contextack: github.com/tsavola/contextack Index | Files | Directories

package contextack

import "github.com/tsavola/contextack"

Package contextack extends context.Context with cancellation acknowledgement.

API implementations should provide context value keys for functions which support context. A group of functions may share the same key if only one of them will be called with a given context (including any parent context which was created via WithAck). The functions should call Ack with the key just before exiting.

API clients should call WithAck with the key which represents the function they are about to call. When it's important to wait until the function has finished, the receive channel returned by WithAck can be used.

Index

Package Files

ack.go

func Ack Uses

func Ack(ctx context.Context, key interface{})

Ack notifies all subscribers that the operation represented by the key has finished. It's ok to call this even when there are no subscribers.

func WithAck Uses

func WithAck(ctx context.Context, key interface{}) (context.Context, <-chan struct{})

WithAck returns ctx or a copy of it, and a channel which will be closed when the operation represented by the key has finished.

Directories

PathSynopsis
example

Package contextack imports 1 packages (graph) and is imported by 2 packages. Updated 2018-11-29. Refresh now. Tools for package owners.