class Stenotype::Adapters::Base
An abstract base class for implementing adapters
@abstract @example Defining a custom adapter
MyCustomAdapter < Stenotype::Adapters::Base def publish(event_data, **additional_arguments) client.publish(event_data, **additional_arguments) end def client @client ||= SomeCustomClient.new(some_credential) end end
Attributes
client[R]
Public Class Methods
new(client: nil)
click to toggle source
@return {#publish} An adapter implementing method [#publish]
# File lib/stenotype/adapters/base.rb, line 31 def initialize(client: nil) @client = client end
Public Instance Methods
auto_initialize!()
click to toggle source
Allows custom setup of the adapter. Noop by default @abstract
# File lib/stenotype/adapters/base.rb, line 49 def auto_initialize! # noop by default end
flush!()
click to toggle source
This method is expected to be implemented by subclasses. In case async publisher is used the process might end before the async queue of messages is processed, so this method is going to be used in a `at_exit` hook to flush the queue. @abstract @raise {NotImplementedError} unless implemented in a subclass
# File lib/stenotype/adapters/base.rb, line 61 def flush! raise NotImplementedError, "#{self.class.name} must implement method #flush" end
publish(_event_data, **_additional_attrs)
click to toggle source
This method is expected to be implemented by subclasses @abstract @raise {NotImplementedError} unless implemented in a subclass
# File lib/stenotype/adapters/base.rb, line 40 def publish(_event_data, **_additional_attrs) raise NotImplementedError, "#{self.class.name} must implement method #publish" end