datasource

package
v0.0.0-...-5edbee2 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 23 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	Lifecycle
	Subscribe(ctx context.Context, cfg SubscriptionEventConfiguration, updater SubscriptionEventUpdater) error
	Publish(ctx context.Context, cfg PublishEventConfiguration, events []StreamEvent) error
}

Adapter is the interface that the provider must implement to implement the basic functionality

type ArgumentTemplateCallback

type ArgumentTemplateCallback func(tpl string) (string, error)

type BeforeEventsDispatchFn

type BeforeEventsDispatchFn func(ctx context.Context, subConf SubscriptionEventConfiguration, eventBuilder EventBuilderFn, evts []StreamEvent) ([]StreamEvent, error)

type BeforeEventsDispatchHooks

type BeforeEventsDispatchHooks struct {
	Handlers []BeforeEventsDispatchFn
	Timeout  time.Duration
}

BeforeEventsDispatchHooks contains hooks that run once per received batch on the broadcast path

type EngineDataSourceFactory

type EngineDataSourceFactory interface {
	// GetFieldName get the field name where the data source is defined
	GetFieldName() string
	// ResolveDataSource returns the engine DataSource implementation that contains
	// methods which will be called by the Planner when resolving a field
	ResolveDataSource() (resolve.DataSource, error)
	// ResolveDataSourceInput build the input that will be passed to the engine DataSource
	ResolveDataSourceInput(event []byte) (string, error)
	// ResolveDataSourceSubscription returns the engine SubscriptionDataSource implementation
	// that contains methods to start a subscription, which will be called by the Planner
	// when a subscription is initiated
	ResolveDataSourceSubscription() (SubscriptionDataSource, error)
	// ResolveDataSourceSubscriptionInput build the input that will be passed to the engine SubscriptionDataSource
	ResolveDataSourceSubscriptionInput() (string, error)
	// TransformEventData allows the data source to transform the event data using the extractFn
	TransformEventData(extractFn ArgumentTemplateCallback) error
}

EngineDataSourceFactory is the interface that all pubsub data sources must implement. It serves three main purposes:

  1. Resolving the data source and subscription data source
  2. Generating the appropriate input for these data sources
  3. Providing access to the engine event configuration

For detailed implementation guidelines, see: https://github.com/wundergraph/cosmo/blob/main/router/pkg/pubsub/README.md

type Error

type Error struct {
	Internal  error
	PublicMsg string
}

func NewError

func NewError(publicMsg string, cause error) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type EventBuilderFn

type EventBuilderFn func(data []byte) MutableStreamEvent

type Hooks

type Hooks struct {
	SubscriptionOnCreate SubscriptionOnCreateHooks
	SubscriptionOnStart  SubscriptionOnStartHooks
	OnPublishEvents      OnPublishEventsHooks
	OnReceiveEvents      OnReceiveEventsHooks
	BeforeEventsDispatch BeforeEventsDispatchHooks
}

Hooks contains hooks for the pubsub providers and data sources

type Lifecycle

type Lifecycle interface {
	// Startup is the method called when the provider is started
	Startup(ctx context.Context) error
	// Shutdown is the method called when the provider is shut down
	Shutdown(ctx context.Context) error
}

Lifecycle is the interface that the provider must implement to allow the router to start and stop the provider

type MockEngineDataSourceFactory

type MockEngineDataSourceFactory struct {
	mock.Mock
}

MockEngineDataSourceFactory is an autogenerated mock type for the EngineDataSourceFactory type

func NewMockEngineDataSourceFactory

func NewMockEngineDataSourceFactory(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockEngineDataSourceFactory

NewMockEngineDataSourceFactory creates a new instance of MockEngineDataSourceFactory. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockEngineDataSourceFactory) EXPECT

func (*MockEngineDataSourceFactory) GetFieldName

func (_mock *MockEngineDataSourceFactory) GetFieldName() string

GetFieldName provides a mock function for the type MockEngineDataSourceFactory

func (*MockEngineDataSourceFactory) ResolveDataSource

func (_mock *MockEngineDataSourceFactory) ResolveDataSource() (resolve.DataSource, error)

ResolveDataSource provides a mock function for the type MockEngineDataSourceFactory

func (*MockEngineDataSourceFactory) ResolveDataSourceInput

func (_mock *MockEngineDataSourceFactory) ResolveDataSourceInput(event []byte) (string, error)

ResolveDataSourceInput provides a mock function for the type MockEngineDataSourceFactory

func (*MockEngineDataSourceFactory) ResolveDataSourceSubscription

func (_mock *MockEngineDataSourceFactory) ResolveDataSourceSubscription() (SubscriptionDataSource, error)

ResolveDataSourceSubscription provides a mock function for the type MockEngineDataSourceFactory

func (*MockEngineDataSourceFactory) ResolveDataSourceSubscriptionInput

func (_mock *MockEngineDataSourceFactory) ResolveDataSourceSubscriptionInput() (string, error)

ResolveDataSourceSubscriptionInput provides a mock function for the type MockEngineDataSourceFactory

func (*MockEngineDataSourceFactory) TransformEventData

func (_mock *MockEngineDataSourceFactory) TransformEventData(extractFn ArgumentTemplateCallback) error

TransformEventData provides a mock function for the type MockEngineDataSourceFactory

type MockEngineDataSourceFactory_Expecter

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

func (*MockEngineDataSourceFactory_Expecter) GetFieldName

