-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgroups.rb
More file actions
executable file
·32 lines (27 loc) · 865 Bytes
/
groups.rb
File metadata and controls
executable file
·32 lines (27 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env ruby
# frozen_string_literal: true
require_relative '../lib/leopard/nats_api_server'
# Example to echo the given message
class ServiceGroups
include Rubyists::Leopard::NatsApiServer
def initialize(a_var: 1)
logger.info "ServiceGroups initialized with a_var: #{a_var}"
end
group :mammal
group :feline, group: :mammal, queue: :meow
endpoint(:sound, group: :feline) { |msg| Success("Meow! #{msg.data}") }
endpoint(:fail, group: :feline) { |msg| Failure({ reason: 'cat nap', data: msg.data }) }
end
if __FILE__ == $PROGRAM_NAME
SemanticLogger.default_level = :info
SemanticLogger.add_appender(io: $stdout, formatter: :color)
ServiceGroups.run(
nats_url: 'nats://localhost:4222',
service_opts: {
name: 'example.groups',
version: '1.0.0',
instance_args: { a_var: 2 },
},
instances: 1,
)
end