Document is a work-in-progress
Go-gentle
Talk to external services like a gentleman.
Intro
Package gentle defines Stream and Handler interfaces and provides composable resilient implementations of them.
Stream, Handler and back-pressure
Stream and Handler are our fundamental abstractions to achieve back-pressure. Stream has Get() that emits Messages. Handler has Handle() that transforms given Messages. They are composed altogether as one Stream which could then be pulled by the application's main loop.
Resiliency
Resiliency patterns are indispensable in distributed systems because external services are not reliable at all time. We provide some useful patterns in the forms of Streams/Handlers. They include rate-limiting(NewRateLimitedStream, NewRateLimitedHandler), retry/back-off(NewRetryStream, NewRetryHanddler), bulkhead(NewBulkheadStream, NewBulkheadHandler) and circuit-breaker(NewCircuitStream, NewCircuitHandler). Each of them can be freely composed with other Streams/Handlers as one sees fit.
Composability
Developers should implement their own logic in the forms of Streams/Handlers and then
compose them, possibly with our resilient counterpart. This package provides basic helpers like AppendHandlersStream, AppendHandlersHandler, etc., to simplify composition.
If simply appending Streams/Handlers is not enough, developers can define Streams/Handlers
with advanced flow controls, like these resilience Streams/Handlers provided in this package.
Document
GoDoc
Install
The master branch is considered unstable. Always depend on semantic versioning and verdor this library.
If you're using glide, simply run:
glide get gopkg.in/cfchou/go-gentle.v2
glide update
If you're not using package management tools, then
go get http://gopkg.in/cfchou/go-gentle.v2/gentle