GetFieldName is a helper method to define mock.On call

func (*MockEngineDataSourceFactory_Expecter) ResolveDataSource

ResolveDataSource is a helper method to define mock.On call

func (*MockEngineDataSourceFactory_Expecter) ResolveDataSourceInput

ResolveDataSourceInput is a helper method to define mock.On call

  • event []byte

func (*MockEngineDataSourceFactory_Expecter) ResolveDataSourceSubscription

ResolveDataSourceSubscription is a helper method to define mock.On call

func (*MockEngineDataSourceFactory_Expecter) ResolveDataSourceSubscriptionInput

ResolveDataSourceSubscriptionInput is a helper method to define mock.On call

func (*MockEngineDataSourceFactory_Expecter) TransformEventData

TransformEventData is a helper method to define mock.On call

  • extractFn ArgumentTemplateCallback

type MockEngineDataSourceFactory_GetFieldName_Call

type MockEngineDataSourceFactory_GetFieldName_Call struct {
	*mock.Call
}

MockEngineDataSourceFactory_GetFieldName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetFieldName'

func (*MockEngineDataSourceFactory_GetFieldName_Call) Return

func (*MockEngineDataSourceFactory_GetFieldName_Call) Run

func (*MockEngineDataSourceFactory_GetFieldName_Call) RunAndReturn

type MockEngineDataSourceFactory_ResolveDataSourceInput_Call

type MockEngineDataSourceFactory_ResolveDataSourceInput_Call struct {
	*mock.Call
}

MockEngineDataSourceFactory_ResolveDataSourceInput_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ResolveDataSourceInput'

func (*MockEngineDataSourceFactory_ResolveDataSourceInput_Call) Return

func (*MockEngineDataSourceFactory_ResolveDataSourceInput_Call) Run

func (*MockEngineDataSourceFactory_ResolveDataSourceInput_Call) RunAndReturn

type MockEngineDataSourceFactory_ResolveDataSourceSubscriptionInput_Call

type MockEngineDataSourceFactory_ResolveDataSourceSubscriptionInput_Call struct {
	*mock.Call
}

MockEngineDataSourceFactory_ResolveDataSourceSubscriptionInput_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ResolveDataSourceSubscriptionInput'

func (*MockEngineDataSourceFactory_ResolveDataSourceSubscriptionInput_Call) Return

func (*MockEngineDataSourceFactory_ResolveDataSourceSubscriptionInput_Call) Run

func (*MockEngineDataSourceFactory_ResolveDataSourceSubscriptionInput_Call) RunAndReturn

type MockEngineDataSourceFactory_ResolveDataSourceSubscription_Call

type MockEngineDataSourceFactory_ResolveDataSourceSubscription_Call struct {
	*mock.Call
}

MockEngineDataSourceFactory_ResolveDataSourceSubscription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ResolveDataSourceSubscription'

func (*MockEngineDataSourceFactory_ResolveDataSourceSubscription_Call) Return

func (*MockEngineDataSourceFactory_ResolveDataSourceSubscription_Call) Run

func (*MockEngineDataSourceFactory_ResolveDataSourceSubscription_Call) RunAndReturn

type MockEngineDataSourceFactory_ResolveDataSource_Call

type MockEngineDataSourceFactory_ResolveDataSource_Call struct {
	*mock.Call
}

MockEngineDataSourceFactory_ResolveDataSource_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ResolveDataSource'

func (*MockEngineDataSourceFactory_ResolveDataSource_Call) Return

func (*MockEngineDataSourceFactory_ResolveDataSource_Call) Run

func (*MockEngineDataSourceFactory_ResolveDataSource_Call) RunAndReturn

type MockEngineDataSourceFactory_TransformEventData_Call

type MockEngineDataSourceFactory_TransformEventData_Call struct {
	*mock.Call
}

MockEngineDataSourceFactory_TransformEventData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TransformEventData'

func (*MockEngineDataSourceFactory_TransformEventData_Call) Return

func (*MockEngineDataSourceFactory_TransformEventData_Call) Run

func (*MockEngineDataSourceFactory_TransformEventData_Call) RunAndReturn

type MockLifecycle

type MockLifecycle struct {
	mock.Mock
}

MockLifecycle is an autogenerated mock type for the Lifecycle type

func NewMockLifecycle

func NewMockLifecycle(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockLifecycle

NewMockLifecycle creates a new instance of MockLifecycle. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockLifecycle) EXPECT

func (_m *MockLifecycle) EXPECT() *MockLifecycle_Expecter

func (*MockLifecycle) Shutdown

func (_mock *MockLifecycle) Shutdown(ctx context.Context) error

Shutdown provides a mock function for the type MockLifecycle

func (*MockLifecycle) Startup

func (_mock *MockLifecycle) Startup(ctx context.Context) error

Startup provides a mock function for the type MockLifecycle

type MockLifecycle_Expecter

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

func (*MockLifecycle_Expecter) Shutdown

func (_e *MockLifecycle_Expecter) Shutdown(ctx interface{}) *MockLifecycle_Shutdown_Call

Shutdown is a helper method to define mock.On call

  • ctx context.Context

func (*MockLifecycle_Expecter) Startup

func (_e *MockLifecycle_Expecter) Startup(ctx interface{}) *MockLifecycle_Startup_Call

Startup is a helper method to define mock.On call

  • ctx context.Context

type MockLifecycle_Shutdown_Call

