gateways

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2019 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(backoff *wait.Backoff, conn func() error) error

General connection helper

func HandleEventsFromEventSource

func HandleEventsFromEventSource(name string, eventStream Eventing_StartEventSourceServer, dataCh chan []byte, errorCh chan error, doneCh chan struct{}, log *zlog.Logger) error

HandleEventsFromEventSource handles events from the event source.

func Hasher

func Hasher(value string) string

Hasher hashes a string

func InitBackoff

func InitBackoff(backoff *wait.Backoff)

InitBackoff initializes backoff

func Recover

func Recover(eventSource string)

Recover recovers from panics in event sources

func RegisterEventingServer

func RegisterEventingServer(s *grpc.Server, srv EventingServer)

func SetValidEventSource

func SetValidEventSource(v *ValidEventSource, reason string, valid bool)

SetValidateReason set the result of event source validation

func StartGateway

func StartGateway(es EventingServer)

StartGateway start a gateway

Types

type Event

type Event struct {
	// The event source name.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// The event payload.
	Payload              []byte   `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

* Represents an event

func (*Event) Descriptor

func (*Event) Descriptor() ([]byte, []int)

func (*Event) GetName

func (m *Event) GetName() string

func (*Event) GetPayload

func (m *Event) GetPayload() []byte

func (*Event) ProtoMessage

func (*Event) ProtoMessage()

func (*Event) Reset

func (m *Event) Reset()

func (*Event) String

func (m *Event) String() string

func (*Event) XXX_DiscardUnknown

func (m *Event) XXX_DiscardUnknown()

func (*Event) XXX_Marshal

func (m *Event) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Event) XXX_Merge

func (m *Event) XXX_Merge(src proto.Message)

func (*Event) XXX_Size

func (m *Event) XXX_Size() int

func (*Event) XXX_Unmarshal

func (m *Event) XXX_Unmarshal(b []byte) error

type EventSource

type EventSource struct {
	// ID of the event source. internally generated.
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// The event source name.
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	// The event source configuration value.
	Data                 string   `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

* Represents an event source

func (*EventSource) Descriptor

func (*EventSource) Descriptor() ([]byte, []int)

func (*EventSource) GetData

func (m *EventSource) GetData() string

func (*EventSource) GetId

func (m *EventSource) GetId() string

func (*EventSource) GetName

func (m *EventSource) GetName() string

func (*EventSource) ProtoMessage

func (*EventSource) ProtoMessage()

func (*EventSource) Reset

func (m *EventSource) Reset()

func (*EventSource) String

func (m *EventSource) String() string

func (*EventSource) XXX_DiscardUnknown

func (m *EventSource) XXX_DiscardUnknown()

func (*EventSource) XXX_Marshal

func (m *EventSource) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*EventSource) XXX_Merge

func (m *EventSource) XXX_Merge(src proto.Message)

func (*EventSource) XXX_Size

func (m *EventSource) XXX_Size() int

func (*EventSource) XXX_Unmarshal

func (m *EventSource) XXX_Unmarshal(b []byte) error

type EventSourceContext

type EventSourceContext struct {
	// Data holds the actual event source
	Data *EventSourceData
	// Ctx contains context for the connection
	Ctx context.Context
	// Cancel upon invocation cancels the connection context
	Cancel context.CancelFunc
	// Client is grpc client
	Client EventingClient
	// Conn is grpc connection
	Conn *grpc.ClientConn
}

EventSourceContext contains information of a event source for gateway to run.

type EventSourceData

type EventSourceData struct {
	// Unique ID for event source
	ID string `json:"id"`
	// Src contains name of the event source
	Src string `json:"src"`
	// Config contains the event source
	Config string `json:"config"`
}

EventSourceData holds the actual event source

type EventSourceStatus

type EventSourceStatus struct {
	// Id of the event source
	Id string
	// Name of the event source
	Name string
	// Message
	Message string
	// Phase of the event source
	Phase v1alpha1.NodePhase
	// Gateway reference
	Gw *v1alpha1.Gateway
}

EventSourceStatus encapsulates state of an event source

type EventingClient

type EventingClient interface {
	// StartEventSource starts an event source and returns stream of events.
	StartEventSource(ctx context.Context, in *EventSource, opts ...grpc.CallOption) (Eventing_StartEventSourceClient, error)
	// ValidateEventSource validates an event source.
	ValidateEventSource(ctx context.Context, in *EventSource, opts ...grpc.CallOption) (*ValidEventSource, error)
}

EventingClient is the client API for Eventing service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewEventingClient

