spec

package
v1.0.0-beta.126 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EntityEntitlement = "entitlement"
	EntitySubjectKey  = "subjectKey"
	EntityGrant       = "grant"
)

Entitlements

View Source
const (
	EntityEvent = "event"
)

Ingestion/Events

Variables

This section is empty.

Functions

func ComposeResourcePath

func ComposeResourcePath(namespace string, items ...string) string

func NewCloudEvent

func NewCloudEvent(eventSpec EventSpec, payload CloudEventsPayload) (event.Event, error)

NewCloudEvent creates a new CloudEvent with the given event spec and payload example usage:

 ev, err := CreateCloudEvent(EventSpec{
				ID:    "123",
				Source: "test",
 }, IngestEvent{...})

func ParseCloudEvent

func ParseCloudEvent[PayloadType CloudEventsPayload](ev event.Event) (PayloadType, error)

ParseCloudEvent unmarshals a single CloudEvent into the given payload example usage: ingest, err := UnmarshalCloudEvent[schema.IngestEvent](ev)

Types

type CloudEventsPayload

type CloudEventsPayload interface {
	Spec() *EventTypeSpec
	Validate() error
}

type EventName

type EventName string

type EventSpec

type EventSpec struct {
	// ID of the event
	ID string

	// Time specifies when the event occurred
	Time time.Time

	// Subject meta
	// Examples for source and subject pairs
	//  grant:
	//      source: //openmeter.io/namespace/<id>/entitlement/<id>/grant/<id>
	//      subject: //openmeter.io/namespace/<id>/subject/<subjectID>
	//
	//  entitlement:
	//      source: //openmeter.io/namespace/<id>/entitlement/<id>
	//      subject: //openmeter.io/namespace/<id>/subject/<subjectID>
	//
	//  ingest:
	//      source: //openmeter.io/namespace/<id>/event
	//      subject: //openmeter.io/namespace/<id>/subject/<subjectID>
	Subject string
	Source  string
}

type EventSpecVersion

type EventSpecVersion string

type EventSubjectKind

type EventSubjectKind string

type EventSubsystem

type EventSubsystem string

type EventTypeSpec

type EventTypeSpec struct {
	// Subsystem defines which connector/component is responsible for the event (e.g. ingest, entitlements, etc)
	Subsystem EventSubsystem

	// Type is the actual event type (e.g. ingestion, flush, etc)
	Name EventName

	// Version is the version of the event (e.g. v1, v2, etc)
	Version EventVersion

	// SpecVersion is the version of the event spec (e.g. 1.0, 1.1, etc)
	SpecVersion EventSpecVersion
	// contains filtered or unexported fields
}

func (*EventTypeSpec) Type

func (s *EventTypeSpec) Type() string

type EventVersion

type EventVersion string

type ParsedCloudEvent

type ParsedCloudEvent[PayloadType CloudEventsPayload] struct {
	Event   event.Event
	Payload PayloadType
}

func ParseCloudEventFromBytes

func ParseCloudEventFromBytes[PayloadType CloudEventsPayload](data []byte) (*ParsedCloudEvent[PayloadType], error)

Jump to

Keyboard shortcuts

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