schemaeventsource

package
v0.440.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventSource

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

EventSource represents a stream of schema events and the materialised view of those events.

func New

func New(ctx context.Context, subscriptionID string, client ftlv1connect.SchemaServiceClient) EventSource

New creates a new EventSource that pulls schema changes from the SchemaService into an event channel and a materialised view (ie. schema.Schema).

The sync will terminate when the context is cancelled.

func NewUnattached

func NewUnattached() EventSource

NewUnattached creates a new EventSource that is not attached to a SchemaService.

func (*EventSource) ActiveChangeset added in v0.435.0

func (e *EventSource) ActiveChangeset() map[key.Changeset]*schema.Changeset

func (*EventSource) CanonicalView added in v0.435.0

func (e *EventSource) CanonicalView() *schema.Schema

CanonicalView is the materialised view of the schema from "Events".

func (*EventSource) Events

func (e *EventSource) Events() <-chan schema.Notification

Events is a stream of schema change events.

"View" will be updated with these changes prior to being sent on this channel.

NOTE: Only a single goroutine should read from the EventSource.

func (*EventSource) Live

func (e *EventSource) Live() bool

Live returns true if the EventSource is connected to the SchemaService.

func (*EventSource) Publish

func (e *EventSource) Publish(event schema.Notification) error

Publish an event to the EventSource.

This will update the materialised view and send the event on the "Events" channel. The event will be updated with the materialised view.

This is mostly useful in conjunction with NewUnattached, for testing.

func (*EventSource) PublishModuleForTest added in v0.439.0

func (e *EventSource) PublishModuleForTest(module *schema.Module) error

func (*EventSource) ViewOnly

func (e *EventSource) ViewOnly() *View

ViewOnly converts the EventSource into a read-only view of the schema.

This will consume all events so the EventSource doesn't block as the view is automatically updated.

func (*EventSource) WaitForInitialSync

func (e *EventSource) WaitForInitialSync(ctx context.Context) bool

WaitForInitialSync blocks until the initial sync has completed or the context is cancelled.

Returns true if the initial sync has completed, false if the context was cancelled.

type View

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

View is a read-only view of the schema.

func (*View) GetCanonical added in v0.435.0

func (v *View) GetCanonical() *schema.Schema

GetCanonical returns the current canonical schema (ie: without any changes applied from active changesets)

Jump to

Keyboard shortcuts

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