type MockLifecycle_Shutdown_Call struct {
	*mock.Call
}

MockLifecycle_Shutdown_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Shutdown'

func (*MockLifecycle_Shutdown_Call) Return

func (*MockLifecycle_Shutdown_Call) Run

func (*MockLifecycle_Shutdown_Call) RunAndReturn

type MockLifecycle_Startup_Call

type MockLifecycle_Startup_Call struct {
	*mock.Call
}

MockLifecycle_Startup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Startup'

func (*MockLifecycle_Startup_Call) Return

func (*MockLifecycle_Startup_Call) Run

func (*MockLifecycle_Startup_Call) RunAndReturn

type MockProvider

type MockProvider struct {
	mock.Mock
}

MockProvider is an autogenerated mock type for the Provider type

func NewMockProvider

func NewMockProvider(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockProvider

NewMockProvider creates a new instance of MockProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockProvider) EXPECT

func (_m *MockProvider) EXPECT() *MockProvider_Expecter

func (*MockProvider) ID

func (_mock *MockProvider) ID() string

ID provides a mock function for the type MockProvider

func (*MockProvider) Publish

func (_mock *MockProvider) Publish(ctx context.Context, cfg PublishEventConfiguration, events []StreamEvent) error

Publish provides a mock function for the type MockProvider

func (*MockProvider) SetHooks

func (_mock *MockProvider) SetHooks(hooks Hooks)

SetHooks provides a mock function for the type MockProvider

func (*MockProvider) Shutdown

func (_mock *MockProvider) Shutdown(ctx context.Context) error

Shutdown provides a mock function for the type MockProvider

func (*MockProvider) Startup

func (_mock *MockProvider) Startup(ctx context.Context) error

Startup provides a mock function for the type MockProvider

func (*MockProvider) Subscribe

Subscribe provides a mock function for the type MockProvider

func (*MockProvider) TypeID

func (_mock *MockProvider) TypeID() string

TypeID provides a mock function for the type MockProvider

type MockProviderBuilder

type MockProviderBuilder[P any, E any] struct {
	mock.Mock
}

MockProviderBuilder is an autogenerated mock type for the ProviderBuilder type

func NewMockProviderBuilder

func NewMockProviderBuilder[P any, E any](t interface {
	mock.TestingT
	Cleanup(func())
}) *MockProviderBuilder[P, E]

NewMockProviderBuilder creates a new instance of MockProviderBuilder. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockProviderBuilder[P, E]) BuildEngineDataSourceFactory

func (_mock *MockProviderBuilder[P, E]) BuildEngineDataSourceFactory(data E, providers map[string]Provider) (EngineDataSourceFactory, error)

BuildEngineDataSourceFactory provides a mock function for the type MockProviderBuilder

func (*MockProviderBuilder[P, E]) BuildProvider

func (_mock *MockProviderBuilder[P, E]) BuildProvider(options P, providerOpts ProviderOpts) (Provider, error)

BuildProvider provides a mock function for the type MockProviderBuilder

func (*MockProviderBuilder[P, E]) EXPECT

func (_m *MockProviderBuilder[P, E]) EXPECT() *MockProviderBuilder_Expecter[P, E]

func (*MockProviderBuilder[P, E]) TypeID

func (_mock *MockProviderBuilder[P, E]) TypeID() string

TypeID provides a mock function for the type MockProviderBuilder

type MockProviderBuilder_BuildEngineDataSourceFactory_Call

type MockProviderBuilder_BuildEngineDataSourceFactory_Call[P any, E any] struct {
	*mock.Call
}

MockProviderBuilder_BuildEngineDataSourceFactory_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BuildEngineDataSourceFactory'

func (*MockProviderBuilder_BuildEngineDataSourceFactory_Call[P, E]) Return

func (*MockProviderBuilder_BuildEngineDataSourceFactory_Call[P, E]) Run

func (*MockProviderBuilder_BuildEngineDataSourceFactory_Call[P, E]) RunAndReturn

type MockProviderBuilder_BuildProvider_Call

type MockProviderBuilder_BuildProvider_Call[P any, E any] struct {
	*mock.Call
}

MockProviderBuilder_BuildProvider_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BuildProvider'

func (*MockProviderBuilder_BuildProvider_Call[P, E]) Return

func (*MockProviderBuilder_BuildProvider_Call[P, E]) Run

func (_c *MockProviderBuilder_BuildProvider_Call[P, E]) Run(run func(options P, providerOpts ProviderOpts)) *MockProviderBuilder_BuildProvider_Call[P, E]

func (*MockProviderBuilder_BuildProvider_Call[P, E]) RunAndReturn

func (_c *MockProviderBuilder_BuildProvider_Call[P, E]) RunAndReturn(run func(options P, providerOpts ProviderOpts) (Provider, error)) *MockProviderBuilder_BuildProvider_Call[P, E]

type MockProviderBuilder_Expecter

type MockProviderBuilder_Expecter[P any, E any] struct {
	// contains filtered or unexported fields
}

func (*MockProviderBuilder_Expecter[P, E]) BuildEngineDataSourceFactory

func (_e *MockProviderBuilder_Expecter[P, E]) BuildEngineDataSourceFactory(data interface{}, providers interface{}) *MockProviderBuilder_BuildEngineDataSourceFactory_Call[P, E]

BuildEngineDataSourceFactory is a helper method to define mock.On call

  • data E
  • providers map[string]Provider

func (*MockProviderBuilder_Expecter[P, E]) BuildProvider

func (_e *MockProviderBuilder_Expecter[P, E]) BuildProvider(options interface{}, providerOpts interface{}) *MockProviderBuilder_BuildProvider_Call[P, E]

BuildProvider is a helper method to define mock.On call

  • options P
  • providerOpts ProviderOpts

func (*MockProviderBuilder_Expecter[P, E]) TypeID

TypeID is a helper method to define mock.On call

type MockProviderBuilder_TypeID_Call

type MockProviderBuilder_TypeID_Call[P any, E any] struct {
	*mock.Call
}

MockProviderBuilder_TypeID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TypeID'

func (*MockProviderBuilder_TypeID_Call[P, E]) Return

func (*MockProviderBuilder_TypeID_Call[P, E]) Run

func (_c *MockProviderBuilder_TypeID_Call[P, E]) Run(run func()) *MockProviderBuilder_TypeID_Call[P, E]

func (*MockProviderBuilder_TypeID_Call[P, E]) RunAndReturn

func (_c *MockProviderBuilder_TypeID_Call[P, E]) RunAndReturn(run func() string) *MockProviderBuilder_TypeID_Call[P, E]

type MockProvider_Expecter

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

func (*MockProvider_Expecter) ID

ID is a helper method to define mock.On call

func (*MockProvider_Expecter) Publish

func (_e *MockProvider_Expecter) Publish(ctx interface{}, cfg interface{}, events interface{}) *MockProvider_Publish_Call

Publish is a helper method to define mock.On call

  • ctx context.Context
  • cfg PublishEventConfiguration
  • events []StreamEvent

func (*MockProvider_Expecter) SetHooks

func (_e *MockProvider_Expecter) SetHooks(hooks interface{}) *MockProvider_SetHooks_Call

SetHooks is a helper method to define mock.On call

  • hooks Hooks

func (*MockProvider_Expecter) Shutdown

func (_e *MockProvider_Expecter) Shutdown(ctx interface{}) *MockProvider_Shutdown_Call

Shutdown is a helper method to define mock.On call

  • ctx context.Context

func (*MockProvider_Expecter) Startup

func (_e *MockProvider_Expecter) Startup(ctx interface{}) *MockProvider_Startup_Call

Startup is a helper method to define mock.On call

  • ctx context.Context

func (*MockProvider_Expecter) Subscribe

func (_e *MockProvider_Expecter) Subscribe(ctx interface{}, cfg interface{}, updater interface{}) *MockProvider_Subscribe_Call

Subscribe is a helper method to define mock.On call

  • ctx context.Context
  • cfg SubscriptionEventConfiguration
  • updater SubscriptionEventUpdater

func (*MockProvider_Expecter) TypeID

TypeID is a helper method to define mock.On call

type MockProvider_ID_Call

type MockProvider_ID_Call struct {
	*mock.Call
}

MockProvider_ID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ID'

func (*MockProvider_ID_Call) Return

func (*MockProvider_ID_Call) Run

func (_c *MockProvider_ID_Call) Run(run func()) *MockProvider_ID_Call

func (*MockProvider_ID_Call) RunAndReturn

func (_c *MockProvider_ID_Call) RunAndReturn(run func() string) *MockProvider_ID_Call

type MockProvider_Publish_Call

type MockProvider_Publish_Call struct {
	*mock.Call
}

MockProvider_Publish_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Publish'

func (*MockProvider_Publish_Call) Return

func (*MockProvider_Publish_Call) Run

func (*MockProvider_Publish_Call) RunAndReturn

type MockProvider_SetHooks_Call

type MockProvider_SetHooks_Call struct {
	*mock.Call
}

MockProvider_SetHooks_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetHooks'

func (*MockProvider_SetHooks_Call) Return

func (*MockProvider_SetHooks_Call) Run

func (*MockProvider_SetHooks_Call) RunAndReturn

func (_c *MockProvider_SetHooks_Call) RunAndReturn(run func(hooks Hooks)) *MockProvider_SetHooks_Call

type MockProvider_Shutdown_Call

type MockProvider_Shutdown_Call struct {
	*mock.Call
}

MockProvider_Shutdown_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Shutdown'

func (*MockProvider_Shutdown_Call) Return

func (*MockProvider_Shutdown_Call) Run

func (*MockProvider_Shutdown_Call) RunAndReturn

type MockProvider_Startup_Call

type MockProvider_Startup_Call struct {
	*mock.Call
}

MockProvider_Startup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Startup'

func (*MockProvider_Startup_Call) Return

func (*MockProvider_Startup_Call) Run

func (*MockProvider_Startup_Call) RunAndReturn

func (_c *MockProvider_Startup_Call) RunAndReturn(run func(ctx context.Context) error) *MockProvider_Startup_Call

type MockProvider_Subscribe_Call

type MockProvider_Subscribe_Call struct {
	*mock.Call
}

MockProvider_Subscribe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Subscribe'

func (*MockProvider_Subscribe_Call) Return

func (*MockProvider_Subscribe_Call) Run

func (*MockProvider_Subscribe_Call) RunAndReturn

type MockProvider_TypeID_Call

type MockProvider_TypeID_Call struct {
	*mock.Call
}

MockProvider_TypeID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TypeID'

func (*MockProvider_TypeID_Call) Return

func (*MockProvider_TypeID_Call) Run

func (*MockProvider_TypeID_Call) RunAndReturn

