Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
leopard (0.1.7)
leopard (0.2.1)
concurrent-ruby (~> 1.1)
dry-configurable (~> 1.3)
dry-monads (~> 1.9)
Expand Down Expand Up @@ -53,7 +53,7 @@ GEM
racc (1.8.1)
rainbow (3.1.1)
rake (13.3.0)
regexp_parser (2.11.0)
regexp_parser (2.11.1)
reline (0.6.2)
io-console (~> 0.5)
rubocop (1.79.2)
Expand Down
32 changes: 32 additions & 0 deletions examples/groups.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,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