inter

package
v0.24.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2021 License: Apache-2.0 Imports: 15 Imported by: 5

Documentation

Index

Constants

View Source
const (
	MessageMessageType        string = "message"
	RequestMessageType        string = "request"
	DirectRequestMessageType  string = "direct_request"
	ServiceRequestMessageType string = "service_request"
	ReplyMessageType          string = "reply"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentConnector

type AgentConnector interface {
	ConnectedServer() string
	ConnectionOptions() nats.Options
	ConnectionStats() nats.Statistics
	QueueSubscribe(ctx context.Context, name string, subject string, group string, output chan ConnectorMessage) error
	Unsubscribe(name string) error
	AgentBroadcastTarget(collective string, agent string) string
	ServiceBroadcastTarget(collective string, agent string) string
}

AgentConnector provides the minimal Connector features for subscribing and unsubscribing agents

type ConfigurationProvider

type ConfigurationProvider interface {
	Configuration() *config.Config
}

ConfigurationProvider provides runtime Choria configuration

type ConnectionManager

type ConnectionManager interface {
	NewConnector(ctx context.Context, servers func() (srvcache.Servers, error), name string, logger *log.Entry) (conn Connector, err error)
}

ConnectionManager is capable of being a factory for connection, mcollective.Choria is one

type Connector

type Connector interface {
	AgentBroadcastTarget(collective string, agent string) string
	ChanQueueSubscribe(name string, subject string, group string, capacity int) (chan ConnectorMessage, error)
	Close()
	Connect(ctx context.Context) (err error)
	ConnectedServer() string
	ConnectionOptions() nats.Options
	ConnectionStats() nats.Statistics
	IsConnected() bool
	Nats() *nats.Conn
	NodeDirectedTarget(collective string, identity string) string
	Publish(msg Message) error
	PublishRaw(target string, data []byte) error
	PublishRawMsg(msg *nats.Msg) error
	QueueSubscribe(ctx context.Context, name string, subject string, group string, output chan ConnectorMessage) error
	ReplyTarget(msg Message) (string, error)
	RequestRawMsgWithContext(ctx context.Context, msg *nats.Msg) (*nats.Msg, error)
	ServiceBroadcastTarget(collective string, agent string) string
	Unsubscribe(name string) error
}

Connector is the interface a connector must implement to be valid be it NATS, Stomp, Testing etc

type ConnectorInfo

type ConnectorInfo interface {
	ConnectedServer() string
	ConnectionOptions() nats.Options
	ConnectionStats() nats.Statistics
}

ConnectorInfo provides information about the active connection without giving access to the connection

type ConnectorMessage

type ConnectorMessage interface {
	Subject() string
	Reply() string
	Data() []byte

	// Msg is the middleware specific message like *nats.Msg
	Msg() interface{}
}

ConnectorMessage is received from middleware

type Framework

type Framework interface {
	ProtocolConstructor
	ConfigurationProvider
	ConnectionManager

	BuildInfo() *build.Info
	CallerID() string
	Certname() string
	ClientTLSConfig() (*tls.Config, error)
	Colorize(c string, format string, a ...interface{}) string
	ConfigureProvisioning()
	DisableTLSVerify() bool
	Enroll(ctx context.Context, wait time.Duration, cb func(digest string, try int)) error
	FacterCmd() string
	FacterDomain() (string, error)
	FacterFQDN() (string, error)
	FacterStringFact(fact string) (string, error)
	FederationCollectives() (collectives []string)
	FederationMiddlewareServers() (servers srvcache.Servers, err error)
	Getuid() int
	GovernorSubject(name string) string
	HTTPClient(secure bool) (*http.Client, error)
	HasCollective(collective string) bool
	IsFederated() (result bool)
	KV(ctx context.Context, conn Connector, bucket string, create bool, opts ...kv.Option) (kv.KV, error)
	KVWithConn(ctx context.Context, conn Connector, bucket string, create bool, opts ...kv.Option) (kv.KV, Connector, error)
	Logger(component string) *logrus.Entry
	MiddlewareServers() (servers srvcache.Servers, err error)
	NetworkBrokerPeers() (servers srvcache.Servers, err error)
	OverrideCertname() string
	PQLQuery(query string) ([]byte, error)
	PQLQueryCertNames(query string) ([]string, error)
	ParseSignerTokenUnverified() (token *jwt.Token, claims jwt.MapClaims, err error)
	ProgressWidth() int
	PrometheusTextFileDir() string
	ProvisionMode() bool
	ProvisioningServers(ctx context.Context) (srvcache.Servers, error)
	PublicCert() (*x509.Certificate, error)
	PuppetAIOCmd(command string, def string) string
	PuppetDBServers() (servers srvcache.Servers, err error)
	PuppetSetting(setting string) (string, error)
	QuerySrvRecords(records []string) (srvcache.Servers, error)
	SetLogWriter(out io.Writer)
	SetLogger(logger *logrus.Logger)
	SetupLogging(debug bool) (err error)
	ShouldUseNGS() bool
	SignerToken() (token string, err error)
	SupportsProvisioning() bool
	TLSConfig() (*tls.Config, error)
	TrySrvLookup(names []string, defaultSrv srvcache.Server) (srvcache.Server, error)
	UniqueID() string
	UniqueIDFromUnverifiedToken() (caller string, id string, token string, err error)
	ValidateSecurity() (errors []string, ok bool)
}

type Message

type Message interface {
	Agent() string
	Base64Payload() string
	CacheTransport()
	CallerID() string
	Collective() string
	CustomTarget() string
	DiscoveredHosts() []string
	ExpectedMessageID() string
	Filter() *protocol.Filter
	IsCachedTransport() bool
	NotifyPublish()
	OnPublish(func())
	Payload() string
	ProtocolVersion() string
	ReplyTo() string
	Request() Message
	RequestID() string
	SenderID() string
	SetBase64Payload(payload string) error
	SetCollective(string) error
	SetCustomTarget(string)
	SetDiscoveredHosts(hosts []string)
	SetExpectedMsgID(id string) error
	SetFilter(*protocol.Filter)
	SetPayload(string)
	SetProtocolVersion(string)
	SetReplyTo(string) error
	SetTTL(int)
	SetType(string) error
	String() string
	TTL() int
	TimeStamp() time.Time
	Transport() (protocol.TransportMessage, error)
	Type() string
	Validate() (bool, error)
	ValidateTTL() bool
	ReplyTarget() string
}

Message is a message that is transportable over the Choria Protocol

type Pluggable

type Pluggable interface {
	// PluginInstance is any structure that implements the plugin, should be right type for the kind of plugin
	PluginInstance() interface{}

	// PluginName is a human friendly name for the plugin
	PluginName() string

	// PluginType is the type of the plugin, to match plugin.Type
	PluginType() PluginType

	// PluginVersion is the version of the plugin
	PluginVersion() string
}

Pluggable is a Choria Plugin

type PluginType

type PluginType int

PluginType are types of choria plugin

const (
	// UnknownPlugin is a unknown plugin type
	UnknownPlugin PluginType = iota

	// AgentProviderPlugin is a plugin that provide types of agents to Choria
	AgentProviderPlugin

	// AgentPlugin is a type of agent
	AgentPlugin

	// ProvisionTargetResolverPlugin is a plugin that helps provisioning mode Choria find its broker
	ProvisionTargetResolverPlugin

	// ConfigMutatorPlugin is a plugin that can dynamically adjust
	// configuration based on local site conditions
	ConfigMutatorPlugin

	// MachineWatcherPlugin is a plugin that adds a Autonomous Agent Watcher
	MachineWatcherPlugin

	// DataPlugin is a plugin that provides data to choria
	DataPlugin

	// MachinePlugin is an autonomous agent
	MachinePlugin
)

type ProtocolConstructor

type ProtocolConstructor interface {
	NewMessage(payload string, agent string, collective string, msgType string, request Message) (msg Message, err error)
	NewMessageFromRequest(req protocol.Request, replyto string) (Message, error)
	NewReply(request protocol.Request) (reply protocol.Reply, err error)
	NewReplyFromMessage(version string, msg Message) (rep protocol.Reply, err error)
	NewReplyFromSecureReply(sr protocol.SecureReply) (reply protocol.Reply, err error)
	NewReplyFromTransportJSON(payload []byte, skipvalidate bool) (msg protocol.Reply, err error)
	NewReplyTransportForMessage(msg Message, request protocol.Request) (protocol.TransportMessage, error)
	NewRequest(version string, agent string, senderid string, callerid string, ttl int, requestid string, collective string) (request protocol.Request, err error)
	NewRequestFromMessage(version string, msg Message) (req protocol.Request, err error)
	NewRequestFromSecureRequest(sr protocol.SecureRequest) (request protocol.Request, err error)
	NewRequestFromTransportJSON(payload []byte, skipvalidate bool) (msg protocol.Request, err error)
	NewRequestID() (string, error)
	NewRequestMessageFromTransportJSON(payload []byte) (Message, error)
	NewRequestTransportForMessage(msg Message, version string) (protocol.TransportMessage, error)
	NewSecureReply(reply protocol.Reply) (secure protocol.SecureReply, err error)
	NewSecureReplyFromTransport(message protocol.TransportMessage, skipvalidate bool) (secure protocol.SecureReply, err error)
	NewSecureRequest(request protocol.Request) (secure protocol.SecureRequest, err error)
	NewSecureRequestFromTransport(message protocol.TransportMessage, skipvalidate bool) (secure protocol.SecureRequest, err error)
	NewTransportForSecureReply(reply protocol.SecureReply) (message protocol.TransportMessage, err error)
	NewTransportForSecureRequest(request protocol.SecureRequest) (message protocol.TransportMessage, err error)
	NewTransportFromJSON(data string) (message protocol.TransportMessage, err error)
	NewTransportMessage(version string) (message protocol.TransportMessage, err error)
}

type RawNATSConnector

type RawNATSConnector interface {
	PublishRaw(target string, data []byte) error
	PublishRawMsg(msg *nats.Msg) error
	RequestRawMsgWithContext(ctx context.Context, msg *nats.Msg) (*nats.Msg, error)
}

RawNATSConnector sends NATS messages directly

type RequestSigner

type RequestSigner interface {
	// Sign signs request payload
	Sign(ctx context.Context, request []byte, cfg RequestSignerConfig) ([]byte, error)

	// Kind is the name of the provider
	Kind() string
}

RequestSigner signs request, typically remote signers over HTTP or Choria RPC

type RequestSignerConfig

type RequestSignerConfig interface {
	RemoteSignerURL() (*url.URL, error)
	RemoteSignerToken() ([]byte, error)
}

RequestSignerConfig configures RequestSigner

Directories

Path Synopsis
Package imock is a generated GoMock package.
Package imock is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL