eaa

package
v0.0.0-...-4380e07 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateAndSetCACertPool

func CreateAndSetCACertPool(caFile string) (*x509.CertPool, error)

CreateAndSetCACertPool creates and set CA cert pool

func DeregisterApplication

func DeregisterApplication(w http.ResponseWriter, r *http.Request)

DeregisterApplication implements https API

func GetNotifications

func GetNotifications(w http.ResponseWriter, r *http.Request)

GetNotifications implements https API

func GetServices

func GetServices(w http.ResponseWriter, r *http.Request)

GetServices implements https API

func GetSubscriptions

func GetSubscriptions(w http.ResponseWriter, r *http.Request)

GetSubscriptions implements https API

func InitEaaContext

func InitEaaContext(cfgPath string, eaaCtx *Context) error

InitEaaContext initializes the Eaa Context

func NewEaaRouter

func NewEaaRouter(eaaCtx *Context) *mux.Router

NewEaaRouter initializes EAA router

func PushNotificationToSubscribers

func PushNotificationToSubscribers(w http.ResponseWriter, r *http.Request)

PushNotificationToSubscribers implements https API

func RegisterApplication

func RegisterApplication(w http.ResponseWriter, r *http.Request)

RegisterApplication implements https API

func Run

func Run(parentCtx context.Context, cfgPath string) error

Run start EAA

func RunServer

func RunServer(parentCtx context.Context, eaaCtx *Context) error

RunServer starts Edge Application Agent server listening on port read from config file

func SubscribeNamespaceNotifications

func SubscribeNamespaceNotifications(w http.ResponseWriter, r *http.Request)

SubscribeNamespaceNotifications implements https API

func SubscribeServiceNotifications

func SubscribeServiceNotifications(w http.ResponseWriter, r *http.Request)

SubscribeServiceNotifications implements https API

func UnsubscribeAllNotifications

func UnsubscribeAllNotifications(w http.ResponseWriter, r *http.Request)

UnsubscribeAllNotifications implements https API

func UnsubscribeNamespaceNotifications

func UnsubscribeNamespaceNotifications(w http.ResponseWriter, r *http.Request)

UnsubscribeNamespaceNotifications implements https API

func UnsubscribeServiceNotifications

func UnsubscribeServiceNotifications(w http.ResponseWriter, r *http.Request)

UnsubscribeServiceNotifications implements https API

Types

type CertKeyPair

type CertKeyPair struct {
	// contains filtered or unexported fields
}

CertKeyPair manages digital certificates.

func InitEaaCert

func InitEaaCert(certInfo CertsInfo) (*CertKeyPair, error)

InitEaaCert generates cartificate for server signed by CA

type Certs

type Certs struct {
	// contains filtered or unexported fields
}

Certs stores certs and keys for root ca and eaa

type CertsInfo

type CertsInfo struct {
	CaRootKeyPath     string `json:"CaRootKeyPath"`
	CaRootPath        string `json:"CaRootPath"`
	ServerCertPath    string `json:"ServerCertPath"`
	ServerKeyPath     string `json:"ServerKeyPath"`
	CommonName        string `json:"CommonName"`
	KafkaCAPath       string `json:"KafkaCAPath"`
	KafkaUserCertPath string `json:"KafkaUserCertPath"`
	KafkaUserKeyPath  string `json:"KafkaUserKeyPath"`
}

CertsInfo describes paths for certs used in configuration

type Config

type Config struct {
	TLSEndpoint        string        `json:"TlsEndpoint"`
	OpenEndpoint       string        `json:"OpenEndpoint"`
	ValidationEndpoint string        `json:"ValidationEndpoint"`
	HeartbeatInterval  util.Duration `json:"HeartbeatInterval"`
	Certs              CertsInfo     `json:"Certs"`
	KafkaBroker        string        `json:"KafkaBroker"`
}

Config describes EAA JSON config file

type ConsumerConnection

type ConsumerConnection struct {
	// contains filtered or unexported fields
}

ConsumerConnection stores websocket connection of a consumer

type ConsumerSubscription

type ConsumerSubscription struct {
	// contains filtered or unexported fields
}

ConsumerSubscription stores namespace notification subscribers and a map of services and their subscribers

type Context

type Context struct {
	MsgBrokerCtx msgBroker
	// contains filtered or unexported fields
}

Context holds all EAA structures

type GoChannelMsgBroker

type GoChannelMsgBroker struct {
	// contains filtered or unexported fields
}

GoChannelMsgBroker is a GoChannel-backed msgBroker

func NewGoChannelMsgBroker

func NewGoChannelMsgBroker(eaaCtx *Context) *GoChannelMsgBroker

NewGoChannelMsgBroker creates and returns a GoChannel-backed msgBroker

type KafkaInterface

