Class: Camunda::Zeebe::API

Inherits:
Object
  • Object
show all
Defined in:
lib/camunda/zeebe/api.rb

Direct Known Subclasses

Jobs, ProcessInstances

Class Method Summary collapse

Class Method Details

.authentication_headersObject



19
20
21
22
23
24
25
# File 'lib/camunda/zeebe/api.rb', line 19

def self.authentication_headers
  token = Camunda::Zeebe::OAuthToken.create
  channel_creds = GRPC::Core::ChannelCredentials.new
  auth_proc = proc { { 'authorization' => "Bearer #{token['access_token']}" } }
  call_creds = GRPC::Core::CallCredentials.new(auth_proc)
  channel_creds.compose(call_creds)
end

.clientObject



15
16
17
# File 'lib/camunda/zeebe/api.rb', line 15

def self.client
  ::Zeebe::Client::GatewayProtocol::Gateway::Stub.new(Camunda.zeebe_url, authentication_headers)
end

.run(method, params = {}) ⇒ Object



8
9
10
11
12
13
# File 'lib/camunda/zeebe/api.rb', line 8

def self.run(method, params = {})
  client.public_send(method, params)
rescue ::GRPC::Unavailable => e
  Rails.logger.error e.message # TODO: give people options to use other logger
  raise e
end