func (_c *MockProvider_TypeID_Call) RunAndReturn(run func() string) *MockProvider_TypeID_Call

type MockSubscriptionEventUpdater

type MockSubscriptionEventUpdater struct {
	mock.Mock
}

MockSubscriptionEventUpdater is an autogenerated mock type for the SubscriptionEventUpdater type

func NewMockSubscriptionEventUpdater

func NewMockSubscriptionEventUpdater(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockSubscriptionEventUpdater

NewMockSubscriptionEventUpdater creates a new instance of MockSubscriptionEventUpdater. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockSubscriptionEventUpdater) Complete

func (_mock *MockSubscriptionEventUpdater) Complete()

Complete provides a mock function for the type MockSubscriptionEventUpdater

func (*MockSubscriptionEventUpdater) Done

func (_mock *MockSubscriptionEventUpdater) Done()

Done provides a mock function for the type MockSubscriptionEventUpdater

func (*MockSubscriptionEventUpdater) EXPECT

func (*MockSubscriptionEventUpdater) SetHooks

func (_mock *MockSubscriptionEventUpdater) SetHooks(hooks Hooks)

SetHooks provides a mock function for the type MockSubscriptionEventUpdater

func (*MockSubscriptionEventUpdater) Update

func (_mock *MockSubscriptionEventUpdater) Update(events []StreamEvent)

Update provides a mock function for the type MockSubscriptionEventUpdater

type MockSubscriptionEventUpdater_Complete_Call

type MockSubscriptionEventUpdater_Complete_Call struct {
	*mock.Call
}

MockSubscriptionEventUpdater_Complete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Complete'

func (*MockSubscriptionEventUpdater_Complete_Call) Return

func (*MockSubscriptionEventUpdater_Complete_Call) Run

func (*MockSubscriptionEventUpdater_Complete_Call) RunAndReturn

type MockSubscriptionEventUpdater_Done_Call

type MockSubscriptionEventUpdater_Done_Call struct {
	*mock.Call
}

MockSubscriptionEventUpdater_Done_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Done'

func (*MockSubscriptionEventUpdater_Done_Call) Return

func (*MockSubscriptionEventUpdater_Done_Call) Run

func (*MockSubscriptionEventUpdater_Done_Call) RunAndReturn

type MockSubscriptionEventUpdater_Expecter

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

func (*MockSubscriptionEventUpdater_Expecter) Complete

Complete is a helper method to define mock.On call

func (*MockSubscriptionEventUpdater_Expecter) Done

Done is a helper method to define mock.On call

func (*MockSubscriptionEventUpdater_Expecter) SetHooks

SetHooks is a helper method to define mock.On call

  • hooks Hooks

func (*MockSubscriptionEventUpdater_Expecter) Update

Update is a helper method to define mock.On call

  • events []StreamEvent

type MockSubscriptionEventUpdater_SetHooks_Call

type MockSubscriptionEventUpdater_SetHooks_Call struct {
	*mock.Call
}

MockSubscriptionEventUpdater_SetHooks_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetHooks'

func (*MockSubscriptionEventUpdater_SetHooks_Call) Return

func (*MockSubscriptionEventUpdater_SetHooks_Call) Run

func (*MockSubscriptionEventUpdater_SetHooks_Call) RunAndReturn

type MockSubscriptionEventUpdater_Update_Call

type MockSubscriptionEventUpdater_Update_Call struct {
	*mock.Call
}

MockSubscriptionEventUpdater_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update'

func (*MockSubscriptionEventUpdater_Update_Call) Return

func (*MockSubscriptionEventUpdater_Update_Call) Run

func (*MockSubscriptionEventUpdater_Update_Call) RunAndReturn

type MockSubscriptionUpdater

type MockSubscriptionUpdater struct {
	mock.Mock
}

MockSubscriptionUpdater is an autogenerated mock type for the SubscriptionUpdater type

func NewMockSubscriptionUpdater

func NewMockSubscriptionUpdater(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockSubscriptionUpdater

NewMockSubscriptionUpdater creates a new instance of MockSubscriptionUpdater. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockSubscriptionUpdater) CloseSubscription

func (_mock *MockSubscriptionUpdater) CloseSubscription(id resolve.SubscriptionIdentifier)

CloseSubscription provides a mock function for the type MockSubscriptionUpdater

func (*MockSubscriptionUpdater) Complete

func (_mock *MockSubscriptionUpdater) Complete()

Complete provides a mock function for the type MockSubscriptionUpdater

func (*MockSubscriptionUpdater) Done

func (_mock *MockSubscriptionUpdater) Done()

Done provides a mock function for the type MockSubscriptionUpdater

func (*MockSubscriptionUpdater) EXPECT

func (*MockSubscriptionUpdater) Error

func (_mock *MockSubscriptionUpdater) Error(data []byte)

Error provides a mock function for the type MockSubscriptionUpdater

func (*MockSubscriptionUpdater) Subscriptions

Subscriptions provides a mock function for the type MockSubscriptionUpdater

func (*MockSubscriptionUpdater) Update

func (_mock *MockSubscriptionUpdater) Update(data []byte)

Update provides a mock function for the type MockSubscriptionUpdater

func (*MockSubscriptionUpdater) UpdateSubscription

func (_mock *MockSubscriptionUpdater) UpdateSubscription(id resolve.SubscriptionIdentifier, data []byte)

