Switch branches/tags
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
README.md
daemon.go
daemon_test.go
posixsignal.go
posixsignal_test.go
runner.go
runner_test.go

README.md

Package contextx

Description

package contextx adds abstractions needed to run tasks that receive a context.Context. The goal is to provide a common abstraction that will enable running and stopping tasks, and also to compose and decorate its executions.

Types

Everything is build around this simple interface:

type Runner interface {
	Run(context.Context)
}

It receives a context.Context type, which is very useful when applying Go Concurrency Patterns and implement concerns like cancellation.

There is also available its functional countertype RunnerFunc in case no state is needed, and Multi which runs multiple Runners at the same time.

An Adapter augments the capabilities of a Runner to do more things when it runs. There is also available its functional countertype AdapterFunc in case no state is needed, and a MultiAdapter which adapts multiple Runners at the same time.

TODO

Create runners and adapters for the basic cross-cutting concerns of an application:

  • OS signal handling (stop, reload, kill, config change)
  • graceful shutdown handling
  • panic handling
  • logging
  • instrumentation
  • event dispatching
  • compile information
  • metrics