Class: Hatchet::Client
- Inherits:
-
Object
- Object
- Hatchet::Client
- Defined in:
- lib/hatchet-sdk.rb
Overview
The main client for interacting with Hatchet services.
Instance Attribute Summary collapse
-
#config ⇒ Config
readonly
The configuration object used by this client.
Instance Method Summary collapse
-
#admin ⇒ AdminClient
High-level admin client for workflow triggering.
-
#admin_grpc ⇒ Hatchet::Clients::Grpc::Admin
gRPC Admin client (lazy-initialized).
-
#cel ⇒ Hatchet::Features::CEL
Feature Client for debugging CEL expressions.
-
#channel ⇒ GRPC::Core::Channel
Shared gRPC channel (lazy-initialized).
-
#cron ⇒ Hatchet::Features::Cron
Feature Client for managing cron workflows.
-
#dispatcher_grpc ⇒ Hatchet::Clients::Grpc::Dispatcher
gRPC Dispatcher client (lazy-initialized).
-
#durable_task(name:, eviction_policy: Hatchet::DEFAULT_DURABLE_TASK_EVICTION_POLICY, **opts) {|input, ctx| ... } ⇒ Hatchet::Task
Create a standalone durable task.
-
#event_grpc ⇒ Hatchet::Clients::Grpc::EventClient
gRPC Event client (lazy-initialized).
-
#events ⇒ Hatchet::Features::Events
Feature Client for interacting with Hatchet events.
-
#filters ⇒ Hatchet::Features::Filters
Feature Client for managing filters.
-
#initialize(**options) ⇒ Client
constructor
Initialize a new Hatchet client with the given configuration options.
-
#logger ⇒ Logger
Convenience accessor for the logger.
-
#logs ⇒ Hatchet::Features::Logs
Feature Client for interacting with Hatchet logs.
-
#metrics ⇒ Hatchet::Features::Metrics
Feature Client for reading metrics.
-
#rate_limits ⇒ Hatchet::Features::RateLimits
Feature Client for managing rate limits.
- #rest_client ⇒ Object
-
#runs ⇒ Hatchet::Features::Runs
Feature Client for interacting with Hatchet workflow runs.
-
#scheduled ⇒ Hatchet::Features::Scheduled
Feature Client for managing scheduled workflows.
-
#task(name:, **opts) {|input, ctx| ... } ⇒ Hatchet::Task
Create a standalone task (auto-wraps in a single-task workflow).
-
#tenant ⇒ Hatchet::Features::Tenant
Feature Client for interacting with the current tenant.
-
#tenant_id ⇒ String
The tenant ID.
-
#worker(name, **opts) ⇒ Hatchet::Worker
Create a new worker.
-
#workers ⇒ Hatchet::Features::Workers
Feature Client for managing workers.
-
#workflow(name:, **opts) ⇒ Hatchet::Workflow
Create a new workflow definition.
-
#workflow_run_listener ⇒ Hatchet::WorkflowRunListener
Pooled gRPC listener for workflow run completion events (lazy-initialized).
-
#workflows ⇒ Hatchet::Features::Workflows
Feature Client for managing workflow definitions.
Constructor Details
Instance Attribute Details
#config ⇒ Config (readonly)
Returns The configuration object used by this client.
99 100 101 |
# File 'lib/hatchet-sdk.rb', line 99 def config @config end |
Instance Method Details
#admin ⇒ AdminClient
High-level admin client for workflow triggering. Delegates to the gRPC admin client with context variable propagation.
310 311 312 |
# File 'lib/hatchet-sdk.rb', line 310 def admin @admin ||= AdminClient.new(client: self) end |
#admin_grpc ⇒ Hatchet::Clients::Grpc::Admin
gRPC Admin client (lazy-initialized). Uses both v0 WorkflowService and v1 AdminService stubs.
285 286 287 |
# File 'lib/hatchet-sdk.rb', line 285 def admin_grpc @admin_grpc ||= Clients::Grpc::Admin.new(config: @config, channel: channel) end |
#cel ⇒ Hatchet::Features::CEL
Feature Client for debugging CEL expressions
155 156 157 |
# File 'lib/hatchet-sdk.rb', line 155 def cel @cel ||= Hatchet::Features::CEL.new(rest_client, @config) end |
#channel ⇒ GRPC::Core::Channel
Shared gRPC channel (lazy-initialized). A single channel is shared across all gRPC stubs for connection reuse.
270 271 272 |
# File 'lib/hatchet-sdk.rb', line 270 def channel @channel ||= Connection.new_channel(@config) end |
#cron ⇒ Hatchet::Features::Cron
Feature Client for managing cron workflows
185 186 187 |
# File 'lib/hatchet-sdk.rb', line 185 def cron @cron ||= Hatchet::Features::Cron.new(rest_client, @config) end |
#dispatcher_grpc ⇒ Hatchet::Clients::Grpc::Dispatcher
gRPC Dispatcher client (lazy-initialized).
277 278 279 |
# File 'lib/hatchet-sdk.rb', line 277 def dispatcher_grpc @dispatcher_grpc ||= Clients::Grpc::Dispatcher.new(config: @config, channel: channel) end |
#durable_task(name:, eviction_policy: Hatchet::DEFAULT_DURABLE_TASK_EVICTION_POLICY, **opts) {|input, ctx| ... } ⇒ Hatchet::Task
Create a standalone durable task.
235 236 237 238 239 240 |
# File 'lib/hatchet-sdk.rb', line 235 def durable_task(name:, eviction_policy: Hatchet::DEFAULT_DURABLE_TASK_EVICTION_POLICY, **opts, &block) wf = Workflow.new(name: name, client: self, on_events: opts.delete(:on_events) || [], default_filters: opts.delete(:default_filters) || [],) wf.durable_task(name, eviction_policy: eviction_policy, **opts, &block) end |
#event_grpc ⇒ Hatchet::Clients::Grpc::EventClient
gRPC Event client (lazy-initialized).
292 293 294 |
# File 'lib/hatchet-sdk.rb', line 292 def event_grpc @event_grpc ||= Clients::Grpc::EventClient.new(config: @config, channel: channel) end |
#events ⇒ Hatchet::Features::Events
Feature Client for interacting with Hatchet events
125 126 127 |
# File 'lib/hatchet-sdk.rb', line 125 def events @events ||= Hatchet::Features::Events.new(rest_client, event_grpc, @config) end |
#filters ⇒ Hatchet::Features::Filters
Feature Client for managing filters
167 168 169 |
# File 'lib/hatchet-sdk.rb', line 167 def filters @filters ||= Hatchet::Features::Filters.new(rest_client, @config) end |
#logger ⇒ Logger
Convenience accessor for the logger
257 258 259 |
# File 'lib/hatchet-sdk.rb', line 257 def logger @config.logger end |
#logs ⇒ Hatchet::Features::Logs
Feature Client for interacting with Hatchet logs
143 144 145 |
# File 'lib/hatchet-sdk.rb', line 143 def logs @logs ||= Hatchet::Features::Logs.new(rest_client, @config) end |
#metrics ⇒ Hatchet::Features::Metrics
Feature Client for reading metrics
173 174 175 |
# File 'lib/hatchet-sdk.rb', line 173 def metrics @metrics ||= Hatchet::Features::Metrics.new(rest_client, @config) end |
#rate_limits ⇒ Hatchet::Features::RateLimits
Feature Client for managing rate limits
179 180 181 |
# File 'lib/hatchet-sdk.rb', line 179 def rate_limits @rate_limits ||= Hatchet::Features::RateLimits.new(admin_grpc, @config) end |
#rest_client ⇒ Object
119 120 121 |
# File 'lib/hatchet-sdk.rb', line 119 def rest_client @rest_client ||= Hatchet::Clients.rest_client(@config) end |
#runs ⇒ Hatchet::Features::Runs
Feature Client for interacting with Hatchet workflow runs
131 132 133 |
# File 'lib/hatchet-sdk.rb', line 131 def runs @runs ||= Hatchet::Features::Runs.new(rest_client, @config, client: self) end |
#scheduled ⇒ Hatchet::Features::Scheduled
Feature Client for managing scheduled workflows
191 192 193 |
# File 'lib/hatchet-sdk.rb', line 191 def scheduled @scheduled ||= Hatchet::Features::Scheduled.new(rest_client, @config) end |
#task(name:, **opts) {|input, ctx| ... } ⇒ Hatchet::Task
Create a standalone task (auto-wraps in a single-task workflow)
217 218 219 220 221 222 223 |
# File 'lib/hatchet-sdk.rb', line 217 def task(name:, **opts, &block) # Create a workflow wrapper for standalone tasks wf = Workflow.new(name: name, client: self, on_events: opts.delete(:on_events) || [], default_filters: opts.delete(:default_filters) || [],) wf.task(name, **opts, &block) end |
#tenant ⇒ Hatchet::Features::Tenant
Feature Client for interacting with the current tenant
137 138 139 |
# File 'lib/hatchet-sdk.rb', line 137 def tenant @tenant ||= Hatchet::Features::Tenant.new(rest_client, @config) end |
#tenant_id ⇒ String
Returns The tenant ID.
262 263 264 |
# File 'lib/hatchet-sdk.rb', line 262 def tenant_id @config.tenant_id end |
#worker(name, **opts) ⇒ Hatchet::Worker
Create a new worker
251 252 253 |
# File 'lib/hatchet-sdk.rb', line 251 def worker(name, **opts) Worker.new(name: name, client: self, **opts) end |
#workers ⇒ Hatchet::Features::Workers
Feature Client for managing workers
149 150 151 |
# File 'lib/hatchet-sdk.rb', line 149 def workers @workers ||= Hatchet::Features::Workers.new(rest_client, @config) end |
#workflow(name:, **opts) ⇒ Hatchet::Workflow
Create a new workflow definition
204 205 206 |
# File 'lib/hatchet-sdk.rb', line 204 def workflow(name:, **opts) Workflow.new(name: name, client: self, **opts) end |
#workflow_run_listener ⇒ Hatchet::WorkflowRunListener
Pooled gRPC listener for workflow run completion events (lazy-initialized).
Maintains a single bidi stream to ‘Dispatcher.SubscribeToWorkflowRuns` shared by all callers of `WorkflowRunRef#result`.
302 303 304 |
# File 'lib/hatchet-sdk.rb', line 302 def workflow_run_listener @workflow_run_listener ||= WorkflowRunListener.new(config: @config, channel: channel) end |
#workflows ⇒ Hatchet::Features::Workflows
Feature Client for managing workflow definitions
161 162 163 |
# File 'lib/hatchet-sdk.rb', line 161 def workflows @workflows ||= Hatchet::Features::Workflows.new(rest_client, @config) end |