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 =
'7.2.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



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

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

#queuesObject



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

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

#status(druid:, version:) ⇒ Object



82
83
84
# File 'lib/dor/workflow/client.rb', line 82

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

#templatesObject



78
79
80
# File 'lib/dor/workflow/client.rb', line 78

def templates
  WorkflowTemplate.new(requestor: requestor)
end

#version_routesObject



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

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

#workflow_routesObject



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

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

#workflow_template(name) ⇒ Object



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

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

#workflow_templatesObject



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

def workflow_templates
  templates.all
end