Class: Temporal::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/temporal/configuration.rb

Constant Summary collapse

DEFAULT_TIMEOUTS =

We want an infinite execution timeout for cron schedules and other perpetual workflows. We choose an 10-year execution timeout because that’s the maximum the cassandra DB supports, matching the go SDK, see github.com/temporalio/sdk-go/blob/d96130dad3d2bc189bc7626543bd5911cc07ff6d/internal/internal_workflow_testsuite.go#L68

{
  execution: 86_400 * 365 * 10, # End-to-end workflow time, including all recurrences if it's scheduled.
  # Time for a single run, excluding retries.  Server defaults to execution timeout; we default here as well to be explicit.
  run: 86_400 * 365 * 10,
  task: 10,               # Workflow task processing time
  schedule_to_close: nil, # End-to-end activity time (default: schedule_to_start + start_to_close)
  schedule_to_start: 10,  # Queue time for an activity
  start_to_close: 30,     # Time spent processing an activity
  heartbeat: nil          # Max time between heartbeats (off by default)
}.freeze
DEFAULT_HEADERS =
{}.freeze
DEFAULT_NAMESPACE =
'default-namespace'.freeze
DEFAULT_TASK_QUEUE =
'default-task-queue'.freeze
DEFAULT_CONVERTER =
Temporal::Client::Converter::Composite.new(
  payload_converters: [
    Temporal::Client::Converter::Payload::Nil.new,
    Temporal::Client::Converter::Payload::Bytes.new,
    Temporal::Client::Converter::Payload::JSON.new,
  ]
).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/temporal/configuration.rb', line 39

def initialize
  @client_type = :grpc
  @logger = Temporal::Logger.new(STDOUT, progname: 'temporal_client')
  @metrics_adapter = MetricsAdapters::Null.new
  @timeouts = DEFAULT_TIMEOUTS
  @namespace = DEFAULT_NAMESPACE
  @task_queue = DEFAULT_TASK_QUEUE
  @headers = DEFAULT_HEADERS
  @converter = DEFAULT_CONVERTER
  @error_handlers = []
end

Instance Attribute Details

#client_typeObject

Returns the value of attribute client_type.



12
13
14
# File 'lib/temporal/configuration.rb', line 12

def client_type
  @client_type
end

#converterObject



67
68
69
# File 'lib/temporal/configuration.rb', line 67

def converter
  @converter
end

#error_handlersObject (readonly)

Returns the value of attribute error_handlers.



10
11
12
# File 'lib/temporal/configuration.rb', line 10

def error_handlers
  @error_handlers
end

#headersObject

Returns the value of attribute headers.



12
13
14
# File 'lib/temporal/configuration.rb', line 12

def headers
  @headers
end

#hostObject

Returns the value of attribute host.



12
13
14
# File 'lib/temporal/configuration.rb', line 12

def host
  @host
end

#loggerObject

Returns the value of attribute logger.



12
13
14
# File 'lib/temporal/configuration.rb', line 12

def logger
  @logger
end

#metrics_adapterObject

Returns the value of attribute metrics_adapter.



12
13
14
# File 'lib/temporal/configuration.rb', line 12

def metrics_adapter
  @metrics_adapter
end

#namespaceObject

Returns the value of attribute namespace.



12
13
14
# File 'lib/temporal/configuration.rb', line 12

def namespace
  @namespace
end

#portObject

Returns the value of attribute port.



12
13
14
# File 'lib/temporal/configuration.rb', line 12

def port
  @port
end

#task_queueObject

Returns the value of attribute task_queue.



12
13
14
# File 'lib/temporal/configuration.rb', line 12

def task_queue
  @task_queue
end

#timeoutsObject

Returns the value of attribute timeouts.



10
11
12
# File 'lib/temporal/configuration.rb', line 10

def timeouts
  @timeouts
end

Instance Method Details

#on_error(&block) ⇒ Object



51
52
53
# File 'lib/temporal/configuration.rb', line 51

def on_error(&block)
  @error_handlers << block
end

#task_listObject



55
56
57
# File 'lib/temporal/configuration.rb', line 55

def task_list
  @task_queue
end

#task_list=(name) ⇒ Object



59
60
61
# File 'lib/temporal/configuration.rb', line 59

def task_list=(name)
  self.task_queue = name
end