models

package
v0.1.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DeliveryStatusOK     = "ok"
	DeliveryStatusFailed = "failed"
)
View Source
const MAX_DESTINATIONS_PER_TENANT = 100

TODO: get this from config

Variables

View Source
var (
	ErrInvalidTopics       = errors.New("validation failed: invalid topics")
	ErrInvalidTopicsFormat = errors.New("validation failed: invalid topics format")
)
View Source
var (
	ErrDuplicateDestination = errors.New("destination already exists")
)

Functions

func NewErrDestinationValidation

func NewErrDestinationValidation(err error) error

Types

type AESCipher

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

func (*AESCipher) Decrypt

func (a *AESCipher) Decrypt(toBeDecrypted []byte) ([]byte, error)

func (*AESCipher) Encrypt

func (a *AESCipher) Encrypt(toBeEncrypted []byte) ([]byte, error)

type Cipher

type Cipher interface {
	Encrypt(data []byte) ([]byte, error)
	Decrypt(data []byte) ([]byte, error)
}

func NewAESCipher

func NewAESCipher(secret string) Cipher

type Config

type Config map[string]string

func (*Config) MarshalBinary

func (c *Config) MarshalBinary() ([]byte, error)

func (*Config) UnmarshalBinary

func (c *Config) UnmarshalBinary(data []byte) error

type Credentials

type Credentials map[string]string

func (*Credentials) MarshalBinary

func (c *Credentials) MarshalBinary() ([]byte, error)

func (*Credentials) UnmarshalBinary

func (c *Credentials) UnmarshalBinary(data []byte) error

type Data

type Data map[string]interface{}

func (*Data) String

func (d *Data) String() string

func (*Data) UnmarshalBinary

func (d *Data) UnmarshalBinary(data []byte) error

type Delivery

type Delivery struct {
	ID              string    `json:"id"`
	DeliveryEventID string    `json:"delivery_event_id"`
	EventID         string    `json:"event_id"`
	DestinationID   string    `json:"destination_id"`
	Status          string    `json:"status"`
	Time            time.Time `json:"time"`
}

type DeliveryEvent

type DeliveryEvent struct {
	ID            string
	Attempt       int
	DestinationID string
	Event         Event
	Delivery      *Delivery
	Telemetry     *DeliveryEventTelemetry
}

func NewDeliveryEvent

func NewDeliveryEvent(event Event, destinationID string) DeliveryEvent

func (*DeliveryEvent) FromMessage

func (e *DeliveryEvent) FromMessage(msg *mqs.Message) error

func (*DeliveryEvent) ToMessage

func (e *DeliveryEvent) ToMessage() (*mqs.Message, error)

type DeliveryEventTelemetry

type DeliveryEventTelemetry struct {
	TraceID string
	SpanID  string
}

type Destination

type Destination struct {
	ID          string      `json:"id" redis:"id"`
	Type        string      `json:"type" redis:"type"`
	Topics      Topics      `json:"topics" redis:"-"`
	Config      Config      `json:"config" redis:"-"`
	Credentials Credentials `json:"credentials" redis:"-"`
	CreatedAt   time.Time   `json:"created_at" redis:"created_at"`
	DisabledAt  *time.Time  `json:"disabled_at" redis:"disabled_at"`
	TenantID    string      `json:"-" redis:"-"`
}

func (*Destination) Publish

func (d *Destination) Publish(ctx context.Context, event *Event) error

func (*Destination) ToSummary

func (d *Destination) ToSummary() *DestinationSummary

func (*Destination) Validate

func (d *Destination) Validate(ctx context.Context) error

type DestinationFilter

type DestinationFilter struct {
	Type   []string
	Topics []string
}

type DestinationPublishError

type DestinationPublishError struct {
	Err error
}

func (*DestinationPublishError) Error

func (e *DestinationPublishError) Error() string

type DestinationSummary

type DestinationSummary struct {
	ID       string `json:"id"`
	Type     string `json:"type"`
	Topics   Topics `json:"topics"`
	Disabled bool   `json:"disabled"`
}

func (*DestinationSummary) MarshalBinary

func (ds *DestinationSummary) MarshalBinary() ([]byte, error)

