Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFound reports a missing configuration document. ErrNotFound = errors.New("sundial: not found") // ErrConflict reports that a write was based on a stale configuration revision. ErrConflict = errors.New("sundial: conflict") // ErrEmptyDocument reports an empty configuration document. ErrEmptyDocument = errors.New("sundial: empty configuration document") )
Functions ¶
func IsConflict ¶
func IsNotFound ¶
Types ¶
type Entry ¶
Entry pairs a detached configuration value with the Provider metadata from the same in-memory snapshot.
type Metadata ¶
type Metadata struct {
Revision string
}
Metadata describes the Provider state paired with a configuration document.
type Option ¶
type Option func(*options)
Option configures a Sundial instance.
func WithLogger ¶
WithLogger configures structured debug and automatic reload error logging.
func WithOnChange ¶
func WithOnChange(callback func()) Option
WithOnChange sets the callback run after a changed configuration is published.
func WithOnError ¶
WithOnError sets the automatic reload error callback.
type Provider ¶
type Provider interface {
// Get returns the current document and its revision from the same logical
// read. A missing document returns ErrNotFound and zero Metadata.
Get(ctx context.Context) ([]byte, Metadata, error)
// Put writes the document without checking the current revision.
Put(ctx context.Context, data []byte) (Metadata, error)
// PutIfRevision atomically replaces an existing document only when the non-empty
// expectedMetadata.Revision matches the current revision. It returns the
// metadata paired with the saved document; a mismatch returns ErrConflict.
PutIfRevision(ctx context.Context, data []byte, expectedMetadata Metadata) (Metadata, error)
}
Provider reads and writes one complete configuration document.
type Sundial ¶
type Sundial[T any] struct { // contains filtered or unexported fields }
Sundial manages one typed configuration document and its in-memory state.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package codec defines configuration document encoding and decoding.
|
Package codec defines configuration document encoding and decoding. |
|
json
Package json provides a JSON codec backed by the Go standard library.
|
Package json provides a JSON codec backed by the Go standard library. |
|
yaml
Package yaml provides a YAML codec backed by go.yaml.in/yaml/v3.
|
Package yaml provides a YAML codec backed by go.yaml.in/yaml/v3. |
|
examples
|
|
|
s3
command
|
|
|
provider
|
|
|
s3
Package s3 provides a Sundial Provider backed by one standard S3 object.
|
Package s3 provides a Sundial Provider backed by one standard S3 object. |
|
testing
Package providertesting provides Provider implementations for Sundial tests.
|
Package providertesting provides Provider implementations for Sundial tests. |
Click to show internal directories.
Click to hide internal directories.