Class: Operaton::Bpm::Client::Impl::ExternalTaskClientBuilderImpl

Inherits:
Object
  • Object
show all
Includes:
ExternalTaskClientBuilder
Defined in:
lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb

Overview

Mirrors org.operaton.bpm.client.impl.ExternalTaskClientBuilderImpl

Constant Summary

Constants included from ExternalTaskClientBuilder

ExternalTaskClientBuilder::INTERFACE_METHODS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeExternalTaskClientBuilderImpl

Returns a new instance of ExternalTaskClientBuilderImpl.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 47

def initialize
  # default values
  @worker_id = nil
  @max_tasks = 10
  @use_priority = true
  @ordering_config = Task::OrderingConfig.empty
  @async_response_timeout = nil
  @lock_duration = 20_000
  @default_serialization_format = Engine::Variable::Variables::SerializationDataFormats::JSON
  @date_format = ObjectMapper::DEFAULT_DATE_FORMAT
  @interceptors = []
  @is_auto_fetching_enabled = true
  @backoff_strategy = Backoff::ExponentialBackoffStrategy.new
  @is_backoff_strategy_disabled = false
  @http_customizer = nil
  @url_resolver = PermanentUrlResolver.new(nil)
  @object_mapper = nil
  @value_mappers = nil
  @typed_values = nil
  @engine_client = nil
  @topic_subscription_manager = nil
end

Instance Attribute Details

#engine_clientObject (readonly)

Returns the value of attribute engine_client.



45
46
47
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 45

def engine_client
  @engine_client
end

#object_mapperObject (readonly)

Returns the value of attribute object_mapper.



45
46
47
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 45

def object_mapper
  @object_mapper
end

#typed_valuesObject (readonly)

Returns the value of attribute typed_values.



45
46
47
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 45

def typed_values
  @typed_values
end

#value_mappersObject (readonly)

Returns the value of attribute value_mappers.



45
46
47
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 45

def value_mappers
  @value_mappers
end

Instance Method Details

#add_interceptor(interceptor) ⇒ Object



85
86
87
88
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 85

def add_interceptor(interceptor)
  @interceptors << interceptor
  self
end

#ascObject



113
114
115
116
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 113

def asc
  @ordering_config.configure_direction_on_last_field(Task::OrderingConfig::Direction::ASC)
  self
end

#async_response_timeout(async_response_timeout) ⇒ Object



123
124
125
126
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 123

def async_response_timeout(async_response_timeout)
  @async_response_timeout = async_response_timeout
  self
end

#backoff_strategy(backoff_strategy) ⇒ Object



138
139
140
141
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 138

def backoff_strategy(backoff_strategy)
  @backoff_strategy = backoff_strategy
  self
end

#base_url(base_url) ⇒ Object



70
71
72
73
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 70

def base_url(base_url)
  @url_resolver = PermanentUrlResolver.new(base_url)
  self
end

#buildObject



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 166

def build
  raise logger.max_tasks_not_greater_than_zero_exception(@max_tasks) if @max_tasks <= 0

  if !@async_response_timeout.nil? && @async_response_timeout <= 0
    raise logger.async_response_timeout_not_greater_than_zero_exception(@async_response_timeout)
  end

  raise logger.lock_duration_is_not_greater_than_zero_exception(@lock_duration) if @lock_duration <= 0

  raise logger.base_url_null_exception if @url_resolver.nil? || get_base_url.nil? || get_base_url.empty?

  check_interceptors
  @ordering_config.validate_ordering_properties

  init_base_url
  init_worker_id
  init_object_mapper
  init_engine_client
  init_variable_mappers
  init_topic_subscription_manager

  ExternalTaskClientImpl.new(@topic_subscription_manager)
end

#customize_http_client(customizer = nil, &block) ⇒ Object

Accepts a block invoked with the Net::HTTP instance of every request.



161
162
163
164
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 161

def customize_http_client(customizer = nil, &block)
  @http_customizer = customizer || block
  self
end

#date_format(date_format) ⇒ Object

A Ruby strftime pattern (default "%Y-%m-%dT%H:%M:%S.%L%z", the equivalent of the Java client's "yyyy-MM-dd'T'HH:mm:ss.SSSZ").



155
156
157
158
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 155

def date_format(date_format)
  @date_format = date_format
  self
end

#default_serialization_format(default_serialization_format) ⇒ Object



148
149
150
151
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 148

def default_serialization_format(default_serialization_format)
  @default_serialization_format = default_serialization_format
  self
end

#descObject



118
119
120
121
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 118

def desc
  @ordering_config.configure_direction_on_last_field(Task::OrderingConfig::Direction::DESC)
  self
end

#disable_auto_fetchingObject



133
134
135
136
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 133

def disable_auto_fetching
  @is_auto_fetching_enabled = false
  self
end

#disable_backoff_strategyObject



143
144
145
146
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 143

def disable_backoff_strategy
  @is_backoff_strategy_disabled = true
  self
end

#get_base_urlObject

rubocop:disable Naming/AccessorMethodName



190
191
192
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 190

def get_base_url # rubocop:disable Naming/AccessorMethodName
  @url_resolver.base_url
end

#get_date_formatObject

rubocop:disable Naming/AccessorMethodName



198
199
200
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 198

def get_date_format # rubocop:disable Naming/AccessorMethodName
  @date_format
end

#get_default_serialization_formatObject

rubocop:disable Naming/AccessorMethodName



194
195
196
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 194

def get_default_serialization_format # rubocop:disable Naming/AccessorMethodName
  @default_serialization_format
end

#lock_duration(lock_duration) ⇒ Object



128
129
130
131
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 128

def lock_duration(lock_duration)
  @lock_duration = lock_duration
  self
end

#max_tasks(max_tasks) ⇒ Object



90
91
92
93
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 90

def max_tasks(max_tasks)
  @max_tasks = max_tasks
  self
end

#order_by_create_timeObject



108
109
110
111
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 108

def order_by_create_time
  @ordering_config.configure_field(Task::OrderingConfig::SortingField::CREATE_TIME)
  self
end

#url_resolver(url_resolver) ⇒ Object



75
76
77
78
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 75

def url_resolver(url_resolver)
  @url_resolver = url_resolver
  self
end

#use_create_time(use_create_time) ⇒ Object



100
101
102
103
104
105
106
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 100

def use_create_time(use_create_time)
  if use_create_time
    @ordering_config.configure_field(Task::OrderingConfig::SortingField::CREATE_TIME)
    @ordering_config.configure_direction_on_last_field(Task::OrderingConfig::Direction::DESC)
  end
  self
end

#use_priority(use_priority) ⇒ Object



95
96
97
98
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 95

def use_priority(use_priority)
  @use_priority = use_priority
  self
end

#worker_id(worker_id) ⇒ Object



80
81
82
83
# File 'lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb', line 80

def worker_id(worker_id)
  @worker_id = worker_id
  self
end