Add the following code to your project's shard.yml under:
dependencies
to use in production
- OR -
development_dependencies
to use in development
harold - crystal library for inter-process pub-sub communication.
Add this to your application's shard.yml
:
dependencies:
harold:
github: waterlink/harold
require "harold"
Harold.start
Harold.publish(topic :: String, "message")
NOTE: topic
is expected to be a valid crystal identifier.
NOTE: :: {{Type}}
part after topic name is the type annotation for message.
spawn do
Harold.subscribe(topic :: String).each do |message|
puts "Someone said: #{message}"
end
end
NOTE: topic
is expected to be a valid crystal identifier.
NOTE: :: {{Type}}
part after topic name is the type annotation for message.
After cloning the project:
crystal deps
or shards
to install development dependencies.crystal spec
to run tests.