Documentation
¶
Overview ¶
Package artifact defines a minimal library that can be used to define updatable types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNilValue is used when a nil paramater is provided ErrNilValue = errors.New("nil value provided") )
Functions ¶
This section is empty.
Types ¶
type Artifact ¶
type Artifact interface {
// RWLocker is required to ensure go routine safety.
RWLocker
// ModifiedAt returns the time that the artifact
// was last updated.
ModifiedAt() time.Time
// NotifyUpdate will inform all registered listeners
// that a change has been made and will also update
// modified time for the type.
NotifyUpdated(ctx context.Context)
// Register stores the information about the channel
// and will send updates once Update is called successfully
Register(notify chan<- struct{}) (err error)
// Update must read the incoming reader to then
// apply the update to the type, any issue will
// return ar error and not notifications will happen.
//
// Note: Callee's a requried to call `Artifact.Lock` and `Artifact.Unlock`
// respectively, they must not be called within the update method.
Update(in io.Reader) error
}
Artifact allows other components to be notified when this type has changed
type Client ¶
type Client interface {
// Register will associate a name that can help with identifying
// updates (ie. name = URI(/path/to/schema/definition)) that the client
// is aware of and can pass those updates to the Artifact.
// Register MUST fail when the initial load is not possible, any failures
// after that point is treated as transitive and should be handled
Register(ctx context.Context, name string, art Artifact) error
// MonitorUpdates is used to update all registered components
// that can be done as background task
MonitorUpdates(ctx context.Context) error
}
Client represents a minimal viable interface that would be needed to provide async updates of Artifacts.
type Notifier ¶
Notifier is a partial implementation of Artifact so that it can be embedded into types to help reduce code duplication
func (*Notifier) ModifiedAt ¶
func (*Notifier) NotifyUpdated ¶
Click to show internal directories.
Click to hide internal directories.