sinks

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2022 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const MetadataLabelOtel = "opentelemetry"

Variables

View Source
var (
	// ErrMalformedEntity indicates malformed entity specification (e.g.
	// invalid username or password).
	ErrMalformedEntity = errors.New("malformed entity specification")

	// ErrNotFound indicates a non-existent entity request.
	ErrNotFound = errors.New("non-existent entity")

	// ErrConflict indicates that entity already exists.
	ErrConflict = errors.New("entity already exists")

	// ErrScanMetadata indicates problem with metadata in db
	ErrScanMetadata = errors.New("failed to scan metadata in db")

	// ErrSelectEntity indicates error while reading entity from database
	ErrSelectEntity = errors.New("select entity from db error")

	// ErrEntityConnected indicates error while checking connection in database
	ErrEntityConnected = errors.New("check connection in database error")

	// ErrUpdateEntity indicates error while updating a entity
	ErrUpdateEntity = errors.New("failed to update entity")

	ErrUnauthorizedAccess = errors.New("missing or invalid credentials provided")

	ErrRemoveEntity = errors.New("failed to remove entity")

	ErrInvalidBackend = errors.New("No available backends")
)
View Source
var (
	ErrCreateSink                 = errors.New("failed to create Sink")
	ErrConflictSink               = errors.New("entity already exists")
	ErrUnsupportedContentTypeSink = errors.New("unsupported content type")
	ErrValidateSink               = errors.New("failed to validate Sink")
)

Functions

func NewPasswordService

func NewPasswordService(logger *zap.Logger, key string) *passwordService

Types

type Filter

type Filter struct {
	StateFilter   string
	OpenTelemetry string
}

type Page

type Page struct {
	PageMetadata
	Sinks []Sink
}

Page contains page related metadata as well as list of sinks that belong to this page

type PageMetadata

type PageMetadata struct {
	Total    uint64
	Offset   uint64         `json:"offset,omitempty"`
	Limit    uint64         `json:"limit,omitempty"`
	Name     string         `json:"name,omitempty"`
	Order    string         `json:"order,omitempty"`
	Dir      string         `json:"dir,omitempty"`
	Metadata types.Metadata `json:"metadata,omitempty"`
	Tags     types.Tags     `json:"tags,omitempty"`
}

PageMetadata contains page metadata that helps navigation

type PasswordService

type PasswordService interface {
	EncodePassword(plainText string) (string, error)
	SetKey(newKey string)
	DecodePassword(cipheredText string) (string, error)
}

type Sink

type Sink struct {
	ID          string
	Name        types.Identifier
	MFOwnerID   string
	Description string
	Backend     string
	Config      types.Metadata
	Tags        types.Tags
	State       State
	Error       string
	Created     time.Time
}

type SinkRepository

type SinkRepository interface {
	// Save persists the Sink. Successful operation is indicated by non-nil error response.
	Save(ctx context.Context, sink Sink) (string, error)
	// Update performs an update to the existing sink, A non-nil error is
	// returned to indicate operation failure
	Update(ctx context.Context, sink Sink) error
	// RetrieveAllByOwnerID retrieves Sinks by OwnerID
	RetrieveAllByOwnerID(ctx context.Context, owner string, pm PageMetadata) (Page, error)
	// SearchAllSinks search Sinks for internal usage like services
	SearchAllSinks(ctx context.Context, filter Filter) ([]Sink, error)
	// RetrieveById retrieves a Sink by ID
	RetrieveById(ctx context.Context, key string) (Sink, error)
	// RetrieveByOwnerAndId retrieves a By OwnerId And SinkId
	RetrieveByOwnerAndId(ctx context.Context, ownerID string, key string) (Sink, error)
	// Remove an existing Sink by id
	Remove(ctx context.Context, owner string, key string) error
	// UpdateSinkState updates sink state like active, idle, new, unknown
	UpdateSinkState(ctx context.Context, sinkID string, msg string, ownerID string, state State) error
}

type SinkService

type SinkService interface {
	// CreateSink creates new data sink
	CreateSink(ctx context.Context, token string, s Sink) (Sink, error)
	// UpdateSink by id
	UpdateSink(ctx context.Context, token string, s Sink) (Sink, error)
	// ListSinks retrieves data about sinks
	ListSinks(ctx context.Context, token string, pm PageMetadata) (Page, error)
	// ListSinksInternal retrieves data from sinks filtered by SinksFilter for Services like Maestro, to build DeploymentEntries
	ListSinksInternal(ctx context.Context, filter Filter) ([]Sink, error)
	// ListBackends retrieves a list of available backends
	ListBackends(ctx context.Context, token string) ([]string, error)
	// ViewBackend retrieves a backend by the name
	ViewBackend(ctx context.Context, token string, key string) (backend.Backend, error)
	// ViewSink retrieves a sink by id, for View, does not send password
	ViewSink(ctx context.Context, token string, key string) (Sink, error)
	// ViewSinkInternal retrieves a sink by id, via GRPC, sends password
	ViewSinkInternal(ctx context.Context, ownerID string, key string) (Sink, error)
	// DeleteSink delete a existing sink by id
	DeleteSink(ctx context.Context, token string, key string) error
	// ValidateSink validate a sink configuration without saving
	ValidateSink(ctx context.Context, token string, sink Sink) (Sink, error)
	// ChangeSinkStateInternal change the sink internal state from new/idle/active
	ChangeSinkStateInternal(ctx context.Context, sinkID string, msg string, ownerID string, state State) error
}

SinkService Sink CRUD interface

func NewSinkService

func NewSinkService(logger *zap.Logger, auth mainflux.AuthServiceClient, sinkRepo SinkRepository, mfsdk mfsdk.SDK, services PasswordService) SinkService

type State

type State int
const (
	Unknown State = iota
	Active
	Error
	Idle
)

func (*State) Scan

func (s *State) Scan(value interface{}) error

func (State) String

func (s State) String() string

func (State) Value

func (s State) Value() (driver.Value, error)

Directories

Path Synopsis
api
Package postgres contains repository implementations using PostgreSQL as the underlying database.
Package postgres contains repository implementations using PostgreSQL as the underlying database.
redis
consumer
Package esconsumer contains events esconsumer for events
Package esconsumer contains events esconsumer for events
producer
Package producer contains the domain events needed to support event sourcing of Sink service actions.
Package producer contains the domain events needed to support event sourcing of Sink service actions.

Jump to

Keyboard shortcuts

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