Sha256: 3d08a7391838a42802c223692e13043195e9a922ac763c20583701f66423257e

Contents?: true

Size: 432 Bytes

Versions: 4

Compression:

Stored size: 432 Bytes

Contents

require_relative "../../lib/moleculer"

class Server < Moleculer::Service::Base
  service_name "math"
  action "add", :add
  event "echo.event", :echo

  def add(ctx)
    {
      count: ctx.params.count,
      res:   ctx.params["a"].to_i + ctx.params["b"].to_i,
    }
  end

  def echo(data)
    broker.emit("reply.event", data)
  end
end

Moleculer.configure do |c|
  c.log_level = :trace
  c.services << Server
end

Moleculer.run

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
moleculer-0.3.0 examples/client-server/server.rb
moleculer-0.2.0 examples/client-server/server.rb
moleculer-0.1.1 examples/client-server/server.rb
moleculer-0.1.0 examples/client-server/server.rb