Module: Logux

Includes:
Configurations
Defined in:
lib/logux/add.rb,
lib/logux/auth.rb,
lib/logux/meta.rb,
lib/logux/node.rb,
lib/logux/rack.rb,
lib/logux/test.rb,
lib/logux/utils.rb,
lib/logux/action.rb,
lib/logux/client.rb,
lib/logux/policy.rb,
lib/logux/stream.rb,
lib/logux/actions.rb,
lib/logux/process.rb,
lib/logux/rack/app.rb,
lib/logux/response.rb,
lib/logux/rake_tasks.rb,
lib/logux/test/store.rb,
lib/logux/class_finder.rb,
lib/logux/process/auth.rb,
lib/logux/rack/version.rb,
lib/logux/test/helpers.rb,
lib/logux/action_caller.rb,
lib/logux/policy_caller.rb,
lib/logux/process/batch.rb,
lib/logux/test/matchers.rb,
lib/logux/action_watcher.rb,
lib/logux/error_renderer.rb,
lib/logux/process/action.rb,
lib/logux/base_controller.rb,
lib/logux/action_controller.rb,
lib/logux/channel_controller.rb,
lib/logux/test/matchers/base.rb,
lib/logux/test/matchers/send_to_logux.rb,
lib/logux/test/matchers/response_chunks.rb

Defined Under Namespace

Modules: Process, Rack, Test, Utils Classes: Action, ActionCaller, ActionController, ActionWatcher, Actions, Add, Auth, BaseController, ChannelController, ClassFinder, Client, ErrorRenderer, Meta, Node, Policy, PolicyCaller, RakeTasks, Response, Stream, WithMetaError

Constant Summary collapse

PROTOCOL_VERSION =
1
UnknownActionError =
Class.new(WithMetaError)
UnknownChannelError =
Class.new(WithMetaError)
UnauthorizedError =
Class.new(StandardError)
ParameterMissingError =
Class.new(StandardError)

Class Method Summary collapse

Class Method Details

.action_watcherObject



121
122
123
# File 'lib/logux/rack.rb', line 121

def action_watcher
  configuration.action_watcher.new(configuration.action_watcher_options)
end

.add(action, meta = Meta.new) ⇒ Object



83
84
85
# File 'lib/logux/rack.rb', line 83

def add(action, meta = Meta.new)
  Logux::Add.new.call([[action, meta]])
end

.add_batch(commands) ⇒ Object



87
88
89
# File 'lib/logux/rack.rb', line 87

def add_batch(commands)
  Logux::Add.new.call(commands)
end

.applicationObject



129
130
131
# File 'lib/logux/rack.rb', line 129

def application
  Logux::Rack::App
end

.generate_action_idObject



113
114
115
# File 'lib/logux/rack.rb', line 113

def generate_action_id
  Logux::Node.instance.generate_action_id
end

.loggerObject



117
118
119
# File 'lib/logux/rack.rb', line 117

def logger
  configuration.logger
end

.process_batch(stream:, batch:) ⇒ Object



109
110
111
# File 'lib/logux/rack.rb', line 109

def process_batch(stream:, batch:)
  Logux::Process::Batch.new(stream: stream, batch: batch).call
end

.undo(meta, reason: nil, data: {}) ⇒ Object



91
92
93
94
95
96
# File 'lib/logux/rack.rb', line 91

def undo(meta, reason: nil, data: {})
  add(
    data.merge(type: 'logux/undo', id: meta.id, reason: reason),
    Logux::Meta.new(clients: [meta.client_id])
  )
end

.verify_request_meta_data(meta_params) ⇒ Object

Raises:



98
99
100
101
102
103
104
105
106
107
# File 'lib/logux/rack.rb', line 98

def (meta_params)
  if configuration.password.nil?
    logger.warn(%(Please, add password for logux server:
                        Logux.configure do |c|
                          c.password = 'your-password'
                        end))
  end
  auth = configuration.password == meta_params&.dig('password')
  raise UnauthorizedError, 'Incorrect password' unless auth
end

.watch_actionObject



125
126
127
# File 'lib/logux/rack.rb', line 125

def watch_action
  action_watcher.call { yield }
end