projections

package
v0.34.2 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2025 License: MIT Imports: 10 Imported by: 0

README

projections

Client implementation in go for the Freym service projections.

Docs

Please have a look at our documentation.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthData

type AuthData struct {
	TenantId string
	UserId   string
	Scopes   []string
	Data     map[string]any
}

type Data

type Data map[string]any

type DataList

type DataList struct {
	Limit int64
	Page  int64
	Total int64
	Data  []Data
}

type DeliveryClient

type DeliveryClient interface {
	GetData(
		ctx context.Context,
		projection string,
		authData *AuthData,
		id string,
		filter *Filter,
		returnEmptyDataIfNotFound bool,
		wait *Wait,
		useStrongConsistency bool,
		target deliverypb.DeploymentTarget,
	) (*Data, error)
	GetJsonData(
		ctx context.Context,
		projection string,
		authData *AuthData,
		id string,
		filter *JsonFilter,
		returnEmptyDataIfNotFound bool,
		wait *JsonWait,
		useStrongConsistency bool,
		target deliverypb.DeploymentTarget,
	) (*JsonData, error)
	GetViewData(
		ctx context.Context,
		view string,
		authData *AuthData,
		filter *Filter,
		useStrongConsistency bool,
		target deliverypb.DeploymentTarget,
	) (*Data, error)
	GetViewJsonData(
		ctx context.Context,
		view string,
		authData *AuthData,
		filter *JsonFilter,
		useStrongConsistency bool,
		target deliverypb.DeploymentTarget,
	) (*JsonData, error)
	GetDataList(
		ctx context.Context,
		projection string,
		authData *AuthData,
		pagination *Pagination,
		filter *Filter,
		order []Order,
		useStrongConsistency bool,
		target deliverypb.DeploymentTarget,
	) (*DataList, error)
	GetJsonDataList(
		ctx context.Context,
		projection string,
		authData *AuthData,
		pagination *Pagination,
		filter *JsonFilter,
		order []Order,
		useStrongConsistency bool,
		target deliverypb.DeploymentTarget,
	) (*JsonDataList, error)
	GetViewDataList(
		ctx context.Context,
		view string,
		authData *AuthData,
		pagination *Pagination,
		filter *Filter,
		order []Order,
		useStrongConsistency bool,
		target deliverypb.DeploymentTarget,
	) (*DataList, error)
	GetViewJsonDataList(
		ctx context.Context,
		view string,
		authData *AuthData,
		pagination *Pagination,
		filter *JsonFilter,
		order []Order,
		useStrongConsistency bool,
		target deliverypb.DeploymentTarget,
	) (*JsonDataList, error)
	UpsertData(
		ctx context.Context,
		projection string,
		authData *AuthData,
		id string,
		payload Data,
		eventMetadata *EventMetadata,
	) (*UpsertResponse, error)
	UpsertJsonData(
		ctx context.Context,
		projection string,
		authData *AuthData,
		id string,
		payload JsonData,
		eventMetadata *EventMetadata,
	) (*JsonUpsertResponse, error)
	DeleteDataById(
		ctx context.Context,
		projection string,
		authData *AuthData,
		id string,
		eventMetadata *EventMetadata,
	) (int64, error)
	DeleteDataByFilter(
		ctx context.Context,
		projection string,
		authData *AuthData,
		filter *Filter,
		eventMetadata *EventMetadata,
	) (int64, error)
	DeleteDataByJsonFilter(
		ctx context.Context,
		projection string,
		authData *AuthData,
		filter *JsonFilter,
		eventMetadata *EventMetadata,
	) (int64, error)
	Close() error
}

func NewDeliveryClient

func NewDeliveryClient(
	conf *config.Config,
) (DeliveryClient, error)

type DeploymentOptions

type DeploymentOptions struct {
	DangerouslyRemoveGdprFields bool
	Target                      managementpb.DeploymentTarget
	Force                       bool
}

type EnumType

type EnumType struct {
	Name   string
	Values []string
}

type EventMetadata

type EventMetadata struct {
	CorrelationId string
	CausationId   string
	Target        deliverypb.DeploymentTarget
}

type FieldFilter

type FieldFilter struct {
	Operation string
	Type      string
	Value     any
}

type FieldJsonFilter added in v0.33.0

type FieldJsonFilter struct {
	Operation string
	Type      string
	Value     string
}

type Filter