func NewEventingClient(cc *grpc.ClientConn) EventingClient

type EventingServer

type EventingServer interface {
	// StartEventSource starts an event source and returns stream of events.
	StartEventSource(*EventSource, Eventing_StartEventSourceServer) error
	// ValidateEventSource validates an event source.
	ValidateEventSource(context.Context, *EventSource) (*ValidEventSource, error)
}

EventingServer is the server API for Eventing service.

type Eventing_StartEventSourceClient

type Eventing_StartEventSourceClient interface {
	Recv() (*Event, error)
	grpc.ClientStream
}

type Eventing_StartEventSourceServer

type Eventing_StartEventSourceServer interface {
	Send(*Event) error
	grpc.ServerStream
}

type GatewayConfig

type GatewayConfig struct {
	// Log provides fast and simple logger dedicated to JSON output
	Log zerolog.Logger
	// Clientset is client for kubernetes API
	Clientset kubernetes.Interface
	// Name is gateway name
	Name string
	// Namespace is namespace for the gateway to run inside
	Namespace string
	// KubeConfig rest client config
	KubeConfig *rest.Config

	// StatusCh is used to communicate the status of an event source
	StatusCh chan EventSourceStatus
	// contains filtered or unexported fields
}

GatewayConfig provides a generic event source for a gateway

func NewGatewayConfiguration

func NewGatewayConfiguration() *GatewayConfig

NewGatewayConfiguration returns a new gateway configuration

func (*GatewayConfig) DispatchEvent

func (gc *GatewayConfig) DispatchEvent(gatewayEvent *Event) error

DispatchEvent dispatches event to gateway transformer for further processing

func (*GatewayConfig) UpdateGatewayResourceState

func (gc *GatewayConfig) UpdateGatewayResourceState(status *EventSourceStatus)

UpdateGatewayResourceState updates gateway resource nodes state

func (*GatewayConfig) WatchGateway

func (gc *GatewayConfig) WatchGateway(ctx context.Context) (cache.Controller, error)

WatchGatewayEventSources watches change in the gateway resource This will act as replacement for old gateway-transformer-configmap. Changes to watchers, event version and event type will be reflected.

func (*GatewayConfig) WatchGatewayEventSources

func (gc *GatewayConfig) WatchGatewayEventSources(ctx context.Context) (cache.Controller, error)

WatchGatewayEventSources watches change in configuration for the gateway

type GatewayEvent

type GatewayEvent struct {
	// Src is source of event
	Src string `json:"src"`
	// Payload contains event data
	Payload []byte `json:"payload"`
}

GatewayEvent is the internal representation of an event.

type TransformerPayload

type TransformerPayload struct {
	// Src contains information about which specific configuration in gateway generated the event
	Src string `json:"src"`
	// Payload is event data
	Payload []byte `json:"payload"`
}

TransformerPayload contains payload of cloudevents.

type ValidEventSource

type ValidEventSource struct {
	// whether event source is valid
	IsValid bool `protobuf:"varint,1,opt,name=isValid,proto3" json:"isValid,omitempty"`
	// reason if an event source is invalid
	Reason               string   `protobuf:"bytes,2,opt,name=reason,proto3" json:"reason,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

* Represents if an event source is valid or not

func (*ValidEventSource) Descriptor

func (*ValidEventSource) Descriptor() ([]byte, []int)

func (*ValidEventSource) GetIsValid

func (m *ValidEventSource) GetIsValid() bool

func (*ValidEventSource) GetReason

func (m *ValidEventSource) GetReason() string

func (*ValidEventSource) ProtoMessage

func (*ValidEventSource) ProtoMessage()

func (*ValidEventSource) Reset

func (m *ValidEventSource) Reset()

func (*ValidEventSource) String

func (m *ValidEventSource) String() string

func (*ValidEventSource) XXX_DiscardUnknown

func (m *ValidEventSource) XXX_DiscardUnknown()

func (*ValidEventSource) XXX_Marshal

func (m *ValidEventSource) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ValidEventSource) XXX_Merge

func (m *ValidEventSource) XXX_Merge(src proto.Message)

func (*ValidEventSource) XXX_Size

func (m *ValidEventSource) XXX_Size() int

func (*ValidEventSource) XXX_Unmarshal

func (m *ValidEventSource) XXX_Unmarshal(b []byte) error

Directories

Path Synopsis
This package contains structs and methods that are shared across different gateways.
This package contains structs and methods that are shared across different gateways.
community
core

Jump to

Keyboard shortcuts

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