Class: Coil::QueueLocking::Key

Inherits:
Object
  • Object
show all
Defined in:
lib/coil/queue_locking.rb

Constant Summary collapse

PREFIX =
"QueueLocking"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(queue_type:, message_type:, message_key:) ⇒ Key

Construct a key suitable for obtaining a PostgreSQL advisory lock. www.postgresql.org/docs/current/explicit-locking.html#ADVISORY-LOCKS



14
15
16
17
# File 'lib/coil/queue_locking.rb', line 14

def initialize(queue_type:, message_type:, message_key:)
  @text = [PREFIX, queue_type, message_type, stringify(message_key)].join("|")
  @int64 = Digest::SHA256.digest(@text).slice(0, 8).unpack1("q")
end

Instance Attribute Details

#int64Object (readonly)

Returns the value of attribute int64.



20
21
22
# File 'lib/coil/queue_locking.rb', line 20

def int64
  @int64
end

#textObject (readonly)

Returns the value of attribute text.



19
20
21
# File 'lib/coil/queue_locking.rb', line 19

def text
  @text
end