8000 GitHub - jeroenrinzema/commander at v0.2.1
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

jeroenrinzema/commander

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Commander 🚀

GoDoc Build Status Coverage Coverage Report

Commander is a high-level toolkit for writing event driven applications, aims to be developer friendly. Commander supports event driven patterns such as CQRS and has support for different "dialects". Dialects allow Commander to communicate with different protocols.

Event driven patterns

CQRS stands for Command Query Responsibility Segregation. It's a pattern that I first heard described by Greg Young. At its heart is the notion that you can use a different model to update information than the model you use to read information.

The mainstream approach people use for interacting with an information system is to treat it as a CRUD datastore. By this I mean that we have mental model of some record structure where we can create new records, read records, update existing records, and delete records when we're done with them. In the simplest case, our interactions are all about storing and retrieving these records.

Event Sourcing ensure that every change to the state of an application is captured in an event object, and that these event objects are themselves stored in the sequence they were applied for the same lifetime as the application state itself.

Bidirectional streaming where both sides send a sequence of messages using a read-write stream. The two streams operate independently, so clients and servers can read and write in whatever order they like: for example, the server could wait to receive all the client messages before writing its responses, or it could alternately read a message then write a message, or some other combination of reads and writes. The order of messages in each stream is preserved.

📚 Usage and documentation

Please see godoc for detailed usage docs. Or check out the examples.

Official dialects

  • Mock - Commander in-memory Mock consumer/producer.

  • Kafka - Commander Kafka consumer/producer build upon the Sarama go Kafka client.

  • gRPC connector - protoc gRPC > Commander connector generator

Examples

For more advanced code check out the examples on Github.

Getting started

  • Dialects: A dialect is a application that recieves and/or sends messages.
  • Topic: A Topic is a category/feed name to which messages are stored and published. Different dialects could be assigned to different topics.
  • Groups: A group represents a collection of topics.
  • Client: A commander client holds a collection of groups and is responsible for actions preformed on all groups ex: closing, middleware.

Let's first set up a simple commander group.

dialect := mock.NewDialect()
group := commander.NewGroup(
	NewTopic("commands", dialect, commander.CommandMessage, commander.ConsumeMode),
	NewTopic("event", dialect, commander.EventMessage, commander.ConsumeMode|commander.ProduceMode),
)

client, err := commander.NewClient(group)

Once the event groups are defined and the dialects are initialized could consumers/producers be setup.

group.HandleFunc("example", commander.CommandTopic, func(writer commander.ResponseWriter, message interface{}) {
	writer.ProduceEvent("created", 1, nil, nil)
})

command := commander.NewCommand("example", 1, nil, nil)
group.ProduceCommand(command)

This example consumes commands with the action example and produces at once a event with the action created to the event topic. This example represents a simple CQRS pattern used but commander is not limited by it. Commander tries to be flexible and allowes applications to be written in many different ways.

Dialects

A dialect is the connector to a given protocol or infrastructure. A dialect needs to be defined when constructing a new commander instance. Commander comes shipped with a mocking dialect designed for testing purposes. Check out the dialects directory for the available dialects.

Middleware

Middleware allowes actions to be preformed on event(s) or messages to be manipulated. Check out the middleware directory for the available middleware controllers.

Contributing

Thank you for your interest in contributing to Commander! ❤

Everyone is welcome to contribute, whether it's in the form of code, documentation, bug reports, feature requests, or anything else. We encourage you to experiment with the project and make contributions to help evolve it to meet your needs!

See the contributing guide for more details.

About

Build event-driven and event streaming applications with ease

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  
0