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/version_routes.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, VersionRoutes, WorkflowRoutes, WorkflowTemplate

Constant Summary collapse

VALID_STATUS =

From Workflow Service's admin/Process.java

%w[waiting completed error queued skipped started].freeze
VERSION =
'5.0.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



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

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

#queuesObject



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

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

#status(druid:, version:) ⇒ Object



84
85
86
# File 'lib/dor/workflow/client.rb', line 84

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

#templatesObject



80
81
82
# File 'lib/dor/workflow/client.rb', line 80

def templates
  WorkflowTemplate.new(requestor: requestor)
end

#version_routesObject



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

def version_routes
  @version_routes ||= VersionRoutes.new(requestor: requestor)
end

#workflow_routesObject



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

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

#workflow_template(name) ⇒ Object



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

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

#workflow_templatesObject



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

def workflow_templates
  templates.all
end