crystal-agency

Crystal language shard which provides simple traits to be included for agents that can start and stop, and supervisors which manage a list of agents

Agency

Crystal language shard which provides simple traits to be included for agents that can start and stop, and supervisors which manage a list of agents.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      crystal-agency:
        github: lachlan/crystal-agency
    
  2. Run shards install

Usage

require "agency"

class ExampleAgent
  include Agency::Agent

  def run : Nil
    count = 1
    while started?
      Log.info { "count = #{count}" }
      count += 1
      sleep 1.second
    end
  end
end

class ExampleSupervisor
  include Agency::Supervisor
end

agent = ExampleAgent.new
supervisor = ExampleSupervisor.new
supervisor << agent # supervise the agent with the supervisor
supervisor.start # starts self and all managed agents and waits for completion

Contributing

  1. Fork it (https://github.com/lachlan/crystal-agency/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Repository

crystal-agency

Owner
Statistic
  • 0
  • 0
  • 0
  • 0
  • 0
  • about 8 hours ago
  • August 19, 2026
License

MIT License

Links
Synced at

Wed, 19 Aug 2026 04:45:07 GMT

Languages