UpdateSubscription provides a mock function for the type MockSubscriptionUpdater

type MockSubscriptionUpdater_CloseSubscription_Call

type MockSubscriptionUpdater_CloseSubscription_Call struct {
	*mock.Call
}

MockSubscriptionUpdater_CloseSubscription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CloseSubscription'

func (*MockSubscriptionUpdater_CloseSubscription_Call) Return

func (*MockSubscriptionUpdater_CloseSubscription_Call) Run

func (*MockSubscriptionUpdater_CloseSubscription_Call) RunAndReturn

type MockSubscriptionUpdater_Complete_Call

type MockSubscriptionUpdater_Complete_Call struct {
	*mock.Call
}

MockSubscriptionUpdater_Complete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Complete'

func (*MockSubscriptionUpdater_Complete_Call) Return

func (*MockSubscriptionUpdater_Complete_Call) Run

func (*MockSubscriptionUpdater_Complete_Call) RunAndReturn

type MockSubscriptionUpdater_Done_Call

type MockSubscriptionUpdater_Done_Call struct {
	*mock.Call
}

MockSubscriptionUpdater_Done_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Done'

func (*MockSubscriptionUpdater_Done_Call) Return

func (*MockSubscriptionUpdater_Done_Call) Run

func (*MockSubscriptionUpdater_Done_Call) RunAndReturn

type MockSubscriptionUpdater_Error_Call

type MockSubscriptionUpdater_Error_Call struct {
	*mock.Call
}

MockSubscriptionUpdater_Error_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Error'

func (*MockSubscriptionUpdater_Error_Call) Return

func (*MockSubscriptionUpdater_Error_Call) Run

func (*MockSubscriptionUpdater_Error_Call) RunAndReturn

type MockSubscriptionUpdater_Expecter

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

func (*MockSubscriptionUpdater_Expecter) CloseSubscription

CloseSubscription is a helper method to define mock.On call

  • id resolve.SubscriptionIdentifier

func (*MockSubscriptionUpdater_Expecter) Complete

Complete is a helper method to define mock.On call

func (*MockSubscriptionUpdater_Expecter) Done

Done is a helper method to define mock.On call

func (*MockSubscriptionUpdater_Expecter) Error

Error is a helper method to define mock.On call

  • data []byte

func (*MockSubscriptionUpdater_Expecter) Subscriptions

Subscriptions is a helper method to define mock.On call

func (*MockSubscriptionUpdater_Expecter) Update

Update is a helper method to define mock.On call

  • data []byte

func (*MockSubscriptionUpdater_Expecter) UpdateSubscription

func (_e *MockSubscriptionUpdater_Expecter) UpdateSubscription(id interface{}, data interface{}) *MockSubscriptionUpdater_UpdateSubscription_Call

UpdateSubscription is a helper method to define mock.On call

  • id resolve.SubscriptionIdentifier
  • data []byte

type MockSubscriptionUpdater_Subscriptions_Call

type MockSubscriptionUpdater_Subscriptions_Call struct {
	*mock.Call
}

MockSubscriptionUpdater_Subscriptions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Subscriptions'

func (*MockSubscriptionUpdater_Subscriptions_Call) Return

func (*MockSubscriptionUpdater_Subscriptions_Call) Run

func (*MockSubscriptionUpdater_Subscriptions_Call) RunAndReturn

type MockSubscriptionUpdater_UpdateSubscription_Call

type MockSubscriptionUpdater_UpdateSubscription_Call struct {
	*mock.Call
}

MockSubscriptionUpdater_UpdateSubscription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateSubscription'

func (*MockSubscriptionUpdater_UpdateSubscription_Call) Return

func (*MockSubscriptionUpdater_UpdateSubscription_Call) Run

func (*MockSubscriptionUpdater_UpdateSubscription_Call) RunAndReturn

type MockSubscriptionUpdater_Update_Call

type MockSubscriptionUpdater_Update_Call struct {
	*mock.Call
}

MockSubscriptionUpdater_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update'

func (*MockSubscriptionUpdater_Update_Call) Return

func (*MockSubscriptionUpdater_Update_Call) Run

func (*MockSubscriptionUpdater_Update_Call) RunAndReturn

type MutableStreamEvent

type MutableStreamEvent interface {
	StreamEvent
	// SetData sets the data of the event.
	SetData([]byte)
}

A MutableStreamEvent is a stream event that can be modified.

type OnPublishEventsFn

type OnPublishEventsFn func(ctx context.Context, pubConf PublishEventConfiguration, evts []StreamEvent, eventBuilder EventBuilderFn) ([]StreamEvent, error)

type OnPublishEventsHooks

type OnPublishEventsHooks struct {
	Handlers []OnPublishEventsFn
}

OnPublishEventsHooks contains hooks with settings for event publishing

type OnReceiveEventsFn

type OnReceiveEventsFn func(subscriptionCtx context.Context, updaterCtx context.Context, subConf SubscriptionEventConfiguration, eventBuilder EventBuilderFn, evts []StreamEvent) ([]StreamEvent, error)

type OnReceiveEventsHooks

type OnReceiveEventsHooks struct {
	Handlers              []OnReceiveEventsFn
	MaxConcurrentHandlers int
	Timeout               time.Duration
}

OnReceiveEventsHooks contains hooks with settings for event receiving

type Planner

type Planner[PB ProviderBuilder[P, E], P any, E any] struct {
	// contains filtered or unexported fields
}

