Class: Hatchet::TTLBasedIdempotencyConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/hatchet/idempotency.rb,
sig/hatchet/idempotency.rbs

Overview

TTL-based idempotency: prevents duplicate runs within a sliding time window.

Examples:

Hatchet::TTLBasedIdempotencyConfig.new(expression: "input.id", ttl_ms: 60_000)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expression:, ttl_ms:) ⇒ TTLBasedIdempotencyConfig

Returns a new instance of TTLBasedIdempotencyConfig.

Parameters:

  • expression (String)

    CEL expression to derive the idempotency key

  • ttl_ms (Integer)

    TTL for the idempotency key in milliseconds

  • expression: (String)
  • ttl_ms: (Integer)


17
18
19
20
# File 'lib/hatchet/idempotency.rb', line 17

def initialize(expression:, ttl_ms:)
  @expression = expression
  @ttl_ms = ttl_ms
end

Instance Attribute Details

#expressionString (readonly)

Returns CEL expression evaluated against workflow input.

Returns:

  • (String)

    CEL expression evaluated against workflow input



10
11
12
# File 'lib/hatchet/idempotency.rb', line 10

def expression
  @expression
end

#ttl_msInteger (readonly)

Returns How long the idempotency key lives, in milliseconds.

Returns:

  • (Integer)

    How long the idempotency key lives, in milliseconds



13
14
15
# File 'lib/hatchet/idempotency.rb', line 13

def ttl_ms
  @ttl_ms
end

Instance Method Details

#to_protoV1::IdempotencyConfig



23
24
25
# File 'lib/hatchet/idempotency.rb', line 23

def to_proto
  ::V1::IdempotencyConfig.new(expression: @expression, ttl_ms: @ttl_ms)
end