Class: Dor::Workflow::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/dor/workflow/client.rb,
lib/dor/workflow/client/queues.rb,
lib/dor/workflow/client/status.rb,
lib/dor/workflow/client/version.rb,
lib/dor/workflow/client/requestor.rb,
lib/dor/workflow/client/workflow_routes.rb,
lib/dor/workflow/client/lifecycle_routes.rb,
lib/dor/workflow/client/workflow_template.rb,
lib/dor/workflow/client/connection_factory.rb

Overview

TODO: VALID_STATUS should be just another attribute w/ default

Create and update workflows

Defined Under Namespace

Classes: ConnectionFactory, LifecycleRoutes, Queues, Requestor, Status, WorkflowRoutes, WorkflowTemplate

Constant Summary collapse

VALID_STATUS =

From workflow-server-rails' app/models/workflow_step.rb

%w[waiting completed error queued skipped started retrying].freeze
VERSION =
'7.7.0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url: nil, logger: default_logger, timeout: nil, connection: nil) ⇒ Client

Configure the workflow service

Parameters:

  • :url (String)

    points to the workflow service

  • :logger (Logger)

    defaults writing to workflow_service.log with weekly rotation

  • :timeout (Integer)

    number of seconds for HTTP timeout

  • :connection (Faraday::Connection)

    the REST client resource

Raises:

  • (ArgumentError)


37
38
39
40
41
# File 'lib/dor/workflow/client.rb', line 37

def initialize(url: nil, logger: default_logger, timeout: nil, connection: nil)
  raise ArgumentError, 'You must provide either a connection or a url' if !url && !connection

  @requestor = Requestor.new(connection: connection || ConnectionFactory.build_connection(url, timeout: timeout, logger: logger))
end

Instance Attribute Details

#requestorObject

Returns the value of attribute requestor.



30
31
32
# File 'lib/dor/workflow/client.rb', line 30

def requestor
  @requestor
end

Instance Method Details

#lifecycle_routesObject



59
60
61
# File 'lib/dor/workflow/client.rb', line 59

def lifecycle_routes
  @lifecycle_routes ||= LifecycleRoutes.new(requestor: requestor)
end

#queuesObject



51
52
53
# File 'lib/dor/workflow/client.rb', line 51

def queues
  @queues ||= Queues.new(requestor: requestor)
end

#status(druid:, version:) ⇒ Object



75
76
77
# File 'lib/dor/workflow/client.rb', line 75

def status(druid:, version:)
  Status.new(druid: druid, version: version, lifecycle_routes: lifecycle_routes)
end

#templatesObject



71
72
73
# File 'lib/dor/workflow/client.rb', line 71

def templates
  WorkflowTemplate.new(requestor: requestor)
end

#workflow_routesObject



55
56
57
# File 'lib/dor/workflow/client.rb', line 55

def workflow_routes
  @workflow_routes ||= WorkflowRoutes.new(requestor: requestor)
end

#workflow_template(name) ⇒ Object



63
64
65
# File 'lib/dor/workflow/client.rb', line 63

def workflow_template(name)
  templates.retrieve(name)
end

#workflow_templatesObject



67
68
69
# File 'lib/dor/workflow/client.rb', line 67

def workflow_templates
  templates.all
end