func (*Planner[PB, P, E]) ConfigureFetch

func (p *Planner[PB, P, E]) ConfigureFetch() resolve.FetchConfiguration

func (*Planner[PB, P, E]) ConfigureSubscription

func (p *Planner[PB, P, E]) ConfigureSubscription() plan.SubscriptionConfiguration

func (*Planner[PB, P, E]) DownstreamResponseFieldAlias

func (p *Planner[PB, P, E]) DownstreamResponseFieldAlias(downstreamFieldRef int) (alias string, exists bool)

func (*Planner[PB, P, E]) EnterDocument

func (p *Planner[PB, P, E]) EnterDocument(_, _ *ast.Document)

func (*Planner[PB, P, E]) EnterField

func (p *Planner[PB, P, E]) EnterField(ref int)

func (*Planner[PB, P, E]) ID

func (p *Planner[PB, P, E]) ID() (id int)

func (*Planner[PB, P, E]) Register

func (p *Planner[PB, P, E]) Register(visitor *plan.Visitor, configuration plan.DataSourceConfiguration[*PlannerConfig[PB, P, E]], _ plan.DataSourcePlannerConfiguration) error

func (*Planner[PB, P, E]) SetID

func (p *Planner[PB, P, E]) SetID(id int)

type PlannerConfig

type PlannerConfig[PB ProviderBuilder[P, E], P any, E any] struct {
	Providers       map[string]Provider
	ProviderBuilder PB
	Event           E
	Hooks           Hooks
}

func NewPlannerConfig

func NewPlannerConfig[PB ProviderBuilder[P, E], P any, E any](providerBuilder PB, event E, providers map[string]Provider, hooks Hooks) *PlannerConfig[PB, P, E]

type PlannerFactory

type PlannerFactory[PB ProviderBuilder[P, E], P any, E any] struct {
	// contains filtered or unexported fields
}

func NewPlannerFactory

func NewPlannerFactory[PB ProviderBuilder[P, E], P any, E any](ctx context.Context, config *PlannerConfig[PB, P, E]) *PlannerFactory[PB, P, E]

func (*PlannerFactory[PB, P, E]) Context

func (f *PlannerFactory[PB, P, E]) Context() context.Context

func (*PlannerFactory[PB, P, E]) Planner

func (f *PlannerFactory[PB, P, E]) Planner(_ abstractlogger.Logger) plan.DataSourcePlanner[*PlannerConfig[PB, P, E]]

func (*PlannerFactory[PB, P, E]) PlanningBehavior

func (f *PlannerFactory[PB, P, E]) PlanningBehavior() plan.DataSourcePlanningBehavior

func (*PlannerFactory[PB, P, E]) UpstreamSchema

func (f *PlannerFactory[PB, P, E]) UpstreamSchema(dataSourceConfig plan.DataSourceConfiguration[*PlannerConfig[PB, P, E]]) (*ast.Document, bool)

type Provider

type Provider interface {
	Adapter
	// ID Get the provider ID as specified in the configuration
	ID() string
	// TypeID Get the provider type id (e.g. "kafka", "nats")
	TypeID() string
	// SetHooks Set the hooks
	SetHooks(Hooks)
}

Provider is the interface that the PubSub provider must implement

type ProviderBuilder

type ProviderBuilder[P, E any] interface {
	// TypeID Get the provider type id (e.g. "kafka", "nats")
	TypeID() string
	// BuildProvider Build the provider and the adapter
	BuildProvider(options P, providerOpts ProviderOpts) (Provider, error)
	// BuildEngineDataSourceFactory Build the data source for the given provider and event configuration
	BuildEngineDataSourceFactory(data E, providers map[string]Provider) (EngineDataSourceFactory, error)
}

ProviderBuilder is the interface that the provider builder must implement.

type ProviderOpts

type ProviderOpts struct {
	StreamMetricStore metric.StreamMetricStore
	// SkipUnavailableProviders mirrors events.skip_unavailable_providers. When true the
	// adapter keeps a resilient, auto-reconnecting client even if the broker is unreachable
	// at startup. Startup still reports the connection error (so the router can log a
	// distinct "could not connect" message), but the provider recovers without a restart
	// once the broker becomes reachable again.
	SkipUnavailableProviders bool
}

type ProviderType

type ProviderType string

ProviderType represents the type of pubsub provider.

const (
	ProviderTypeNats  ProviderType = "nats"
	ProviderTypeKafka ProviderType = "kafka"
	ProviderTypeRedis ProviderType = "redis"
)

type PubSubProvider

type PubSubProvider struct {
	Adapter Adapter
	Logger  *zap.Logger
	// contains filtered or unexported fields
}

func NewPubSubProvider

func NewPubSubProvider(id string, typeID string, adapter Adapter, logger *zap.Logger, eventBuilder EventBuilderFn) *PubSubProvider

func (*PubSubProvider) ID

func (p *PubSubProvider) ID() string

func (*PubSubProvider) Publish

func (*PubSubProvider) SetHooks

func (p *PubSubProvider) SetHooks(hooks Hooks)

func (*PubSubProvider) Shutdown

func (p *PubSubProvider) Shutdown(ctx context.Context) error

func (*PubSubProvider) Startup

func (p *PubSubProvider) Startup(ctx context.Context) error

func (*PubSubProvider) Subscribe

func (*PubSubProvider) TypeID

func (p *PubSubProvider) TypeID() string

