Class: FaaStRuby::Subscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/faastruby/server/subscriber.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Subscriber

Returns a new instance of Subscriber.



4
5
6
7
# File 'lib/faastruby/server/subscriber.rb', line 4

def initialize(path)
  @path = path
  @workspace_name, @function_name = @path.split("/")
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



3
4
5
# File 'lib/faastruby/server/subscriber.rb', line 3

def path
  @path
end

Instance Method Details

#call(encoded_data) ⇒ Object



9
10
11
12
13
14
# File 'lib/faastruby/server/subscriber.rb', line 9

def call(encoded_data)
  data = Base64.urlsafe_decode64(encoded_data)
  headers = {'X-Origin' => 'event_hub', 'Content-Transfer-Encoding' => 'base64'}
  event = Event.new(body: data, query_params: {}, headers: headers, context: nil)
  Runner.new.call(@workspace_name, @function_name, event, [])
end