Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeURIPath(next echo.HandlerFunc) echo.HandlerFunc
- func RegisterEngine(engine *Engine)
- func StatusOK(ctx echo.Context) error
- type DiagnosticResult
- type EchoRouter
- type Engine
- type EngineControl
- type Error
- type GenericDiagnosticResult
- type NutsConfigValues
- type NutsEventError
- type NutsGlobalConfig
- func (ngc NutsGlobalConfig) GetEngineMode(engineMode string) string
- func (ngc NutsGlobalConfig) Identity() stringdeprecated
- func (ngc NutsGlobalConfig) InStrictMode() bool
- func (ngc *NutsGlobalConfig) InjectIntoEngine(e *Engine) error
- func (ngc *NutsGlobalConfig) Load(cmd *cobra.Command) error
- func (ngc *NutsGlobalConfig) LoadAndUnmarshal(cmd *cobra.Command, targetCfg interface{}) error
- func (ngc NutsGlobalConfig) Mode() string
- func (ngc *NutsGlobalConfig) PrintConfig(logger log.FieldLogger)
- func (ngc *NutsGlobalConfig) RegisterFlags(cmd *cobra.Command, e *Engine)
- func (ngc NutsGlobalConfig) ServerAddress() string
- func (ngc NutsGlobalConfig) VendorID() PartyID
- type PartyID
Constants ¶
const ( // ServerEngineMode is used for starting a node's engine in server mode ServerEngineMode string = "server" // ClientEngineMode is used for starting a node's engine in client mode ClientEngineMode string = "client" )
const ( // GlobalServerMode is used for starting the application in server mode, running as Nuts node. GlobalServerMode string = "server" // GlobalCLIMode is used for starting the application in CLI mode, meaning it's used as CLI client administering // for a remote Nuts node. Engines will start in client mode when this mode is specified. GlobalCLIMode string = "cli" )
const NutsConsentClassesOID = NutsOID + ".1"
NutsConsentClassesOID is the sub-OID used for consent classification
const NutsMetricsPrefix = "nuts_"
const NutsOID = "1.3.6.1.4.1.54851"
NutsOID is the officially registered OID: http://oid-info.com/get/1.3.6.1.4.1.54851
const NutsVendorOID = NutsOID + ".4"
NutsVendorOID is the sub-OID used for vendor identifiers
Variables ¶
var ErrInvalidConfigTarget = errors.New("only struct pointers are supported to be a config target")
ErrInvalidConfigTarget is an error used for invalid config target pointers
var ErrUnMutableConfigTarget = errors.New("given Engine.Config can not be altered")
ErrUnMutableConfigTarget is an error used when a struct member is accessible
Functions ¶
func DecodeURIPath ¶
func DecodeURIPath(next echo.HandlerFunc) echo.HandlerFunc
DecodeURIPath is a echo middleware that decodes path parameters
func RegisterEngine ¶
func RegisterEngine(engine *Engine)
RegisterEngine is a helper func to add an engine to the list of engines from a different lib/pkg
Types ¶
type DiagnosticResult ¶
type DiagnosticResult interface { // Name returns a simple and understandable name of the check Name() string // String returns the outcome of the check String() string }
DiagnosticResult are the result of different checks giving information on how well the system is doing
type EchoRouter ¶ added in v0.14.0
type EchoRouter interface { CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route }
EchoRouter is the interface the generated server API's will require as the Routes func argument
type Engine ¶
type Engine struct { // Name holds the human readable name of the engine Name string // Cmd is the optional sub-command for the engine. An engine can only add one sub-command (but multiple sub-sub-commands for the sub-command) Cmd *cobra.Command // ConfigKey is the root yaml key in the config file or ENV sub-key for all keys used to configure an engine // status: // key: // and // NUTS_STATUS_KEY= // and // --status-key ConfigKey string // Config is the pointer to a config struct. The config will be unmarshalled using the ConfigKey. Config interface{} // Configure checks if the combination of config parameters is allowed Configure func() error // Diagnostics returns a slice of DiagnosticResult Diagnostics func() []DiagnosticResult // FlasSet contains all engine-local configuration possibilities so they can be displayed through the help command FlagSet *pflag.FlagSet // Routes passes the Echo router to the specific engine for it to register their routes. Routes func(router EchoRouter) // Shutdown the engine Shutdown func() error // Start the engine, this will spawn any clients, background tasks or active processes. Start func() error }
Engine contains all the configuration options and callbacks needed by the executable to configure, start, monitor and shutdown the engines
func NewLoggerEngine ¶
func NewLoggerEngine() *Engine
NewLoggerEngine creates a new Engine for logging
func NewMetricsEngine ¶ added in v0.15.0
func NewMetricsEngine() *Engine
NewMetricsEngine creates a new Engine for exposing prometheus metrics via http. Metrics are exposed on /metrics, by default the GoCollector and ProcessCollector are enabled.
func NewStatusEngine ¶
func NewStatusEngine() *Engine
NewStatusEngine creates a new Engine for viewing all engines
type EngineControl ¶
type EngineControl struct { // Engines is the slice of all registered engines Engines []*Engine }
EngineCtl is the control structure where engines are registered. All registered engines are referenced by the EngineCtl
var EngineCtl EngineControl
type Error ¶
type Error interface { error // Recoverable indicates if an action which resulted in the error can be retried Recoverable() bool }
Error is the interface that extends the default error interface
type GenericDiagnosticResult ¶
GenericDiagnosticResult is a simple implementation of the DiagnosticResult interface
func (*GenericDiagnosticResult) Name ¶
func (gdr *GenericDiagnosticResult) Name() string
Name returns the name of the GenericDiagnosticResult
func (*GenericDiagnosticResult) String ¶
func (gdr *GenericDiagnosticResult) String() string
String returns the outcome of the GenericDiagnosticResult
type NutsConfigValues ¶
type NutsConfigValues interface { ServerAddress() string InStrictMode() bool Mode() string // Identity returns the current vendor node's identity. // // Deprecated: use VendorID() Identity() string // VendorID returns the current node's identity VendorID() PartyID GetEngineMode(engineMode string) string }
NutsConfigValues exposes global configuration values
type NutsEventError ¶
type NutsEventError struct {
// contains filtered or unexported fields
}
NutsEventError is the main implementation adding a recoverable field to an error. This field will tell if the error is definitive or can be retried at a later moment.
func (*NutsEventError) Error ¶
func (ne *NutsEventError) Error() string
func (*NutsEventError) Is ¶
func (ne *NutsEventError) Is(target error) bool
Is is a wrapper for errors.Is()
func (*NutsEventError) Recoverable ¶
func (ne *NutsEventError) Recoverable() bool
Recoverable indicates if an action which resulted in the error can be retried
func (NutsEventError) UnWrap ¶
func (ne NutsEventError) UnWrap() error
UnWrap is needed for NutsEventError to be UnWrapped
type NutsGlobalConfig ¶
type NutsGlobalConfig struct { // The default config file the configuration looks for (Default nuts.yaml) DefaultConfigFile string // Prefix sets the global config environment variable prefix (Default: NUTS) Prefix string // Delimiter sets the nested config separator string (Default: '.') Delimiter string // IgnoredPrefixes is a slice of prefixes which will not be used to prepend config variables, eg: --logging.verbosity will just be --verbosity IgnoredPrefixes []string // contains filtered or unexported fields }
NutsGlobalConfig has the settings which influence all other settings.
func NewNutsGlobalConfig ¶
func NewNutsGlobalConfig() *NutsGlobalConfig
NewNutsGlobalConfig creates a NutsGlobalConfig with the following defaults * Prefix: NUTS * Delimiter: '.' * IgnoredPrefixes: ["root","logging"]
func NutsConfig ¶
func NutsConfig() *NutsGlobalConfig
NutsGlobalConfig returns a singleton global config
func (NutsGlobalConfig) GetEngineMode ¶
func (ngc NutsGlobalConfig) GetEngineMode(engineMode string) string
GetEngineMode configures an engine mode if not already configured. If the application is started in 'cli' mode, its engines are configured to run in 'client' mode. This function returns the proper mode for the engine in and should be used as follows: engineConfig.Mode = GetEngineMode(engineConfig.Mode)
func (NutsGlobalConfig) Identity
deprecated
func (ngc NutsGlobalConfig) Identity() string
Identity returns the current vendor's identity. This is a mandatory parameter which must be in the following form: urn:oid:1.3.6.1.4.1.54851.4:<number>
Deprecated: use VendorID() instead
func (NutsGlobalConfig) InStrictMode ¶
func (ngc NutsGlobalConfig) InStrictMode() bool
InStrictMode helps to safeguard settings which are handy and default in development but not safe for production.
func (*NutsGlobalConfig) InjectIntoEngine ¶
func (ngc *NutsGlobalConfig) InjectIntoEngine(e *Engine) error
InjectIntoEngine loop over all flags from an engine and injects any value into the given Config struct for the Engine. If the Engine does not have a config struct, it does nothing. Any config not registered as global flag will be ignored. It expects all config var names to be prepended or nested with the Engine ConfigKey, this will be ignored if the ConfigKey is "" or if the key is in the set of ignored prefixes.
func (*NutsGlobalConfig) Load ¶
func (ngc *NutsGlobalConfig) Load(cmd *cobra.Command) error
Load sets some initial config in order to be able for commands to load the right parameters and to add the configFile Flag. This is mainly spf13/viper related stuff
func (*NutsGlobalConfig) LoadAndUnmarshal ¶
func (ngc *NutsGlobalConfig) LoadAndUnmarshal(cmd *cobra.Command, targetCfg interface{}) error
Unmarshal loads config from Env, commandLine and configFile into given struct. This call is intended to be used outside of the engine structure of Nuts-go. It can be used by the individual repo's, for testing the repo as standalone command.
func (NutsGlobalConfig) Mode ¶
func (ngc NutsGlobalConfig) Mode() string
Mode returns the configured mode (client/server).
func (*NutsGlobalConfig) PrintConfig ¶
func (ngc *NutsGlobalConfig) PrintConfig(logger log.FieldLogger)
PrintConfig outputs the current config to the logger on info level
func (*NutsGlobalConfig) RegisterFlags ¶
func (ngc *NutsGlobalConfig) RegisterFlags(cmd *cobra.Command, e *Engine)
RegisterFlags adds the flagSet of an engine to the commandline, flag names are prefixed if needed The passed command must be the root command not the engine.Cmd (unless they are the same)
func (NutsGlobalConfig) ServerAddress ¶
func (ngc NutsGlobalConfig) ServerAddress() string
ServerAddress is the address which is used to either listen on (in server mode) or connect to (in client mode).
func (NutsGlobalConfig) VendorID ¶ added in v0.15.0
func (ngc NutsGlobalConfig) VendorID() PartyID
VendorID returns the current vendor's identity.
type PartyID ¶ added in v0.15.0
type PartyID struct {
// contains filtered or unexported fields
}
PartyID is a data type uniquely identifying a party in the Nuts Network. It's represented as a URN-encoded OID: https://www.ietf.org/rfc/rfc8141.txt For example: urn:oid:1.2.3.4:foo
func NewPartyID ¶ added in v0.15.0
NewPartyID creates a new PartyID
func ParsePartyID ¶ added in v0.15.0
ParsePartyID tries to parse the given input as URN-encoded OID (for example: urn:oid:1.2.3.4:foo)
func (PartyID) IsZero ¶ added in v0.15.0
IsZero tests whether this identifier is empty a.k.a. 'zero'.
func (PartyID) MarshalJSON ¶ added in v0.15.0
MarshalJSON marshals the PartyID to JSON.
func (PartyID) String ¶ added in v0.15.0
String returns the PartyID as fully-qualified URN-encoded OID.
func (*PartyID) UnmarshalJSON ¶ added in v0.15.0
MarshalJSON unmarshals the PartyID from JSON.