Class: Familia::Validation::CommandRecorder::RecordedCommand
- Inherits:
-
Object
- Object
- Familia::Validation::CommandRecorder::RecordedCommand
- Defined in:
- lib/familia/validation/command_recorder.rb
Overview
Represents a single Redis command with full context
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#command_type ⇒ Object
readonly
Returns the value of attribute command_type.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#duration_us ⇒ Object
readonly
Returns the value of attribute duration_us.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#atomic_command? ⇒ Boolean
-
#initialize(command:, args:, result:, timestamp:, duration_us:, context: {}) ⇒ RecordedCommand
constructor
A new instance of RecordedCommand.
-
#pipeline_command? ⇒ Boolean
-
#to_h ⇒ Object
-
#to_s ⇒ Object
-
#transaction_command? ⇒ Boolean
Constructor Details
#initialize(command:, args:, result:, timestamp:, duration_us:, context: {}) ⇒ RecordedCommand
Returns a new instance of RecordedCommand.
40 41 42 43 44 45 46 47 48 |
# File 'lib/familia/validation/command_recorder.rb', line 40 def initialize(command:, args:, result:, timestamp:, duration_us:, context: {}) @command = command.to_s.upcase @args = args.dup.freeze @result = result @timestamp = @duration_us = duration_us @context = context.dup.freeze @command_type = determine_command_type end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
38 39 40 |
# File 'lib/familia/validation/command_recorder.rb', line 38 def args @args end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
38 39 40 |
# File 'lib/familia/validation/command_recorder.rb', line 38 def command @command end |
#command_type ⇒ Object (readonly)
Returns the value of attribute command_type.
38 39 40 |
# File 'lib/familia/validation/command_recorder.rb', line 38 def command_type @command_type end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
38 39 40 |
# File 'lib/familia/validation/command_recorder.rb', line 38 def context @context end |
#duration_us ⇒ Object (readonly)
Returns the value of attribute duration_us.
38 39 40 |
# File 'lib/familia/validation/command_recorder.rb', line 38 def duration_us @duration_us end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
38 39 40 |
# File 'lib/familia/validation/command_recorder.rb', line 38 def result @result end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
38 39 40 |
# File 'lib/familia/validation/command_recorder.rb', line 38 def @timestamp end |
Instance Method Details
#atomic_command? ⇒ Boolean
75 76 77 |
# File 'lib/familia/validation/command_recorder.rb', line 75 def atomic_command? @context[:transaction] == true end |
#pipeline_command? ⇒ Boolean
71 72 73 |
# File 'lib/familia/validation/command_recorder.rb', line 71 def pipeline_command? @context[:pipeline] == true end |
#to_h ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/familia/validation/command_recorder.rb', line 55 def to_h { command: @command, args: @args, result: @result, timestamp: @timestamp, duration_us: @duration_us, context: @context, command_type: @command_type } end |
#to_s ⇒ Object
50 51 52 53 |
# File 'lib/familia/validation/command_recorder.rb', line 50 def to_s args_str = @args.map(&:inspect).join(', ') "#{@command}(#{args_str})" end |
#transaction_command? ⇒ Boolean
67 68 69 |
# File 'lib/familia/validation/command_recorder.rb', line 67 def transaction_command? %w[MULTI EXEC DISCARD].include?(@command) end |