Class: Gcpc::Interceptors::Subscriber::CheckOrderInterceptor::BaseStrategy
- Inherits:
-
Object
- Object
- Gcpc::Interceptors::Subscriber::CheckOrderInterceptor::BaseStrategy
- Defined in:
- lib/gcpc/interceptors/subscriber/check_order_interceptor.rb
Constant Summary collapse
- DEFAULT_TIMESTAMP_KEY =
"published_at"
- DEFAULT_TTL =
7 days
7 * 24 * 3600
Instance Attribute Summary collapse
-
#ttl ⇒ Object
readonly
Returns the value of attribute ttl.
Instance Method Summary collapse
- #decode_timestamp(str) ⇒ DateTime?
- #group_id(data, attributes, message) ⇒ String
-
#initialize(ttl: DEFAULT_TTL, timestamp_key: DEFAULT_TIMESTAMP_KEY) ⇒ BaseStrategy
constructor
A new instance of BaseStrategy.
- #on_swapped(data, attributes, message, &block) {|data, attributes, message| ... } ⇒ Object
- #timestamp(data, attributes, message) ⇒ String?
Constructor Details
#initialize(ttl: DEFAULT_TTL, timestamp_key: DEFAULT_TIMESTAMP_KEY) ⇒ BaseStrategy
Returns a new instance of BaseStrategy.
12 13 14 15 |
# File 'lib/gcpc/interceptors/subscriber/check_order_interceptor.rb', line 12 def initialize(ttl: DEFAULT_TTL, timestamp_key: DEFAULT_TIMESTAMP_KEY) @ttl = ttl @timestamp_key = DEFAULT_TIMESTAMP_KEY end |
Instance Attribute Details
#ttl ⇒ Object (readonly)
Returns the value of attribute ttl.
17 18 19 |
# File 'lib/gcpc/interceptors/subscriber/check_order_interceptor.rb', line 17 def ttl @ttl end |
Instance Method Details
#decode_timestamp(str) ⇒ DateTime?
29 30 31 32 33 |
# File 'lib/gcpc/interceptors/subscriber/check_order_interceptor.rb', line 29 def (str) DateTime.parse(str) rescue ArgumentError, TypeError nil end |
#group_id(data, attributes, message) ⇒ String
39 40 41 42 43 44 |
# File 'lib/gcpc/interceptors/subscriber/check_order_interceptor.rb', line 39 def group_id(data, attributes, ) # The default behavior is to always return the same key. This means # that all messages should be in order. If you want to change the # set of messages you want to order, please override this method. "same-id" end |
#on_swapped(data, attributes, message, &block) {|data, attributes, message| ... } ⇒ Object
50 51 52 53 |
# File 'lib/gcpc/interceptors/subscriber/check_order_interceptor.rb', line 50 def on_swapped(data, attributes, , &block) # By default, simply yield yield data, attributes, end |
#timestamp(data, attributes, message) ⇒ String?
23 24 25 |
# File 'lib/gcpc/interceptors/subscriber/check_order_interceptor.rb', line 23 def (data, attributes, ) attributes[@timestamp_key] end |