symphony

Version, currently 0.1.13 versions

github.com/philipp-classen/symphony

Symphony: A Crystal framework for streamlined asynchronous input/output handling with safe shutdown protocols.

0 stars
0 dependents
License: MIT

Nothing has been indexed for 0.1.1 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.

Installation

# Add this to your shard.yml
dependencies:
  symphony:
    github: philipp-classen/symphony
    version: ~> 0.1.1

Then run:

shards install

shard.yml

No shard.yml has been indexed for 0.1.1. You can read it on the repository.

Dependencies

Unknown: the shard.yml for this version has not been read yet.

README

This README is the one indexed from the repository at its latest ref, not from the tag for this version.

Symphony

Simplifies the startup and safe shutdown of Crystal servers that process inputs (such as queues and HTTP requests) and stream them to various outputs. Unlike traditional HTTP servers that directly respond to requests, this framework is designed for asynchronous processing.

The core idea is to let the application define a list of readers (input) and writers (output), where each reader and writer will run independently.

The framework will take care of the proper startup (first the writers, then the readers) and the safe shutdown (stopping first the readers, then the writers). It will also handle signals like SIGINT or SIGTERM.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      symphony:
        github: philipp-classen/symphony
  2. Run shards install

Usage

Here is a minimal example to illustrate how to set up a basic server. While this example does not include a writer and may not be practically useful, it demonstrates the basic structure of a Symphony application.

require "symphony"

class Application < Symphony::Application
  Log = ::Log.for("test-app")

  def create_input_readers : Array(Symphony::BackgroundService)
    server = Symphony::HttpServer.new do |ctx|
      ctx.response.content_type = "text/plain"
      ctx.response.print "Hello world, got #{ctx.request.path}!"
    end
    [server] of Symphony::BackgroundService
  end

  def create_output_writers : Array(Symphony::BackgroundService)
    [] of Symphony::BackgroundService
  end
end

Log.setup_from_env
APP = Application.new
APP.run

Development

There are currently no tests.

Contributing

  1. Fork it (https://github.com/philipp-classen/symphony/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