Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ContentUpdateChannel = make(chan *UpdaterSchema, 1) // Channel for content updates callback // PushToContentUpdateChannelFn is a function type that takes an UpdateSchema and a content source PushToContentUpdateChannelFn func(update *UpdaterSchema, contentSource uint8) = PushToContentUpdateChannel )
Functions ¶
func PushToContentUpdateChannel ¶
func PushToContentUpdateChannel(schema *UpdaterSchema, contentSource uint8)
PushToContentUpdateChannel sends an UpdaterSchema to the ContentUpdateChannel.
Types ¶
type AwsAppConfigWatcher ¶
type AwsAppConfigWatcher struct {
// contains filtered or unexported fields
}
AwsAppConfigWatcher is responsible for watching configuration changes.
func NewAwsAppConfigWatcher ¶
func NewAwsAppConfigWatcher(cfg *WatcherOptions, configSource string) *AwsAppConfigWatcher
NewAwsAppConfigWatcher creates a new watcher with the config and update handler.
func (*AwsAppConfigWatcher) OnContentUpdate ¶
func (a *AwsAppConfigWatcher) OnContentUpdate(result *appconfig.FetchConfigResult)
func (*AwsAppConfigWatcher) Watch ¶
func (a *AwsAppConfigWatcher) Watch(ctx context.Context)
Watch begins watching AppConfig. It triggers the updater on change.
type UpdaterSchema ¶
type Watcher ¶
type Watcher interface {
// Watch starts watching a content source for changes.
Watch(ctx context.Context)
}
Watcher interface defines the methods for watching content changes. It is used to abstract the implementation details of different watchers.
type WatcherOptions ¶
type WatcherOptions struct {
// WatcherType specifies which backend or system to watch.
// Example: AwsAppConfig.
WatcherType WatcherType
// OnUpdateCallback is invoked when a change is detected in the content source.
// This is a user-defined function typically used to reload content on disk/memory
OnUpdateCallback func()
// WatchContext controls the lifecycle of the watcher. When the context is cancelled,
// polling is stopped gracefully.
WatchContext context.Context
// Application represents the name of the application whose content is being watched.
// Applicable to systems like AWS AppConfig where configs are tied to applications.
Application string
// ClientID is a unique identifier for the consuming service instance.
// Required by systems like AWS AppConfig to track and differentiate clients.
ClientID string
// ContentScope is a flexible field used to specify profile, namespace, or config path
// depending on the backend system (e.g., config profile in AWS AppConfig,
// KV path or prefix in Consul, etc.).
ContentScope string
// Environment defines the environment for which config is being fetched,
// such as "dev", "staging", or "prod".
Environment string
// PollInterval specifies how often the content source should be checked
// for changes. A shorter duration provides faster reactivity but consumes
// more resources.
PollInterval time.Duration
// Logger is the logger instance used to log watcher activity, errors,
// and updates.
Logger logger.Logger
// ContentSource is an optional backend-specific identifier for the content source.
// It can be used to differentiate between content repositories or buckets if needed.
ContentSource uint8
// ContentFormat is used to describe the format of the fetched content
// (e.g., JSON, YAML, etc.), allowing appropriate parsing logic to be applied.
ContentFormat uint8
// UpdateChannel receives content updates for this watcher. If nil, updates
// are sent to the package-level ContentUpdateChannel for legacy callers.
UpdateChannel chan *UpdaterSchema
}
WatcherOptions defines the behavior for a config/content watcher. It supports contextual polling, automatic update callbacks, and source metadata.
type WatcherType ¶
type WatcherType string
WatcherType represents the supported external systems that can be watched for configuration or content changes.
const ( // WatcherTypeAwsAppConfig represents AWS AppConfig as the source of configuration. WatcherTypeAwsAppConfig WatcherType = "AwsAppConfig" )