blockit

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2022 License: MIT Imports: 1 Imported by: 0

README

Blockit

GitHub Workflow Status (branch) Go Reportcard go.dev reference License Release

Blockit provides an interface for establishing blockers where you do not wish to proceed until a certain number of tasks are done. Each of the defined blockers can then be fed into a Multiblocker that will wait for all of them to be finished before proceeding.

Primary Use Case

The reason this library exists is to allow for configuration of a service to proceed all the way to the point of standing up a status endpoint. It is intended to allow the service to configure itself asynchronously of its dependencies and not report healthy until those dependencies are all met. This is particularly useful with Docker and having the service start before its database, telemetry infrastructure, and logging infrastructure are in place.

Installation

go get github.com/gomicro/blockit

Usage

See the examples within the docs for ways to use the library.

Versioning

The library will be versioned in accordance with Semver 2.0.0. See the releases section for the latest version. Until version 1.0.0 the libary is considered to be unstable.

It is always highly recommended to vendor the version you are using.

License

See LICENSE.md for more information.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blocker

type Blocker interface {
	Blockit() <-chan struct{}
	BlockitWithContext(ctx context.Context) <-chan struct{}
}

Blocker represents an object that will have a Blockit function as a method for determining when the object is done with a given task.

type MultiBlocker

type MultiBlocker struct {
	// contains filtered or unexported fields
}

MultiBlocker represent many blockers to monitor and determine when they are done.

func (*MultiBlocker) Add

func (b *MultiBlocker) Add(blocker ...Blocker)

Add takes one to many blockers to append into the multiblocker

func (*MultiBlocker) Blockit

func (b *MultiBlocker) Blockit() <-chan struct{}

Blockit meets the blocker interface and summarizes multiple blockers into a single channel for blocking on.

func (*MultiBlocker) BlockitWithContext added in v0.1.0

func (b *MultiBlocker) BlockitWithContext(ctx context.Context) <-chan struct{}

BlockitWithContext takes a context to include with the blockers. The multiblocker will return if the context is cancelled before the blockers finish.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL