Documentation ¶
Overview ¶
Package inputs with managing of discovered inputs
Package inputs for using a file as input ¶
Package inputs with inputs from polling http services ¶
Package inputs with using subscribed domain outputs as input ¶
Package inputs with receiving of the SetInputMessage ¶
Package inputs with managing and publishing of registered inputs
Index ¶
- func MakeInputDiscoveryAddress(domain string, publisherID string, nodeID string, inputType types.InputType, ...) string
- func MakeInputHWID(nodeHWID string, inputType types.InputType, instance string) string
- func MakeSetInputAddress(domain string, publisherID string, nodeID string, inputType types.InputType, ...) string
- func NewInput(domain string, publisherID string, nodeHWID string, inputType types.InputType, ...) *types.InputDiscoveryMessage
- func PublishRegisteredInputs(inputs []*types.InputDiscoveryMessage, messageSigner *messaging.MessageSigner)
- func PublishSetInput(destination string, value string, sender string, ...) error
- type DomainInputs
- func (domainInputs *DomainInputs) AddInput(input *types.InputDiscoveryMessage)
- func (domainInputs *DomainInputs) GetAllInputs() []*types.InputDiscoveryMessage
- func (domainInputs *DomainInputs) GetInputByAddress(inputAddr string) *types.InputDiscoveryMessage
- func (domainInputs *DomainInputs) GetNodeInputs(nodeAddress string) []*types.InputDiscoveryMessage
- func (domainInputs *DomainInputs) RemoveInput(inputAddress string)
- func (domainInputs *DomainInputs) Subscribe(domain string, publisherID string)
- func (domainInputs *DomainInputs) Unsubscribe(domain string, publisherID string)
- type ReceiveFromFiles
- func (iffile *ReceiveFromFiles) CreateInput(nodeHWID string, inputType types.InputType, instance string, path string, ...) *types.InputDiscoveryMessage
- func (iffile *ReceiveFromFiles) DeleteInput(nodeHWID string, inputType types.InputType, instance string)
- func (iffile *ReceiveFromFiles) Start()
- func (iffile *ReceiveFromFiles) Stop()
- type ReceiveFromHTTP
- func (rxFromHttp *ReceiveFromHTTP) CreateHTTPInput(nodeHWID string, inputType types.InputType, instance string, url string, ...) *types.InputDiscoveryMessage
- func (rxFromHttp *ReceiveFromHTTP) DeleteInput(inputID string)
- func (rxFromHttp *ReceiveFromHTTP) Start()
- func (rxFromHttp *ReceiveFromHTTP) Stop()
- type ReceiveFromOutputs
- type ReceiveFromSetCommands
- type RegisteredInputs
- func (regInputs *RegisteredInputs) CreateInput(nodeHWID string, inputType types.InputType, instance string, ...) *types.InputDiscoveryMessage
- func (regInputs *RegisteredInputs) CreateInputWithSource(nodeHWID string, inputType types.InputType, instance string, source string, ...) *types.InputDiscoveryMessage
- func (regInputs *RegisteredInputs) DeleteInput(inputHWID string)
- func (regInputs *RegisteredInputs) GetAllInputs() []*types.InputDiscoveryMessage
- func (regInputs *RegisteredInputs) GetInputByAddress(inputAddr string) *types.InputDiscoveryMessage
- func (regInputs *RegisteredInputs) GetInputByID(inputID string) *types.InputDiscoveryMessage
- func (regInputs *RegisteredInputs) GetInputByNodeHWID(nodeHWID string, inputType types.InputType, instance string) *types.InputDiscoveryMessage
- func (regInputs *RegisteredInputs) GetInputsByNodeHWID(nodeHWID string) []*types.InputDiscoveryMessage
- func (regInputs *RegisteredInputs) GetInputsWithSource(source string) []*types.InputDiscoveryMessage
- func (regInputs *RegisteredInputs) GetUpdatedInputs(clearUpdates bool) []*types.InputDiscoveryMessage
- func (regInputs *RegisteredInputs) NotifyInputHandler(inputID string, sender string, value string)
- func (regInputs *RegisteredInputs) SetNodeID(nodeHWID string, newNodeID string)
- func (regInputs *RegisteredInputs) UpdateInput(input *types.InputDiscoveryMessage) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeInputDiscoveryAddress ¶
func MakeInputDiscoveryAddress(domain string, publisherID string, nodeID string, inputType types.InputType, instance string) string
MakeInputDiscoveryAddress creates the address for the input discovery
func MakeInputHWID ¶
MakeInputHWID creates the internal ID to identify the input of the owning node using its HWID
func MakeSetInputAddress ¶
func MakeSetInputAddress(domain string, publisherID string, nodeID string, inputType types.InputType, instance string) string
MakeSetInputAddress creates the address used to update a node input value nodeAddress is an address containing the node.
func NewInput ¶
func NewInput( domain string, publisherID string, nodeHWID string, inputType types.InputType, instance string) *types.InputDiscoveryMessage
NewInput instance for creating an input object for later adding. To add it to the inputlist use 'UpdateInput'
func PublishRegisteredInputs ¶
func PublishRegisteredInputs( inputs []*types.InputDiscoveryMessage, messageSigner *messaging.MessageSigner)
PublishRegisteredInputs publishes input discovery messages This will clear the updated inputs list
func PublishSetInput ¶
func PublishSetInput( destination string, value string, sender string, messageSigner *messaging.MessageSigner, encryptionKey *ecdsa.PublicKey) error
PublishSetInput sends a message to set the input value of a remote destination. The destination is the full remote input address including domain and publisherID.
The message is signed by this publisher's key and encrypted with the destination public key. The sender is included in the message and used to verify this publisher's message signature. The messageSigner is used to encrypt the message using the encryption key from the destination publisher
Types ¶
type DomainInputs ¶
type DomainInputs struct {
// contains filtered or unexported fields
}
DomainInputs for managing discovered inputs.
func NewDomainInputs ¶
func NewDomainInputs(messageSigner *messaging.MessageSigner) *DomainInputs
NewDomainInputs creates a new instance for handling of discovered domain inputs
func (*DomainInputs) AddInput ¶
func (domainInputs *DomainInputs) AddInput(input *types.InputDiscoveryMessage)
AddInput adds or replaces the input.
func (*DomainInputs) GetAllInputs ¶
func (domainInputs *DomainInputs) GetAllInputs() []*types.InputDiscoveryMessage
GetAllInputs returns a new list with the inputs from this collection
func (*DomainInputs) GetInputByAddress ¶
func (domainInputs *DomainInputs) GetInputByAddress(inputAddr string) *types.InputDiscoveryMessage
GetInputByAddress returns an input by its address inputAddr must contain the full input address, eg <zone>/<publisherId>/<nodeId>/"$input"/<type>/<instance> Returns nil if address has no known input
func (*DomainInputs) GetNodeInputs ¶
func (domainInputs *DomainInputs) GetNodeInputs(nodeAddress string) []*types.InputDiscoveryMessage
GetNodeInputs returns all inputs of a node Returns nil if the node has no known input
func (*DomainInputs) RemoveInput ¶
func (domainInputs *DomainInputs) RemoveInput(inputAddress string)
RemoveInput removes an input using its address. If the input doesn't exist, this is ignored.
func (*DomainInputs) Subscribe ¶
func (domainInputs *DomainInputs) Subscribe(domain string, publisherID string)
Subscribe to inputs from a domain publisher
func (*DomainInputs) Unsubscribe ¶
func (domainInputs *DomainInputs) Unsubscribe(domain string, publisherID string)
Unsubscribe from publisher inputs
type ReceiveFromFiles ¶
type ReceiveFromFiles struct {
// contains filtered or unexported fields
}
ReceiveFromFiles receives updates from file watchers of inputs that listens for changes in files This supports multiple watchers for the same file.
func NewReceiveFromFiles ¶
func NewReceiveFromFiles(regInputs *RegisteredInputs) *ReceiveFromFiles
NewReceiveFromFiles creates a new file watcher input list
func (*ReceiveFromFiles) CreateInput ¶
func (iffile *ReceiveFromFiles) CreateInput( nodeHWID string, inputType types.InputType, instance string, path string, handler func(input *types.InputDiscoveryMessage, sender string, path string)) *types.InputDiscoveryMessage
CreateInput creates an input that triggers when a file is written to and invokes the given handler. The file must exist when creating the input (the file watcher requires it). If the input already exists, the existing input is returned.
func (*ReceiveFromFiles) DeleteInput ¶
func (iffile *ReceiveFromFiles) DeleteInput(nodeHWID string, inputType types.InputType, instance string)
DeleteInput deletes the input and unsubscribes from the file watcher
func (*ReceiveFromFiles) Start ¶
func (iffile *ReceiveFromFiles) Start()
Start listening for file changes
func (*ReceiveFromFiles) Stop ¶
func (iffile *ReceiveFromFiles) Stop()
Stop listening for file changes
type ReceiveFromHTTP ¶
type ReceiveFromHTTP struct {
// contains filtered or unexported fields
}
ReceiveFromHTTP with inputs to periodically poll HTTP Only a single handler per URL can be used.
func NewReceiveFromHTTP ¶
func NewReceiveFromHTTP(registeredInputs *RegisteredInputs) *ReceiveFromHTTP
NewReceiveFromHTTP creates a new instance of HTTP based inputs Inputs must be created through CreateInput
func (*ReceiveFromHTTP) CreateHTTPInput ¶
func (rxFromHttp *ReceiveFromHTTP) CreateHTTPInput( nodeHWID string, inputType types.InputType, instance string, url string, login string, password string, pollInterval int, handler func(input *types.InputDiscoveryMessage, sender string, path string)) *types.InputDiscoveryMessage
CreateHTTPInput creates a new input that periodically polls a URL address. If a login and password is provided then it will be used for http basic authentication. If an input of the given nodeID, type and instance already exists it will be replaced. pollInterval is in seconds
func (*ReceiveFromHTTP) DeleteInput ¶
func (rxFromHttp *ReceiveFromHTTP) DeleteInput(inputID string)
DeleteInput deletes the input and stops polling the url
func (*ReceiveFromHTTP) Start ¶
func (rxFromHttp *ReceiveFromHTTP) Start()
Start polling inputs for changes
type ReceiveFromOutputs ¶
type ReceiveFromOutputs struct {
// contains filtered or unexported fields
}
ReceiveFromOutputs subscribe to domain outputs to use as input
func NewReceiveFromOutputs ¶
func NewReceiveFromOutputs( messageSigner *messaging.MessageSigner, registeredInputs *RegisteredInputs, ) *ReceiveFromOutputs
NewReceiveFromOutputs creates a input list with subscriptions to outputs to use as input
func (*ReceiveFromOutputs) CreateInput ¶
func (ifout *ReceiveFromOutputs) CreateInput( nodeID string, inputType types.InputType, instance string, outputAddress string, handler func(input *types.InputDiscoveryMessage, sender string, payload string)) *types.InputDiscoveryMessage
CreateInput adds a subscription to an output to use as input If the given output address is already subscribed to, its handler will be replaced
The given outputAddress is one of $raw or $latest output address The handler is provided with the address, the sender and the received output value.
func (*ReceiveFromOutputs) DeleteInput ¶
func (ifout *ReceiveFromOutputs) DeleteInput(inputID string)
DeleteInput by address
type ReceiveFromSetCommands ¶
type ReceiveFromSetCommands struct {
// contains filtered or unexported fields
}
ReceiveFromSetCommands handles set commands aimed at inputs managed by this publisher. This decrypts incoming messages determines the sender and verifies the signature with the sender public key. Last it translates from the publishing address to the input ID before passing the request to the handler associated with the input.
func NewReceiveFromSetCommands ¶
func NewReceiveFromSetCommands( domain string, publisherID string, messageSigner *messaging.MessageSigner, registeredInputs *RegisteredInputs) *ReceiveFromSetCommands
NewReceiveFromSetCommands returns a new instance of handling of set input commands. The private key is used to decrypt set commands. Without it, decryption is disabled.
func (*ReceiveFromSetCommands) CreateInput ¶
func (ifset *ReceiveFromSetCommands) CreateInput( nodeHWID string, inputType types.InputType, instance string, handler func(input *types.InputDiscoveryMessage, sender string, value string)) *types.InputDiscoveryMessage
CreateInput creates a new input that responds to a set command from the message bus. If an input of the given nodeHWID, type and instance already exist it will be replaced. This returns the new input
func (*ReceiveFromSetCommands) DeleteInput ¶
func (ifset *ReceiveFromSetCommands) DeleteInput(inputID string)
DeleteInput deletes the input and unsubscribes to the input's set command
type RegisteredInputs ¶
type RegisteredInputs struct {
// contains filtered or unexported fields
}
RegisteredInputs manages registration of publisher inputs Generics would be nice as this overlaps with outputs, nodes, publishers The inputID used in the inputMap consist of nodeHWID.inputType.instance
func NewRegisteredInputs ¶
func NewRegisteredInputs(domain string, publisherID string) *RegisteredInputs
NewRegisteredInputs creates a new instance for managing registered inputs
func (*RegisteredInputs) CreateInput ¶
func (regInputs *RegisteredInputs) CreateInput( nodeHWID string, inputType types.InputType, instance string, handler func(input *types.InputDiscoveryMessage, sender string, value string)) *types.InputDiscoveryMessage
CreateInput creates and registers a new input with optional handler for input trigger
func (*RegisteredInputs) CreateInputWithSource ¶
func (regInputs *RegisteredInputs) CreateInputWithSource( nodeHWID string, inputType types.InputType, instance string, source string, handler func(input *types.InputDiscoveryMessage, sender string, value string)) *types.InputDiscoveryMessage
CreateInputWithSource creates and registers a new input that takes its input value from a given source Replaces the existing input if it already exist.
func (*RegisteredInputs) DeleteInput ¶
func (regInputs *RegisteredInputs) DeleteInput(inputHWID string)
DeleteInput unregisters the input inputHWID is the input's ID based on the node HWID
func (*RegisteredInputs) GetAllInputs ¶
func (regInputs *RegisteredInputs) GetAllInputs() []*types.InputDiscoveryMessage
GetAllInputs returns the list of inputs
func (*RegisteredInputs) GetInputByAddress ¶
func (regInputs *RegisteredInputs) GetInputByAddress(inputAddr string) *types.InputDiscoveryMessage
GetInputByAddress returns an input by its publication address Returns nil if address has no known input
func (*RegisteredInputs) GetInputByID ¶
func (regInputs *RegisteredInputs) GetInputByID(inputID string) *types.InputDiscoveryMessage
GetInputByID returns an input by its input ID (nodeHWID.type.instance) Returns nil if there is no known input
func (*RegisteredInputs) GetInputByNodeHWID ¶
func (regInputs *RegisteredInputs) GetInputByNodeHWID( nodeHWID string, inputType types.InputType, instance string) *types.InputDiscoveryMessage
GetInputByNodeHWID returns an input by nodeHWID, input type and instance Returns nil if the device has no such input
func (*RegisteredInputs) GetInputsByNodeHWID ¶
func (regInputs *RegisteredInputs) GetInputsByNodeHWID(nodeHWID string) []*types.InputDiscoveryMessage
GetInputsByNodeHWID returns a list of all inputs that are part of the owning node
func (*RegisteredInputs) GetInputsWithSource ¶
func (regInputs *RegisteredInputs) GetInputsWithSource(source string) []*types.InputDiscoveryMessage
GetInputsWithSource returns a list of inputs that have the given source The source is used for inputs that are files, http poll addresses or other outputs. It is not used with set input commands.
func (*RegisteredInputs) GetUpdatedInputs ¶
func (regInputs *RegisteredInputs) GetUpdatedInputs(clearUpdates bool) []*types.InputDiscoveryMessage
GetUpdatedInputs returns the list of registered inputs that have been updated clear the update on return
func (*RegisteredInputs) NotifyInputHandler ¶
func (regInputs *RegisteredInputs) NotifyInputHandler(inputID string, sender string, value string)
NotifyInputHandler passes a set input command to the input's handler to execute the request. The sender is the identity address of the publisher and can be used for authorization. It is empty for local inputs such as file watcher and http polling.
func (*RegisteredInputs) SetNodeID ¶
func (regInputs *RegisteredInputs) SetNodeID(nodeHWID string, newNodeID string)
SetNodeID changes the publication address of all inputs that belong to the device hardware address
func (*RegisteredInputs) UpdateInput ¶
func (regInputs *RegisteredInputs) UpdateInput(input *types.InputDiscoveryMessage) error
UpdateInput replaces an existing input with the provided input. The input must already exist and be created using 'CreateInput', otherwise it returns an error