source

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitStore

func InitStore(eventHub *EventHub) (*MemoryStore, *MemoryStore)

func ResourceID

func ResourceID(namespace, name string) string

func StartGRPCResourceSourceClient

func StartGRPCResourceSourceClient(ctx context.Context, config *grpc.GRPCOptions) (generic.CloudEventsClient[*Resource], error)

func StartMQTTResourceSourceClient

func StartMQTTResourceSourceClient(ctx context.Context, config *mqtt.MQTTOptions, sourceID string, eventHub *EventHub) (generic.CloudEventsClient[*Resource], error)

Types

type EventClient

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

EventClient is a client that can watch resource status change events.

func NewEventClient

func NewEventClient(namespace string) *EventClient

func (*EventClient) Receive

func (c *EventClient) Receive() <-chan *Resource

type EventHub

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

EventHub is a hub that can broadcast resource status change events to registered clients.

func NewEventHub

func NewEventHub() *EventHub

func (*EventHub) Broadcast

func (h *EventHub) Broadcast(res *Resource)

func (*EventHub) Register

func (h *EventHub) Register(client *EventClient)

func (*EventHub) Start

func (h *EventHub) Start(ctx context.Context)

Start starts the event hub.

func (*EventHub) Unregister

func (h *EventHub) Unregister(client *EventClient)

type GRPCServer

type GRPCServer struct {
	pbv1.UnimplementedCloudEventServiceServer
	// contains filtered or unexported fields
}

func NewGRPCServer

func NewGRPCServer(store *MemoryStore, eventHub *EventHub) *GRPCServer

func (*GRPCServer) Publish

func (svr *GRPCServer) Publish(ctx context.Context, pubReq *pbv1.PublishRequest) (*emptypb.Empty, error)

func (*GRPCServer) Start

func (svr *GRPCServer) Start(addr string) error

func (*GRPCServer) Subscribe

type MemoryStore

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

func (*MemoryStore) Add

func (s *MemoryStore) Add(resource *Resource)

func (*MemoryStore) Delete

func (s *MemoryStore) Delete(resourceID string)

func (*MemoryStore) Get

func (s *MemoryStore) Get(resourceID string) (*Resource, error)

func (*MemoryStore) List

func (s *MemoryStore) List(namespace string) []*Resource

func (*MemoryStore) UpSert

func (s *MemoryStore) UpSert(resource *Resource)

func (*MemoryStore) Update

func (s *MemoryStore) Update(resource *Resource) error

func (*MemoryStore) UpdateStatus

func (s *MemoryStore) UpdateStatus(resource *Resource) error

type Resource

type Resource struct {
	ResourceID        string
	ResourceVersion   int64
	Namespace         string
	DeletionTimestamp *metav1.Time
	Spec              unstructured.Unstructured
	Status            ResourceStatus
}

func NewResource

func NewResource(namespace, name string) *Resource

func (*Resource) GetDeletionTimestamp

func (r *Resource) GetDeletionTimestamp() *metav1.Time

func (*Resource) GetResourceVersion

func (r *Resource) GetResourceVersion() string

func (*Resource) GetUID

func (r *Resource) GetUID() kubetypes.UID

type ResourceStatus

type ResourceStatus struct {
	Conditions []metav1.Condition
}

Jump to

Keyboard shortcuts

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