type Filter struct {
	// all these field filters have to match
	Fields map[string]FieldFilter
	// these filters will be calculated using the and operator
	And []Filter
	// these filters will be calculated using the or operator
	Or []Filter
}

type JsonData added in v0.33.0

type JsonData map[string]string

type JsonDataList added in v0.33.0

type JsonDataList struct {
	Limit int64
	Page  int64
	Total int64
	Data  []JsonData
}

type JsonFilter added in v0.33.0

type JsonFilter struct {
	// all these field filters have to match
	Fields map[string]FieldJsonFilter
	// these filters will be calculated using the and operator
	And []JsonFilter
	// these filters will be calculated using the or operator
	Or []JsonFilter
}

type JsonUpsertResponse added in v0.33.0

type JsonUpsertResponse struct {
	ValidationErrors      []string
	FieldValidationErrors map[string]string
	Data                  JsonData
	ID                    string
}

type JsonWait added in v0.33.0

type JsonWait struct {
	ConditionFilter  *JsonFilter
	ConditionTimeout time.Duration
}

type ManagementClient

type ManagementClient interface {
	DeploySchema(
		ctx context.Context,
		deploymentId int64,
		namespace string,
		projectionTypes []ObjectType,
		crudTypes []ObjectType,
		nestedTypes []ObjectType,
		enums []EnumType,
		views []View,
		options *DeploymentOptions,
	) error
	ActivateSchema(ctx context.Context, deploymentId int64) error
	ConfirmSchema(ctx context.Context, deploymentId int64) error
	RollbackSchema(ctx context.Context, namespace string, target managementpb.DeploymentTarget) error
	RollbackSchemaByDeployment(ctx context.Context, deploymentId int64) error
	GetSchemaDeployment(ctx context.Context, deploymentId int64) (uint32, error)
	Close() error
}

func NewManagementClient

func NewManagementClient(
	conf *config.Config,
) (ManagementClient, error)

type MockDeliveryClient

type MockDeliveryClient struct {
	mock.Mock
}

func (*MockDeliveryClient) Close

func (c *MockDeliveryClient) Close() error

func (*MockDeliveryClient) DeleteDataByFilter

func (c *MockDeliveryClient) DeleteDataByFilter(
	ctx context.Context,
	projection string,
	authData *AuthData,
	filter *Filter,
	eventMetadata *EventMetadata,
) (int64, error)

func (*MockDeliveryClient) DeleteDataById

func (c *MockDeliveryClient) DeleteDataById(
	ctx context.Context,
	projection string,
	authData *AuthData,
	id string,
	eventMetadata *EventMetadata,
) (int64, error)

func (*MockDeliveryClient) DeleteDataByJsonFilter added in v0.33.0

func (c *MockDeliveryClient) DeleteDataByJsonFilter(
	ctx context.Context,
	projection string,
	authData *AuthData,
	filter *JsonFilter,
	eventMetadata *EventMetadata,
) (int64, error)

func (*MockDeliveryClient) GetData

func (c *MockDeliveryClient) GetData(
	ctx context.Context,
	projection string,
	authData *AuthData,
	id string,
	filter *Filter,
	returnEmptyDataIfNotFound bool,
	wait *Wait,
	useStrongConsistency bool,
	target deliverypb.DeploymentTarget,
) (*Data, error)

func (*MockDeliveryClient) GetDataList

func (c *MockDeliveryClient) GetDataList(
	ctx context.Context,
	projection string,
	authData *AuthData,
	pagination *Pagination,
	filter *Filter,
	order []Order,
	useStrongConsistency bool,
	target deliverypb.DeploymentTarget,
) (*DataList, error)

func (*MockDeliveryClient) GetJsonData added in v0.33.0

func (c *MockDeliveryClient) GetJsonData(
	ctx context.Context,
	projection string,
	authData *AuthData,
	id string,
	filter *JsonFilter,
	returnEmptyDataIfNotFound bool,
	wait *JsonWait,
	useStrongConsistency bool,
	target deliverypb.DeploymentTarget,
) (*JsonData, error)

func (*MockDeliveryClient) GetJsonDataList added in v0.33.0

func (c *MockDeliveryClient) GetJsonDataList(
	ctx context.Context,
	projection string,
	authData *AuthData,
	pagination *Pagination,
	filter *JsonFilter,
	order []Order,
	useStrongConsistency bool,
	target deliverypb.DeploymentTarget,
) (*JsonDataList, error)

