Documentation ¶
Overview ¶
Package gconf provides a toolset for managing an extension configuration.
Extension that defines a configuration object can use gconf package to load initial state from genesis, update configuration state via messages and to retrieve configuration object from the store.
Each extension can declare and store only one configuration object.
To use gconf you must follow a few simple principles.
1. Define your configuration as a protobuf message.
2. Define your configuration update message as a protobuf message. It must have a `patch` field that holds the new configuration state.
3. Zero field values are ignored during the update message processing,
4. use `InitConfig` inside of your extension initializer to copy configuration from the genesis into the database,
5. Use `Load` function to load your configuration state from the database,
See existing extensions for an example of how to use this package.
Index ¶
- func InitConfig(db Store, opts weave.Options, pkg string, conf Configuration) error
- func Load(db ReadStore, pkg string, dst Unmarshaler) error
- func Save(db Store, pkg string, src ValidMarshaler) error
- type Configuration
- type OwnedConfig
- type ReadStore
- type Store
- type Unmarshaler
- type UpdateConfigurationHandler
- type ValidMarshaler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitConfig ¶ added in v0.15.0
InitConfig will take opts["conf"][pkg], parse it into the given Configuration object validate it, and store under the proper key in the database Returns an error if anything goes wrong
Types ¶
type Configuration ¶ added in v0.15.0
type Configuration interface { ValidMarshaler Unmarshaler }
type OwnedConfig ¶ added in v0.15.0
type OwnedConfig interface { Unmarshaler ValidMarshaler GetOwner() weave.Address }
OwnedConfig must have an Owner field in protobuf. A configuration update message must be signed by an owner in order to be authorized to apply the change.
type Unmarshaler ¶ added in v0.15.0
Unmarshaler is implemented by object that can load their state from given binary representation. This interface is implemented by all protobuf messages.
type UpdateConfigurationHandler ¶ added in v0.15.0
type UpdateConfigurationHandler struct {
// contains filtered or unexported fields
}
func NewUpdateConfigurationHandler ¶ added in v0.15.0
func NewUpdateConfigurationHandler(pkg string, config OwnedConfig, auth x.Authenticator) UpdateConfigurationHandler
type ValidMarshaler ¶ added in v0.15.0
ValidMarshaler is implemented by object that can serialize itself to a binary representation. Marshal is implemented by all protobuf messages. You must add your own Validate method
Note duplicate of code in x/persistent.go