type PubSubSubscriptionDataSource

type PubSubSubscriptionDataSource[C SubscriptionEventConfiguration] struct {
	// contains filtered or unexported fields
}

PubSubSubscriptionDataSource is a data source for handling subscriptions using a Pub/Sub mechanism. It implements the SubscriptionDataSource and HookablePubsubDatasource interfaces.

func NewPubSubSubscriptionDataSource

func NewPubSubSubscriptionDataSource[C SubscriptionEventConfiguration](pubSub Adapter, triggerHashInputFn triggerHashInputFn, logger *zap.Logger, eventBuilder EventBuilderFn) *PubSubSubscriptionDataSource[C]

func (*PubSubSubscriptionDataSource[C]) HashTriggerInput

func (s *PubSubSubscriptionDataSource[C]) HashTriggerInput(input []byte, xxh *xxhash.Digest) error

func (*PubSubSubscriptionDataSource[C]) SetHooks

func (s *PubSubSubscriptionDataSource[C]) SetHooks(hooks Hooks)

func (*PubSubSubscriptionDataSource[C]) Start

func (s *PubSubSubscriptionDataSource[C]) Start(ctx *resolve.Context, header http.Header, input []byte, updater resolve.SubscriptionUpdater) error

func (*PubSubSubscriptionDataSource[C]) SubscriptionEventConfiguration

func (s *PubSubSubscriptionDataSource[C]) SubscriptionEventConfiguration(input []byte) (SubscriptionEventConfiguration, error)

func (*PubSubSubscriptionDataSource[C]) SubscriptionOnCreate

func (s *PubSubSubscriptionDataSource[C]) SubscriptionOnCreate(ctx context.Context, input []byte) (result []byte, err error)

func (*PubSubSubscriptionDataSource[C]) SubscriptionOnStart

func (s *PubSubSubscriptionDataSource[C]) SubscriptionOnStart(ctx resolve.StartupHookContext, input []byte) (err error)

type PublishEventConfiguration

type PublishEventConfiguration interface {
	ProviderID() string
	ProviderType() ProviderType
	RootFieldName() string // the root field name of the mutation in the schema
}

PublishEventConfiguration is the interface that all publish event configurations must implement

type StreamEvent

type StreamEvent interface {
	// GetData returns the payload data of the event.
	GetData() []byte
	// Clone returns a mutable copy of the event.
	Clone() MutableStreamEvent
}

A StreamEvent is a single event coming from or going to an event provider.

type StreamEvents

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

StreamEvents is a list of stream events coming from or going to event providers.

func NewStreamEvents

func NewStreamEvents(evts []StreamEvent) StreamEvents

func (StreamEvents) All

func (e StreamEvents) All() iter.Seq2[int, StreamEvent]

All is an iterator, which can be used to iterate through all events.

func (StreamEvents) Len

func (e StreamEvents) Len() int

Len returns the number of events.

func (StreamEvents) Unsafe

func (e StreamEvents) Unsafe() []StreamEvent

Unsafe returns the underlying slice of stream events. This slice is not thread safe and should not be modified directly.

type SubscriptionDataSource

type SubscriptionDataSource interface {
	SubscriptionEventConfiguration(input []byte) (SubscriptionEventConfiguration, error)
	Start(ctx *resolve.Context, header http.Header, input []byte, updater resolve.SubscriptionUpdater) error
	HashTriggerInput(input []byte, xxh *xxhash.Digest) error
	SetHooks(hooks Hooks)
}

type SubscriptionEventConfiguration

type SubscriptionEventConfiguration interface {
	ProviderID() string
	ProviderType() ProviderType
	RootFieldName() string // the root field name of the subscription in the schema
}

SubscriptionEventConfiguration is the interface that all subscription event configurations must implement

type SubscriptionEventUpdater

type SubscriptionEventUpdater interface {
	Update(events []StreamEvent)
	Complete()
	Done()
	SetHooks(hooks Hooks)
}

SubscriptionEventUpdater is a wrapper around the SubscriptionUpdater interface that provides a way to send the event struct instead of the raw data It is used to give access to the event additional fields to the hooks.

func NewSubscriptionEventUpdater

func NewSubscriptionEventUpdater(
	cfg SubscriptionEventConfiguration,
	hooks Hooks,
	eventUpdater resolve.SubscriptionUpdater,
	logger *zap.Logger,
	eventBuilder EventBuilderFn,
) SubscriptionEventUpdater

type SubscriptionOnCreateFn

type SubscriptionOnCreateFn func(ctx context.Context, subConf SubscriptionEventConfiguration) (SubscriptionEventConfiguration, error)

SubscriptionOnCreateFn is called before the subscription trigger is created. It receives the current subscription config and may return a modified one. Returning a non-nil error aborts the subscription.

type SubscriptionOnCreateHooks

type SubscriptionOnCreateHooks struct {
	Handlers []SubscriptionOnCreateFn
}

SubscriptionOnCreateHooks contains hooks that run before a subscription trigger is created

type SubscriptionOnStartFn

type SubscriptionOnStartFn func(ctx resolve.StartupHookContext, subConf SubscriptionEventConfiguration, eventBuilder EventBuilderFn) error

type SubscriptionOnStartHooks

type SubscriptionOnStartHooks struct {
	Handlers []SubscriptionOnStartFn
}

SubscriptionOnStartHooks contains hooks with settings for subscription starts

Jump to

Keyboard shortcuts

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