type KafkaInterface interface {
	DefaultSaramaSubscriberConfig() *sarama.Config
	DefaultSaramaSyncPublisherConfig() *sarama.Config
	NewWithPartitioningMarshaler(generatePartitionKey kafka.GeneratePartitionKey) kafka.MarshalerUnmarshaler
	NewPublisher(config kafka.PublisherConfig, logger watermill.LoggerAdapter) (*kafka.Publisher, error)
	NewSubscriber(config kafka.SubscriberConfig, logger watermill.LoggerAdapter) (*kafka.Subscriber, error)
}

KafkaInterface allows dependency injection for unit testing

var (
	// KafkaBroker allows easey dependency injection for unit tests
	KafkaBroker KafkaInterface
)

type KafkaMsgBroker

type KafkaMsgBroker struct {
	// contains filtered or unexported fields
}

KafkaMsgBroker is a Kafka-backed msgBroker

func NewKafkaMsgBroker

func NewKafkaMsgBroker(eaaCtx *Context, consumerGroup string,
	tlsConfig *tls.Config) (*KafkaMsgBroker, error)

NewKafkaMsgBroker creates and returns a Kafka-backed msgBroker

type NotificationDescriptor

type NotificationDescriptor struct {
	// Name of notification
	Name string `json:"name,omitempty"`
	// Version of notification
	Version string `json:"version,omitempty"`
	// Human readable description of notification
	Description string `json:"description,omitempty"`
}

NotificationDescriptor describes a type used in EAA API

type NotificationFromProducer

type NotificationFromProducer struct {
	// Name of notification
	Name string `json:"name,omitempty"`
	// Version of notification
	Version string `json:"version,omitempty"`
	// The payload can be any JSON object with a name
	// and version-specific schema.
	Payload json.RawMessage `json:"payload,omitempty"`
}

NotificationFromProducer describes a type used in EAA API

type NotificationMessage

type NotificationMessage struct {
	Notification *NotificationFromProducer
	URN          *URN
}

NotificationMessage is a message sent/received by a message broker

type NotificationSubscriptions

type NotificationSubscriptions struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

NotificationSubscriptions is a synchronized map of a namespace notification struct to the consumer subscription struct

type NotificationToConsumer

type NotificationToConsumer struct {
	// Name of notification
	Name string `json:"name,omitempty"`
	// Version of notification
	Version string `json:"version,omitempty"`
	// The payload can be any JSON object with a name
	// and version-specific schema.
	Payload json.RawMessage `json:"payload,omitempty"`
	// URN of the producer
	URN URN `json:"producer,omitempty"`
}

NotificationToConsumer describes a type used in EAA API

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
}

Route describes traffic routing

type Routes

type Routes []Route

Routes represents a routing table

type Service

type Service struct {
	URN           *URN                     `json:"urn,omitempty"`
	Description   string                   `json:"description,omitempty"`
	EndpointURI   string                   `json:"endpoint_uri,omitempty"`
	Status        string                   `json:"status,omitempty"`
	Notifications []NotificationDescriptor `json:"notifications,omitempty"`
	Info          json.RawMessage          `json:"info,omitempty"`
}

Service JSON struct

type ServiceList

type ServiceList struct {
	Services []Service `json:"services,omitempty"`
}

ServiceList JSON struct

type ServiceMessage

type ServiceMessage struct {
	Svc    *Service `json:"service"`
	Action string   `json:"action"`
}

ServiceMessage is a message sent/received by a message broker

type SubscriberIds

type SubscriberIds []string

SubscriberIds stores subscriber ids as a slice of strings

func (*SubscriberIds) RemoveSubscriber

func (sI *SubscriberIds) RemoveSubscriber(commonName string) bool

RemoveSubscriber delete consumer ID from subscribers list

type Subscription

type Subscription struct {

	// The name of the producer app. The unique ID is optional for
	// subscribing and if not given will subscribe to any producer in the
	// namespace.
	URN *URN `json:"urn,omitempty"`

	// The list of all notification types registered by all producers in
	// this namespace.
	Notifications []NotificationDescriptor `json:"notifications,omitempty"`
}

Subscription describes a type used in EAA API

type SubscriptionList

type SubscriptionList struct {
	Subscriptions []Subscription `json:"subscriptions,omitempty"`
}

SubscriptionList JSON struct

type SubscriptionMessage

type SubscriptionMessage struct {
	ClientCommonName string
	Subscription     *Subscription
	Action           string
	Scope            string
}

SubscriptionMessage is a message sent/received by a message broker

type URN

type URN struct {

	// The per-namespace unique portion of the URN that when appended to
	// the namespace with a separator forms the complete URN.
	ID string `json:"id,omitempty"`

	// The non-unique portion of the URN that identifies the class excluding
	// a trailing separator.
	Namespace string `json:"namespace,omitempty"`
}

URN describes a type used in EAA API

func CommonNameStringToURN

func CommonNameStringToURN(commonName string) (URN, error)

CommonNameStringToURN parses a common name string to a URN struct

func (*URN) String

func (u *URN) String() string

Provides string representation of URN

type UniqueNotif

type UniqueNotif struct {
	// contains filtered or unexported fields
}

UniqueNotif stores information about unique notification. It is used as a key in NotificationSubscriptions map

Jump to

Keyboard shortcuts

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