func (*DestinationSummary) UnmarshalBinary

func (ds *DestinationSummary) UnmarshalBinary(data []byte) error

type EntityStore

type EntityStore interface {
	RetrieveTenant(ctx context.Context, tenantID string) (*Tenant, error)
	UpsertTenant(ctx context.Context, tenant Tenant) error
	DeleteTenant(ctx context.Context, tenantID string) error
	ListDestinationByTenant(ctx context.Context, tenantID string, options ...ListDestinationByTenantOpts) ([]Destination, error)
	RetrieveDestination(ctx context.Context, tenantID, destinationID string) (*Destination, error)
	CreateDestination(ctx context.Context, destination Destination) error
	UpsertDestination(ctx context.Context, destination Destination) error
	DeleteDestination(ctx context.Context, tenantID, destinationID string) error
	MatchEvent(ctx context.Context, event Event) ([]DestinationSummary, error)
}

func NewEntityStore

func NewEntityStore(redisClient *redis.Client, cipher Cipher, availableTopics []string) EntityStore

type Event

type Event struct {
	ID               string          `json:"id"`
	TenantID         string          `json:"tenant_id"`
	DestinationID    string          `json:"destination_id"`
	Topic            string          `json:"topic"`
	EligibleForRetry bool            `json:"eligible_for_retry"`
	Time             time.Time       `json:"time"`
	Metadata         Metadata        `json:"metadata"`
	Data             Data            `json:"data"`
	Telemetry        *EventTelemetry `json:"-"`
}

func (*Event) FromMessage

func (e *Event) FromMessage(msg *mqs.Message) error

func (*Event) ToAdapterEvent

func (e *Event) ToAdapterEvent() *adapters.Event

func (*Event) ToMessage

func (e *Event) ToMessage() (*mqs.Message, error)

type EventTelemetry

type EventTelemetry struct {
	TraceID      string
	SpanID       string
	ReceivedTime string // format time.RFC3339Nano
}

type ListDeliveryRequest

type ListDeliveryRequest struct {
	EventID string
}

type ListDestinationByTenantOpts

type ListDestinationByTenantOpts struct {
	Filter *DestinationFilter
}

func WithDestinationFilter

func WithDestinationFilter(filter DestinationFilter) ListDestinationByTenantOpts

type ListEventRequest

type ListEventRequest struct {
	TenantID string
	Cursor   string
	Limit    int
}

type LogStore

type LogStore interface {
	ListEvent(context.Context, ListEventRequest) ([]*Event, string, error)
	RetrieveEvent(ctx context.Context, tenantID, eventID string) (*Event, error)
	ListDelivery(ctx context.Context, request ListDeliveryRequest) ([]*Delivery, error)
	InsertManyEvent(context.Context, []*Event) error
	InsertManyDelivery(context.Context, []*Delivery) error
}

func NewLogStore

func NewLogStore(chDB clickhouse.DB) LogStore

type Metadata

type Metadata map[string]string

func (*Metadata) String

func (m *Metadata) String() string

func (*Metadata) UnmarshalBinary

func (m *Metadata) UnmarshalBinary(metadata []byte) error

type Tenant

type Tenant struct {
	ID                string    `json:"id" redis:"id"`
	DestinationsCount int       `json:"destinations_count" redis:"-"`
	Topics            []string  `json:"topics" redis:"-"`
	CreatedAt         time.Time `json:"created_at" redis:"created_at"`
}

type Topics

type Topics []string

func TopicsFromString

func TopicsFromString(s string) Topics

func (*Topics) MarshalBinary

func (t *Topics) MarshalBinary() ([]byte, error)

func (*Topics) MarshalJSON

func (t *Topics) MarshalJSON() ([]byte, error)

func (*Topics) MatchesAll

func (t *Topics) MatchesAll() bool

func (*Topics) UnmarshalBinary

func (t *Topics) UnmarshalBinary(data []byte) error

func (*Topics) UnmarshalJSON

func (t *Topics) UnmarshalJSON(data []byte) error

func (*Topics) Validate

func (t *Topics) Validate(availableTopics []string) error

Jump to

Keyboard shortcuts

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