Documentation
¶
Overview ¶
Notes:
Index ¶
- Variables
- func EncodeSeed(public PrefixByte, src []byte) ([]byte, error)
- func NewServer(configuration *Configuration, version string) (*server, error)
- type Configuration
- type ConfigurationFromFile
- type Event
- type HostACLsSerializedWithHash
- type Message
- type Method
- type MethodsAvailable
- type Node
- type PrefixByte
- type Subject
Constants ¶
This section is empty.
Variables ¶
var (
ErrACKSubscribeRetry = errors.New("steward: retrying to subscribe for ack message")
)
Functions ¶
func EncodeSeed ¶ added in v0.3.23
func EncodeSeed(public PrefixByte, src []byte) ([]byte, error)
EncodeSeed will encode a raw key with the prefix and then seed prefix and crc16 and then base32 encoded. This is a slightly modified version of the function found in the nkeys package, just with less options.
func NewServer ¶
func NewServer(configuration *Configuration, version string) (*server, error)
newServer will prepare and return a server type
Types ¶
type Configuration ¶
type Configuration struct {
// RingBufferPersistStore, enable or disable the persisting of
// messages being processed to local db.
RingBufferPersistStore bool `comment:"RingBufferPersistStore, enable or disable the persisting of messages being processed to local db"`
// RingBufferSize
RingBufferSize int `comment:"RingBufferSize"`
// ConfigFolder, the location for the configuration folder on disk
ConfigFolder string `comment:"ConfigFolder, the location for the configuration folder on disk"`
// The folder where the socket file should live
SocketFolder string `comment:"The folder where the socket file should live"`
// The folder where the readfolder should live
ReadFolder string `comment:"The folder where the readfolder should live"`
// EnableReadFolder for enabling the read messages api from readfolder
EnableReadFolder bool `comment:"EnableReadFolder for enabling the read messages api from readfolder"`
// TCP Listener for sending messages to the system, <host>:<port>
TCPListener string `comment:"TCP Listener for sending messages to the system, <host>:<port>"`
// HTTP Listener for sending messages to the system, <host>:<port>
HTTPListener string `comment:"HTTP Listener for sending messages to the system, <host>:<port>"`
// The folder where the database should live
DatabaseFolder string `comment:"The folder where the database should live"`
// Unique string to identify this Edge unit
NodeName string `comment:"Unique string to identify this Edge unit"`
// The address of the message broker, <address>:<port>
BrokerAddress string `comment:"The address of the message broker, <address>:<port>"`
// NatsConnOptTimeout the timeout for trying the connect to nats broker
NatsConnOptTimeout int `comment:"NatsConnOptTimeout the timeout for trying the connect to nats broker"`
// Nats connect retry interval in seconds
NatsConnectRetryInterval int `comment:"Nats connect retry interval in seconds"`
// NatsReconnectJitter in milliseconds
NatsReconnectJitter int `comment:"NatsReconnectJitter in milliseconds"`
// NatsReconnectJitterTLS in seconds
NatsReconnectJitterTLS int `comment:"NatsReconnectJitterTLS in seconds"`
// REQKeysRequestUpdateInterval in seconds
REQKeysRequestUpdateInterval int `comment:"REQKeysRequestUpdateInterval in seconds"`
// REQAclRequestUpdateInterval in seconds
REQAclRequestUpdateInterval int `comment:"REQAclRequestUpdateInterval in seconds"`
// The number of the profiling port
ProfilingPort string `comment:"The number of the profiling port"`
// Host and port for prometheus listener, e.g. localhost:2112
PromHostAndPort string `comment:"Host and port for prometheus listener, e.g. localhost:2112"`
// Set to true if this is the node that should receive the error log's from other nodes
DefaultMessageTimeout int `comment:"Set to true if this is the node that should receive the error log's from other nodes"`
// Default value for how long can a request method max be allowed to run in seconds
DefaultMethodTimeout int `comment:"Default value for how long can a request method max be allowed to run in seconds"`
// Default amount of retries that will be done before a message is thrown away, and out of the system
DefaultMessageRetries int `comment:"Default amount of retries that will be done before a message is thrown away, and out of the system"`
// The path to the data folder
SubscribersDataFolder string `comment:"The path to the data folder"`
// Name of central node to receive logs, errors, key/acl handling
CentralNodeName string `comment:"Name of central node to receive logs, errors, key/acl handling"`
// The full path to the certificate of the root CA
RootCAPath string `comment:"The full path to the certificate of the root CA"`
// Full path to the NKEY's seed file
NkeySeedFile string `comment:"Full path to the NKEY's seed file"`
// The full path to the NKEY user file
NkeyPublicKey string `toml:"-"`
//
NkeyFromED25519SSHKeyFile string `` /* 185-byte string literal not displayed */
// The host and port to expose the data folder, <host>:<port>
ExposeDataFolder string `comment:"The host and port to expose the data folder, <host>:<port>"`
// Timeout in seconds for error messages
ErrorMessageTimeout int `comment:"Timeout in seconds for error messages"`
// Retries for error messages
ErrorMessageRetries int `comment:"Retries for error messages"`
// Compression z for zstd or g for gzip
Compression string `comment:"Compression z for zstd or g for gzip"`
// Serialization, supports cbor or gob,default is gob. Enable cbor by setting the string value cbor
Serialization string `comment:"Serialization, supports cbor or gob,default is gob. Enable cbor by setting the string value cbor"`
// SetBlockProfileRate for block profiling
SetBlockProfileRate int `comment:"SetBlockProfileRate for block profiling"`
// EnableSocket for enabling the creation of a steward.sock file
EnableSocket bool `comment:"EnableSocket for enabling the creation of a steward.sock file"`
// EnableTUI will enable the Terminal User Interface
EnableTUI bool `comment:"EnableTUI will enable the Terminal User Interface"`
// EnableSignatureCheck to enable signature checking
EnableSignatureCheck bool `comment:"EnableSignatureCheck to enable signature checking"`
// EnableAclCheck to enable ACL checking
EnableAclCheck bool `comment:"EnableAclCheck to enable ACL checking"`
// IsCentralAuth, enable to make this instance take the role as the central auth server
IsCentralAuth bool `comment:"IsCentralAuth, enable to make this instance take the role as the central auth server"`
// EnableDebug will also enable printing all the messages received in the errorKernel to STDERR.
EnableDebug bool `comment:"EnableDebug will also enable printing all the messages received in the errorKernel to STDERR."`
// LogLevel
LogLevel string `comment:"LogLevel error/info/warning/debug/none."`
LogConsoleTimestamps bool `comment:"LogConsoleTimestamps true/false for enabling or disabling timestamps when printing errors and information to stderr"`
// KeepPublishersAliveFor number of seconds
// Timer that will be used for when to remove the sub process
// publisher. The timer is reset each time a message is published with
// the process, so the sub process publisher will not be removed until
// it have not received any messages for the given amount of time.
KeepPublishersAliveFor int `` /* 309-byte string literal not displayed */
// StartPubREQHello, sets the interval in seconds for how often we send hello messages to central server
StartPubREQHello int `comment:"StartPubREQHello, sets the interval in seconds for how often we send hello messages to central server"`
// Enable the updates of public keys
EnableKeyUpdates bool `comment:"Enable the updates of public keys"`
// Enable the updates of acl's
EnableAclUpdates bool `comment:"Enable the updates of acl's"`
// Start the central error logger.
IsCentralErrorLogger bool `comment:"Start the central error logger."`
// Start subscriber for hello messages
StartSubREQHello bool `comment:"Start subscriber for hello messages"`
// Start subscriber for text logging
StartSubREQToFileAppend bool `comment:"Start subscriber for text logging"`
// Start subscriber for writing to file
StartSubREQToFile bool `comment:"Start subscriber for writing to file"`
// Start subscriber for writing to file without ACK
StartSubREQToFileNACK bool `comment:"Start subscriber for writing to file without ACK"`
// Start subscriber for reading files to copy
StartSubREQCopySrc bool `comment:"Start subscriber for reading files to copy"`
// Start subscriber for writing copied files to disk
StartSubREQCopyDst bool `comment:"Start subscriber for writing copied files to disk"`
// Start subscriber for Echo Request
StartSubREQPing bool `comment:"Start subscriber for Echo Request"`
// Start subscriber for Echo Reply
StartSubREQPong bool `comment:"Start subscriber for Echo Reply"`
// Start subscriber for CLICommandRequest
StartSubREQCliCommand bool `comment:"Start subscriber for CLICommandRequest"`
// Start subscriber for REQToConsole
StartSubREQToConsole bool `comment:"Start subscriber for REQToConsole"`
// Start subscriber for REQHttpGet
StartSubREQHttpGet bool `comment:"Start subscriber for REQHttpGet"`
// Start subscriber for REQHttpGetScheduled
StartSubREQHttpGetScheduled bool `comment:"Start subscriber for REQHttpGetScheduled"`
// Start subscriber for tailing log files
StartSubREQTailFile bool `comment:"Start subscriber for tailing log files"`
// Start subscriber for continously delivery of output from cli commands.
StartSubREQCliCommandCont bool `comment:"Start subscriber for continously delivery of output from cli commands."`
}
Configuration are the structure that holds all the different configuration options used both with flags and the config file. If a new field is added to this struct there should also be added the same field to the ConfigurationFromFile struct, and an if check should be added to the checkConfigValues function to set default values when reading from config file.
func NewConfiguration ¶
func NewConfiguration() *Configuration
NewConfiguration will return a *Configuration.
func (*Configuration) CheckFlags ¶
func (c *Configuration) CheckFlags(version string) error
CheckFlags will parse all flags
func (*Configuration) CreateKeyPair ¶ added in v0.3.23
func (c *Configuration) CreateKeyPair(prefix PrefixByte) (kp, error)
CreateKeyPair will create the key nkeys key pair. This is a slightly modified version of the function found in the nkeys package, just with less options.
func (*Configuration) ReadConfigFile ¶
func (c *Configuration) ReadConfigFile(configFolder string) (Configuration, error)
Reads the current config file from disk.
func (*Configuration) WriteConfigFile ¶
func (c *Configuration) WriteConfigFile() error
WriteConfigFile will write the current config to file. If the file or the directory for the config file does not exist it will be created.
type ConfigurationFromFile ¶ added in v0.1.10
type ConfigurationFromFile struct {
ConfigFolder *string
RingBufferPersistStore *bool
RingBufferSize *int
SocketFolder *string
ReadFolder *string
EnableReadFolder *bool
TCPListener *string
HTTPListener *string
DatabaseFolder *string
NodeName *string
BrokerAddress *string
NatsConnOptTimeout *int
NatsConnectRetryInterval *int
NatsReconnectJitter *int
NatsReconnectJitterTLS *int
REQKeysRequestUpdateInterval *int
REQAclRequestUpdateInterval *int
ProfilingPort *string
PromHostAndPort *string
DefaultMessageTimeout *int
DefaultMessageRetries *int
DefaultMethodTimeout *int
SubscribersDataFolder *string
CentralNodeName *string
RootCAPath *string
NkeySeedFile *string
NkeyFromED25519SSHKeyFile *string
ExposeDataFolder *string
ErrorMessageTimeout *int
ErrorMessageRetries *int
Compression *string
Serialization *string
SetBlockProfileRate *int
EnableSocket *bool
EnableTUI *bool
EnableSignatureCheck *bool
EnableAclCheck *bool
IsCentralAuth *bool
EnableDebug *bool
LogLevel *string
LogConsoleTimestamps *bool
KeepPublishersAliveFor *int
StartPubREQHello *int
EnableKeyUpdates *bool
EnableAclUpdates *bool
IsCentralErrorLogger *bool
StartSubREQHello *bool
StartSubREQToFileAppend *bool
StartSubREQToFile *bool
StartSubREQToFileNACK *bool
StartSubREQCopySrc *bool
StartSubREQCopyDst *bool
StartSubREQPing *bool
StartSubREQPong *bool
StartSubREQCliCommand *bool
StartSubREQToConsole *bool
StartSubREQHttpGet *bool
StartSubREQHttpGetScheduled *bool
StartSubREQTailFile *bool
StartSubREQCliCommandCont *bool
}
ConfigurationFromFile should have the same structure as Configuration. This structure is used when parsing the configuration values from file, so we are able to detect if a value were given or not when parsing.
type Event ¶ added in v0.2.0
type Event string
Event describes on the message level if this is an ACK or NACK kind of message in the Subject name. This field is mainly used to be able to spawn up different worker processes based on the Subject name. This type is used in both building the subject name, and also inside the Message type to describe what kind like ACK or NACK it is.
const ( // EventACK, wait for the return of an ACK message. // The sender will wait for an ACK reply message // to decide if it was succesfully delivered or not. // If no ACK was received within the timeout, the // message will be resent the nr. of times specified // in retries field of the message. EventACK Event = "EventACK" // Same as above, but No ACK. EventNACK Event = "EventNACK" )
type HostACLsSerializedWithHash ¶ added in v0.3.0
type HostACLsSerializedWithHash struct {
// data is all the ACL's for a specific node serialized serialized into cbor.
Data []byte
// hash is the sha256 hash of the ACL's.
// With maps the order are not guaranteed, so A sorted appearance
// of the ACL map for a host node is used when creating the hash,
// so the hash stays the same unless the ACL is changed.
Hash [32]byte
}
HostACLsSerializedWithHash holds the serialized representation node specific ACL's in the authSchema. There is also a sha256 hash of the data.
type Message ¶
type Message struct {
// The node to send the message to.
ToNode Node `json:"toNode" yaml:"toNode"`
// ToNodes to specify several hosts to send message to in the
// form of an slice/array.
// The ToNodes field is only a concept that exists when messages
// are injected f.ex. on a socket, and there they are directly
//converted into separate node messages for each node, and from
// there the ToNodes field is not used any more within the system.
// With other words, a message that exists within Steward is always
// for just for a single node.
ToNodes []Node `json:"toNodes,omitempty" yaml:"toNodes,omitempty"`
// The Unique ID of the message
ID int `json:"id" yaml:"id"`
// The actual data in the message. This is typically where we
// specify the cli commands to execute on a node, and this is
// also the field where we put the returned data in a reply
// message.
Data []byte `json:"data" yaml:"data"`
// Method, what request type to use, like REQCliCommand, REQHttpGet..
Method Method `json:"method" yaml:"method"`
// Additional arguments that might be needed when executing the
// method. Can be f.ex. an ip address if it is a tcp sender, or the
// shell command to execute in a cli session.
MethodArgs []string `json:"methodArgs" yaml:"methodArgs"`
// ArgSignature is the ed25519 signature of the methodArgs.
ArgSignature []byte `json:"argSignature" yaml:"argSignature"`
// ReplyMethod, is the method to use for the reply message.
// By default the reply method will be set to log to file, but
// you can override it setting your own here.
ReplyMethod Method `json:"replyMethod" yaml:"replyMethod"`
// Additional arguments that might be needed when executing the reply
// method. Can be f.ex. an ip address if it is a tcp sender, or the
// shell command to execute in a cli session.
ReplyMethodArgs []string `json:"replyMethodArgs" yaml:"replyMethodArgs"`
// IsReply are used to tell that this is a reply message. By default
// the system sends the output of a request method back to the node
// the message originated from. If it is a reply method we want the
// result of the reply message to be sent to the central server, so
// we can use this value if set to swap the toNode, and fromNode
// fields.
IsReply bool `json:"isReply" yaml:"isReply"`
// From what node the message originated
FromNode Node `json:"fromNode" yaml:"fromNode"`
// ACKTimeout for waiting for an ack message
ACKTimeout int `json:"ACKTimeout" yaml:"ACKTimeout"`
// RetryWait specified the time in seconds to wait between retries.
RetryWait int `json:"retryWait" yaml:"retryWait"`
// IsSubPublishedMsg enables timeout of publishing process, and is used together with process.isSubProcess to be able to terminate the sub processes publishers.
IsSubPublishedMsg bool `json:"isSubPublishedMsg" yaml:"isSubPublishedMsg"`
// Resend retries
Retries int `json:"retries" yaml:"retries"`
// The ACK timeout of the new message created via a request event.
ReplyACKTimeout int `json:"replyACKTimeout" yaml:"replyACKTimeout"`
// The retries of the new message created via a request event.
ReplyRetries int `json:"replyRetries" yaml:"replyRetries"`
// Timeout for long a process should be allowed to operate
MethodTimeout int `json:"methodTimeout" yaml:"methodTimeout"`
// Timeout for long a process should be allowed to operate
ReplyMethodTimeout int `json:"replyMethodTimeout" yaml:"replyMethodTimeout"`
// Directory is a string that can be used to create the
//directory structure when saving the result of some method.
// For example "syslog","metrics", or "metrics/mysensor"
// The type is typically used in the handler of a method.
Directory string `json:"directory" yaml:"directory"`
// FileName is used to be able to set a wanted name
// on a file being saved as the result of data being handled
// by a method handler.
FileName string `json:"fileName" yaml:"fileName"`
// PreviousMessage are used for example if a reply message is
// generated and we also need a copy of the details of the the
// initial request message.
PreviousMessage *Message
// Schedule
Schedule []int `json:"schedule" yaml:"schedule"`
// contains filtered or unexported fields
}
type Method ¶
type Method string
Method is used to specify the actual function/method that is represented in a typed manner.
const ( // Initial parent method used to start other processes. REQInitial Method = "REQInitial" // Get a list of all the running processes. REQOpProcessList Method = "REQOpProcessList" // Start up a process. REQOpProcessStart Method = "REQOpProcessStart" // Stop up a process. REQOpProcessStop Method = "REQOpProcessStop" // Execute a CLI command in for example bash or cmd. // This is an event type, where a message will be sent to a // node with the command to execute and an ACK will be replied // if it was delivered succesfully. The output of the command // ran will be delivered back to the node where it was initiated // as a new message. // The data field is a slice of strings where the first string // value should be the command, and the following the arguments. REQCliCommand Method = "REQCliCommand" // REQCliCommandCont same as normal Cli command, but can be used // when running a command that will take longer time and you want // to send the output of the command continually back as it is // generated, and not wait until the command is finished. REQCliCommandCont Method = "REQCliCommandCont" // Send text to be logged to the console. // The data field is a slice of strings where the first string // value should be the command, and the following the arguments. REQToConsole Method = "REQToConsole" // REQTuiToConsole REQTuiToConsole Method = "REQTuiToConsole" // Send text logging to some host by appending the output to a // file, if the file do not exist we create it. // A file with the full subject+hostName will be created on // the receiving end. // The data field is a slice of strings where the values of the // slice will be written to the log file. REQToFileAppend Method = "REQToFileAppend" // Send text to some host by overwriting the existing content of // the fileoutput to a file. If the file do not exist we create it. // A file with the full subject+hostName will be created on // the receiving end. // The data field is a slice of strings where the values of the // slice will be written to the file. REQToFile Method = "REQToFile" // REQToFileNACK same as REQToFile but NACK. REQToFileNACK Method = "REQToFileNACK" // Initiated by the user. REQCopySrc Method = "REQCopySrc" // Initial request for file copying. // Generated by the source to send initial information to the destination. REQCopyDst Method = "REQCopyDst" // Read the source file to be copied to some node. REQSUBCopySrc Method = "REQSUBCopySrc" // Write the destination copied to some node. REQSUBCopyDst Method = "REQSUBCopyDst" // Send Hello I'm here message. REQHello Method = "REQHello" // Error log methods to centralError node. REQErrorLog Method = "REQErrorLog" // Echo request will ask the subscriber for a // reply generated as a new message, and sent back to where // the initial request was made. REQPing Method = "REQPing" // Will generate a reply for a ECHORequest REQPong Method = "REQPong" // Http Get REQHttpGet Method = "REQHttpGet" // Http Get Scheduled // The second element of the MethodArgs slice holds the timer defined in seconds. REQHttpGetScheduled Method = "REQHttpGetScheduled" // Tail file REQTailFile Method = "REQTailFile" // REQNone is used when there should be no reply. REQNone Method = "REQNone" // REQTest is used only for testing to be able to grab the output // of messages. REQTest Method = "REQTest" // REQPublicKey will get the public ed25519 key from a node. REQPublicKey Method = "REQPublicKey" // REQKeysRequestUpdate will get all the public keys from central if an update is available. REQKeysRequestUpdate Method = "REQKeysRequestUpdate" // REQKeysDeliverUpdate will deliver the public from central to a node. REQKeysDeliverUpdate Method = "REQKeysDeliverUpdate" // REQKeysAllow REQKeysAllow Method = "REQKeysAllow" // REQKeysDelete REQKeysDelete Method = "REQKeysDelete" // REQAclRequestUpdate will get all node acl's from central if an update is available. REQAclRequestUpdate Method = "REQAclRequestUpdate" // REQAclDeliverUpdate will deliver the acl from central to a node. REQAclDeliverUpdate Method = "REQAclDeliverUpdate" // REQAclAddCommand REQAclAddCommand = "REQAclAddCommand" // REQAclDeleteCommand REQAclDeleteCommand = "REQAclDeleteCommand" // REQAclDeleteSource REQAclDeleteSource = "REQAclDeleteSource" // REQGroupNodesAddNode REQAclGroupNodesAddNode = "REQAclGroupNodesAddNode" // REQAclGroupNodesDeleteNode REQAclGroupNodesDeleteNode = "REQAclGroupNodesDeleteNode" // REQAclGroupNodesDeleteGroup REQAclGroupNodesDeleteGroup = "REQAclGroupNodesDeleteGroup" // REQAclGroupCommandsAddCommand REQAclGroupCommandsAddCommand = "REQAclGroupCommandsAddCommand" // REQAclGroupCommandsDeleteCommand REQAclGroupCommandsDeleteCommand = "REQAclGroupCommandsDeleteCommand" // REQAclGroupCommandsDeleteGroup REQAclGroupCommandsDeleteGroup = "REQAclGroupCommandsDeleteGroup" // REQAclExport REQAclExport = "REQAclExport" // REQAclImport REQAclImport = "REQAclImport" )
------------------------------------------------------------ The constants that will be used throughout the system for when specifying what kind of Method to send or work with.
func (Method) GetMethodsAvailable ¶
func (m Method) GetMethodsAvailable() MethodsAvailable
The mapping of all the method constants specified, what type it references, and the kind if it is an Event or Command, and if it is ACK or NACK.
Allowed values for the Event field are: - EventACK - EventNack
The primary use of this table is that messages are not able to pass the actual type of the request since it is sent as a string, so we use the below table to find the actual type based on that string type.
func (Method) GetReplyMethods ¶ added in v0.1.5
Reply methods. The slice generated here is primarily used within the Stew client for knowing what of the req types are generally used as reply methods.
type MethodsAvailable ¶
type MethodsAvailable struct {
Methodhandlers map[Method]methodHandler
}
MethodsAvailable holds a map of all the different method types and the associated handler to that method type.
func (MethodsAvailable) CheckIfExists ¶
func (ma MethodsAvailable) CheckIfExists(m Method) (methodHandler, bool)
Check if exists will check if the Method is defined. If true the bool value will be set to true, and the methodHandler function for that type will be returned.
type Node ¶ added in v0.1.5
type Node string
Node is the type definition for the node who receive or send a message.
type PrefixByte ¶ added in v0.3.23
type PrefixByte byte
const PrefixByteSeed PrefixByte = 18 << 3 // Base32-encodes to 'S...'
PrefixByteSeed is the version byte used for encoded NATS Seeds
const PrefixByteUser PrefixByte = 20 << 3 // Base32-encodes to 'U...'
PrefixByteUser is the version byte used for encoded NATS Users
type Subject ¶
type Subject struct {
// node, the name of the node to receive the message.
ToNode string `json:"node" yaml:"toNode"`
// Event, event type like EventACK or EventNACK.
Event Event `json:"event" yaml:"event"`
// method, what is this message doing, etc. CLICommand, Syslog, etc.
Method Method `json:"method" yaml:"method"`
// contains filtered or unexported fields
}
subject contains the representation of a subject to be used with one specific process
Source Files
¶
- central_auth_acl_handling.go
- central_auth_key_handling.go
- central_auth_parser.go
- configuration_flags.go
- errorkernel.go
- event_type.go
- message_and_subject.go
- message_readers.go
- metrics.go
- nkey_from_ssh_ed25519_key.go
- node_auth.go
- process.go
- processes.go
- requests.go
- requests_acl.go
- requests_cli.go
- requests_copy.go
- requests_file_handling.go
- requests_http.go
- requests_keys.go
- requests_operator.go
- requests_std.go
- requests_template.go
- ringbuffer.go
- server.go
- tui.go
- tui_msg.go
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
steward
command
|
|
|
doc
|
|
|
concept/auth
command
|
|
|
scripts
|
|
|
nats-server/generate-nkeys
command
|
|