Class: Hatchet::StatusBasedIdempotencyConfig

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

Overview

Status-based idempotency: keeps the idempotency key alive until the associated run reaches a terminal status. fallback_ttl_ms caps how long the key can live before it's evicted, even if the run has not reached a terminal status.

Examples:

Hatchet::StatusBasedIdempotencyConfig.new(expression: "input.id", fallback_ttl_ms: 10_000)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expression:, fallback_ttl_ms:) ⇒ StatusBasedIdempotencyConfig

Returns a new instance of StatusBasedIdempotencyConfig.

Parameters:

  • expression (String)

    CEL expression to derive the idempotency key

  • fallback_ttl_ms (Integer)

    Fallback TTL for the idempotency key in milliseconds

  • expression: (String)
  • fallback_ttl_ms: (Integer)


47
48
49
50
# File 'lib/hatchet/idempotency.rb', line 47

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

Instance Attribute Details

#expressionString (readonly)

Returns CEL expression evaluated against workflow input.

Returns:

  • (String)

    CEL expression evaluated against workflow input



40
41
42
# File 'lib/hatchet/idempotency.rb', line 40

def expression
  @expression
end

#fallback_ttl_msInteger (readonly)

Returns Fallback TTL in milliseconds; the longest the key can live.

Returns:

  • (Integer)

    Fallback TTL in milliseconds; the longest the key can live



43
44
45
# File 'lib/hatchet/idempotency.rb', line 43

def fallback_ttl_ms
  @fallback_ttl_ms
end

Instance Method Details

#to_protoV1::IdempotencyConfig



53
54
55
56
57
58
59
# File 'lib/hatchet/idempotency.rb', line 53

def to_proto
  ::V1::IdempotencyConfig.new(
    expression: @expression,
    ttl_ms: @fallback_ttl_ms,
    method: ::V1::IdempotencyMethod::STATUS,
  )
end