func (*MockDeliveryClient) GetViewData

func (c *MockDeliveryClient) GetViewData(
	ctx context.Context,
	view string,
	authData *AuthData,
	filter *Filter,
	useStrongConsistency bool,
	target deliverypb.DeploymentTarget,
) (*Data, error)

func (*MockDeliveryClient) GetViewDataList

func (c *MockDeliveryClient) GetViewDataList(
	ctx context.Context,
	view string,
	authData *AuthData,
	pagination *Pagination,
	filter *Filter,
	order []Order,
	useStrongConsistency bool,
	target deliverypb.DeploymentTarget,
) (*DataList, error)

func (*MockDeliveryClient) GetViewJsonData added in v0.33.0

func (c *MockDeliveryClient) GetViewJsonData(
	ctx context.Context,
	view string,
	authData *AuthData,
	filter *JsonFilter,
	useStrongConsistency bool,
	target deliverypb.DeploymentTarget,
) (*JsonData, error)

func (*MockDeliveryClient) GetViewJsonDataList added in v0.33.0

func (c *MockDeliveryClient) GetViewJsonDataList(
	ctx context.Context,
	view string,
	authData *AuthData,
	pagination *Pagination,
	filter *JsonFilter,
	order []Order,
	useStrongConsistency bool,
	target deliverypb.DeploymentTarget,
) (*JsonDataList, error)

func (*MockDeliveryClient) UpsertData

func (c *MockDeliveryClient) UpsertData(
	ctx context.Context,
	projection string,
	authData *AuthData,
	id string,
	payload Data,
	eventMetadata *EventMetadata,
) (*UpsertResponse, error)

func (*MockDeliveryClient) UpsertJsonData added in v0.33.0

func (c *MockDeliveryClient) UpsertJsonData(
	ctx context.Context,
	projection string,
	authData *AuthData,
	id string,
	payload JsonData,
	eventMetadata *EventMetadata,
) (*JsonUpsertResponse, error)

type MockManagementClient

type MockManagementClient struct {
	mock.Mock
}

func (*MockManagementClient) ActivateSchema added in v0.31.7

func (c *MockManagementClient) ActivateSchema(ctx context.Context, deploymentId int64) error

func (*MockManagementClient) Close

func (c *MockManagementClient) Close() error

func (*MockManagementClient) ConfirmSchema

func (c *MockManagementClient) ConfirmSchema(ctx context.Context, deploymentId int64) error

func (*MockManagementClient) DeploySchema

func (c *MockManagementClient) DeploySchema(
	ctx context.Context,
	deploymentId int64,
	namespace string,
	projectionTypes []ObjectType,
	crudTypes []ObjectType,
	nestedTypes []ObjectType,
	enums []EnumType,
	views []View,
	options *DeploymentOptions,
) error

func (*MockManagementClient) GetSchemaDeployment

func (c *MockManagementClient) GetSchemaDeployment(ctx context.Context, deploymentId int64) (uint32, error)

func (*MockManagementClient) RollbackSchema

func (c *MockManagementClient) RollbackSchema(ctx context.Context, namespace string, target managementpb.DeploymentTarget) error

func (*MockManagementClient) RollbackSchemaByDeployment added in v0.31.8

func (c *MockManagementClient) RollbackSchemaByDeployment(ctx context.Context, deploymentId int64) error

type ObjectType

type ObjectType struct {
	Name       string
	Directives []TypeDirective
	Fields     []TypeField
}

type Order

type Order struct {
	Field      string
	Descending bool
}

type Pagination

type Pagination struct {
	Limit int64
	Page  int64
}

type TypeArgument

type TypeArgument struct {
	Name  string
	Value any
}

type TypeDirective

type TypeDirective struct {
	Name      string
	Arguments []TypeArgument
}

type TypeField

type TypeField struct {
	Name       string
	Type       []string
	Directives []TypeDirective
}

type UpsertResponse

type UpsertResponse struct {
	ValidationErrors      []string
	FieldValidationErrors map[string]string
	Data                  Data
	ID                    string
}

type View

type View struct {
	Name       string
	Sql        string
	Directives []TypeDirective
	Fields     []TypeField
}

type Wait

type Wait struct {
	ConditionFilter  *Filter
	ConditionTimeout time.Duration
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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