Documentation ¶
Index ¶
- Constants
- func LoadAvroSchema(rawSchema string, registry agentiface.SchemaRegistry) (agentiface.Schema, error)
- func LoadJSONSchema(rawSchema string) (agentiface.Schema, error)
- func NewTypeFromInterface(name string, i interface{}) (agentiface.Type, error)
- func NewTypeFromType(name string, t reflect.Type) agentiface.Type
- type AMQP
- func (a *AMQP) Connect() (err error)
- func (a *AMQP) Disconnect() error
- func (a *AMQP) RegisterCommandCallback(commandName agentiface.MessageName, commandCallback agentiface.CommandCallback) (string, error)
- func (a *AMQP) RegisterEventCallback(filter agentiface.EventFilter, eventCallback agentiface.EventCallback) (string, error)
- func (a *AMQP) RegisterStateCallback(stateCallback agentiface.StateCallback) string
- func (a *AMQP) SendCommand(to string, command interface{}) error
- func (a *AMQP) State() agentiface.State
- type Agent
- type AvroSchema
- type Cli
- type Config
- func (config *Config) BindConfigPFlag(key string, flag *pflag.Flag) error
- func (config *Config) CreateDefaultConfig() error
- func (config *Config) CreateDefaultConfigOverwrite() error
- func (config *Config) GetConfigString(key string) string
- func (config *Config) LoadConfig() error
- func (config *Config) LoadConfigFrom(path string) error
- func (config *Config) PrintConfig(w io.Writer) error
- func (config *Config) SetDefaultConfigOption(key string, value interface{})
- type Ctx
- type JSONSchema
- type Logger
- func (l *Logger) Alert(format string, a ...interface{})
- func (l *Logger) Close() error
- func (l *Logger) Critical(format string, a ...interface{})
- func (l *Logger) Debug(format string, a ...interface{})
- func (l *Logger) Emergency(format string, a ...interface{})
- func (l *Logger) Error(format string, a ...interface{})
- func (l *Logger) Info(format string, a ...interface{})
- func (l *Logger) Warning(format string, a ...interface{})
- type Manifest
- type SchemaRegistry
- func (s *SchemaRegistry) SchemaExist(key string) bool
- func (s *SchemaRegistry) SchemaGetByID(id string) (agentiface.Schema, error)
- func (s *SchemaRegistry) SchemaListIds() []string
- func (s *SchemaRegistry) SchemaRegister(schema agentiface.Schema) (string, error)
- func (s *SchemaRegistry) SchemaUnregister(id string) error
- type TypeRegistry
- func (s *TypeRegistry) TypeExist(key string) bool
- func (s *TypeRegistry) TypeGetByName(key string) (agentiface.Type, error)
- func (s *TypeRegistry) TypeGetByType(v reflect.Type) (agentiface.Type, error)
- func (s *TypeRegistry) TypeListNames() []string
- func (s *TypeRegistry) TypeRegister(t agentiface.Type) (string, error)
- func (s *TypeRegistry) TypeUnregister(key string) error
Constants ¶
const MimeTypeAvroSchema = "application/js+avro"
MimeTypeAvroSchema represents the mime type we use for AVRO schemas.
const MimeTypeJSONSchema = "application/schema+json"
MimeTypeJSONSchema represents the mime type we use for JSON schemas.
Variables ¶
This section is empty.
Functions ¶
func LoadAvroSchema ¶
func LoadAvroSchema(rawSchema string, registry agentiface.SchemaRegistry) (agentiface.Schema, error)
LoadAvroSchema loads the given raw Avro definition and returns a schema instance the registry is given as argument in order to resolve schemas that depends on other schema.
func LoadJSONSchema ¶
func LoadJSONSchema(rawSchema string) (agentiface.Schema, error)
LoadJSONSchema loads the given Json Schema and returns a schema instance
func NewTypeFromInterface ¶
func NewTypeFromInterface(name string, i interface{}) (agentiface.Type, error)
NewTypeFromInterface returns a new instance of Type from a name and an interface.
func NewTypeFromType ¶
func NewTypeFromType(name string, t reflect.Type) agentiface.Type
NewTypeFromType returns a Type from a name and a Type reflection.
Types ¶
type AMQP ¶
type AMQP struct {
// contains filtered or unexported fields
}
AMQP is a low level handler of the AMQP connectionns, events and callbacks.
func (*AMQP) Connect ¶
Connect actually connects to the AMQP broker and initializes all the exchanges and queues.
func (*AMQP) RegisterCommandCallback ¶
func (a *AMQP) RegisterCommandCallback(commandName agentiface.MessageName, commandCallback agentiface.CommandCallback) (string, error)
RegisterCommandCallback registers a callback triggered by a command reception.
func (*AMQP) RegisterEventCallback ¶
func (a *AMQP) RegisterEventCallback(filter agentiface.EventFilter, eventCallback agentiface.EventCallback) (string, error)
RegisterEventCallback registers a callback triggered by an event reception.
func (*AMQP) RegisterStateCallback ¶
func (a *AMQP) RegisterStateCallback(stateCallback agentiface.StateCallback) string
RegisterStateCallback registers a callback triggered by state changes.
func (*AMQP) SendCommand ¶
SendCommand sends a command to a specific agent.
func (*AMQP) State ¶
func (a *AMQP) State() agentiface.State
State returns the state of the connection.
type Agent ¶
type Agent struct { wait.Group *Cli *Config *SchemaRegistry *TypeRegistry *AMQP *Logger // contains filtered or unexported fields }
Agent is the implementation of the base behaviour that all Crucibuild agents should implement: - config file parsing - logging - command line args parsing - command registration - etc...
func NewAgent ¶
func NewAgent(manifest agentiface.Manifest) (agent *Agent, err error)
NewAgent creates a new Agent instance from a spec.
func (*Agent) Manifest ¶
func (a *Agent) Manifest() agentiface.Manifest
Manifest returns the manifest of the agent.
type AvroSchema ¶
type AvroSchema struct {
// contains filtered or unexported fields
}
AvroSchema represents an AVRO schema with all its metadata.
func (*AvroSchema) Code ¶
func (s *AvroSchema) Code(o interface{}) ([]byte, error)
Code serializes data using the AvroSchema registered.
func (*AvroSchema) Decode ¶
func (s *AvroSchema) Decode(o []byte, t agentiface.Type) (interface{}, error)
Decode unserializes data using the AvroSchema registered.
func (*AvroSchema) MimeType ¶
func (*AvroSchema) MimeType() string
MimeType returns the AvroSchema mime type.
type Cli ¶
type Cli struct {
// contains filtered or unexported fields
}
Cli implements command line argument parsing.
func NewCli ¶
func NewCli(a agentiface.Agent) *Cli
NewCli creates an new Command Line Interface for the agent.
func (*Cli) ParseCommandLine ¶
ParseCommandLine parse the arguments
func (*Cli) RegisterCommand ¶
RegisterCommand register additional commands available via the command line.
func (*Cli) RootCommand ¶
RootCommand return the rootCommand of the agent.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config represents an agent configuration data.
func NewConfig ¶
func NewConfig(a agentiface.Agent) *Config
NewConfig creates a new instance of Config for an agent.
func (*Config) BindConfigPFlag ¶
BindConfigPFlag binds a command line flag with a configuration key.
func (*Config) CreateDefaultConfig ¶
CreateDefaultConfig initialize a new configuration file with default values. returns an error if configuration file already exists.
func (*Config) CreateDefaultConfigOverwrite ¶
CreateDefaultConfigOverwrite initialize a new configuration file with default values. Overwrite the file if it exists.
func (*Config) GetConfigString ¶
GetConfigString returns the value matching the key in parameter from the configuration file.
func (*Config) LoadConfig ¶
LoadConfig reads the configuration from the config file.
func (*Config) LoadConfigFrom ¶
LoadConfigFrom reads the configuration from the config file located at path.
func (*Config) PrintConfig ¶
PrintConfig prints the configuration values with w.
func (*Config) SetDefaultConfigOption ¶
SetDefaultConfigOption sets default value for an option of the config.
type Ctx ¶
type Ctx struct {
// contains filtered or unexported fields
}
Ctx denotes a context when receiving a command or an event. From this instance can be retrieved: - the message (command or event) - the schema - the properties attached to the message
func (*Ctx) Message ¶
func (ctx *Ctx) Message() interface{}
Message returns the concrete instance of the deserialized message.
func (*Ctx) Messaging ¶
func (ctx *Ctx) Messaging() agentiface.Messaging
Messaging returns the instance of Messaging.
func (*Ctx) Properties ¶
Properties returns the properties attached to the message.
func (*Ctx) Schema ¶
func (ctx *Ctx) Schema() agentiface.Schema
Schema The (Avro) schema of the message serialized.
func (*Ctx) SendCommand ¶
SendCommand sends a command as a consequence of this event (correlationId is set)
type JSONSchema ¶
type JSONSchema struct {
// contains filtered or unexported fields
}
JSONSchema represents a JSON Schema with all its metadata.
func (*JSONSchema) Code ¶
func (s *JSONSchema) Code(o interface{}) ([]byte, error)
Code serializes data using the JSONSchema registered.
func (*JSONSchema) Decode ¶
func (s *JSONSchema) Decode(o []byte, t agentiface.Type) (interface{}, error)
Decode unserializes data using the JSONSchema registered.
func (*JSONSchema) MimeType ¶
func (*JSONSchema) MimeType() string
MimeType returns the JSONSchema mime type.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is an abstraction wrapping basic operations in order to log messages.
func NewLogger ¶
func NewLogger(a agentiface.Agent) (*Logger, error)
NewLogger creates a new instance of Logger associated with an agent.
type Manifest ¶
type Manifest struct {
// contains filtered or unexported fields
}
Manifest represents the core properties defining an Agent.
func NewManifest ¶
NewManifest creates a new instance of Manifest from a map.
func (*Manifest) Description ¶
Description returns the agent description.
type SchemaRegistry ¶
type SchemaRegistry struct {
// contains filtered or unexported fields
}
SchemaRegistry represents a registry for schemas.
func NewSchemaRegistry ¶
func NewSchemaRegistry(a agentiface.Agent) *SchemaRegistry
NewSchemaRegistry creates a new instance of SchemaRegistry. nolint: unparam, parameter a is reserved for a future usage
func (*SchemaRegistry) SchemaExist ¶
func (s *SchemaRegistry) SchemaExist(key string) bool
SchemaExist returns true if the key match a schema known by the registry.
func (*SchemaRegistry) SchemaGetByID ¶
func (s *SchemaRegistry) SchemaGetByID(id string) (agentiface.Schema, error)
SchemaGetByID returns a schema which id matches the one in parameter.
func (*SchemaRegistry) SchemaListIds ¶
func (s *SchemaRegistry) SchemaListIds() []string
SchemaListIds returns a map of <id, schema> known by the registry.
func (*SchemaRegistry) SchemaRegister ¶
func (s *SchemaRegistry) SchemaRegister(schema agentiface.Schema) (string, error)
SchemaRegister registers a schema in the registry.
func (*SchemaRegistry) SchemaUnregister ¶
func (s *SchemaRegistry) SchemaUnregister(id string) error
SchemaUnregister remove a schema from the registry.
type TypeRegistry ¶
type TypeRegistry struct {
// contains filtered or unexported fields
}
TypeRegistry is a registry referencing types.
func NewTypeRegistry ¶
func NewTypeRegistry(a agentiface.Agent) *TypeRegistry
NewTypeRegistry returns a new instance of TypeRegistry from an agent. nolint: unparam, parameter a is reserved for a future usage
func (*TypeRegistry) TypeExist ¶
func (s *TypeRegistry) TypeExist(key string) bool
TypeExist returns true if a type matching key is known to the registry.
func (*TypeRegistry) TypeGetByName ¶
func (s *TypeRegistry) TypeGetByName(key string) (agentiface.Type, error)
TypeGetByName returns a Type which name's match key.
func (*TypeRegistry) TypeGetByType ¶
func (s *TypeRegistry) TypeGetByType(v reflect.Type) (agentiface.Type, error)
TypeGetByType returns a Type from a reflect.Type.
func (*TypeRegistry) TypeListNames ¶
func (s *TypeRegistry) TypeListNames() []string
TypeListNames returns a map(<id, name>) of all the registered types.
func (*TypeRegistry) TypeRegister ¶
func (s *TypeRegistry) TypeRegister(t agentiface.Type) (string, error)
TypeRegister registers a Type into the registry.
func (*TypeRegistry) TypeUnregister ¶
func (s *TypeRegistry) TypeUnregister(key string) error
TypeUnregister unregister the Type key from the registry.