client

package
v1.3.97 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssureConfigFileExists added in v1.2.36

func AssureConfigFileExists() error

func LoadConfig added in v1.2.36

func LoadConfig()

func NewInterface added in v1.3.67

func NewInterface(client Client) api.Interface

func WriteConfig added in v1.2.36

func WriteConfig() error

Types

type ApplyInterface

type ApplyInterface interface {
	ApplyResource(ctx context.Context, resource *model.Resource, doMigration, forceMigration bool) error
}

type Client added in v1.1.48

type Client interface {
	ApplyInterface
	AuthenticateWithToken(token string)
	AuthenticateWithUsernameAndPassword(username string, password string) error
	NewRemoteExtension(host string, remoteHost string) Extension
	NewPollExtension() Extension
	UpdateTokenFromContext(ctx context.Context)

	// record
	CreateRecord(ctx context.Context, namespace string, resource string, record *model.Record) (*model.Record, error)
	UpdateRecord(ctx context.Context, namespace string, resource string, record *model.Record) (*model.Record, error)
	DeleteRecord(ctx context.Context, namespace string, name string, record *model.Record) error
	ApplyRecord(ctx context.Context, namespace string, resource string, record *model.Record) (*model.Record, error)
	GetRecord(ctx context.Context, namespace string, resource string, id string) (*model.Record, error)
	LoadRecord(ctx context.Context, namespace string, resource string, properties map[string]*structpb.Value, params service.RecordLoadParams) (*model.Record, error)
	ListRecords(ctx context.Context, params service.RecordListParams) ([]*model.Record, uint32, error)
	ListenRecords(ctx context.Context, namespace string, resource string, consumer func(records []*model.Record)) error

	// resource
	GetResourceByName(ctx context.Context, namespace string, resourceName string) (*model.Resource, error)
	ListResources(ctx context.Context) ([]*model.Resource, error)
	ReadRecordStream(ctx context.Context, params service.RecordListParams, recordsChan chan *model.Record) error
	DeleteResource(ctx context.Context, id string, doMigration bool, forceMigration bool) error
	CreateResource(ctx context.Context, resource *model.Resource, migration bool, force bool) error
	UpdateResource(ctx context.Context, resource *model.Resource, migration bool, force bool) error

	PollEvents(ctx context.Context, key string) (<-chan *model.Event, error)
	WriteEvent(ctx context.Context, key string, event *model.Event) error
}

func NewClientWithConfigServer added in v1.2.21

func NewClientWithConfigServer(configServer ServerConfig) (Client, error)

func NewClientWithParams added in v1.2.21

func NewClientWithParams(params Params) (Client, error)

func NewClientWithServerName added in v1.2.21

func NewClientWithServerName(serverName string) (Client, error)

func NewLocalClient added in v1.1.37

func NewLocalClient(container service.Container) Client

type Config added in v1.1.39

type Config struct {
	Type          string         `yaml:"type"`
	Servers       []ServerConfig `yaml:"servers"`
	DefaultServer string         `yaml:"defaultServer"`
}

func GetConfig added in v1.2.36

func GetConfig() *Config

type ConfigServerAuthentication added in v1.1.39

type ConfigServerAuthentication struct {
	Username string
	Password string
	Token    string
}

type Extension

type Extension interface {
	Run(ctx context.Context) error
	RegisterFunction(s string, f ExternalFunction)
	RegisterExtension(newExtension *resource_model.Extension)

	WithServiceKey(serviceKey string) Extension
	PrepareCall(*resource_model.Extension) resource_model.ExternalCall
	// contains filtered or unexported methods
}

type ExternalFunction

type ExternalFunction func(ctx context.Context, req *model.Event) (*model.Event, error)

type FindParams

type FindParams struct {
	Limit             uint32
	Offset            uint64
	UseHistory        bool
	Annotations       map[string]string
	ResolveReferences []string
	Filters           map[string]string
}

type Handler added in v1.1.37

type Handler[Entity interface{}] interface {
	Name(string) Handler[Entity]
	Before() Handler[Entity]
	PreProcess(RecordProcessFunc[Entity]) Handler[Entity]
	PostProcess(RecordProcessFunc[Entity]) Handler[Entity]
	Lambda(action string, processor LambdaProcessFunc[Entity]) Handler[Entity]
	Fire(ctx context.Context, action string, payload Entity) error
	After() Handler[Entity]
	Instead() Handler[Entity]
	Create(RecordProcessFunc[Entity]) Handler[Entity]
	Update(RecordProcessFunc[Entity]) Handler[Entity]
	Delete(RecordProcessFunc[Entity]) Handler[Entity]
}

func NewHandler added in v1.1.37

func NewHandler[Entity interface{}](dhClient Client, ext Extension, mapper abs.EntityMapper[Entity]) Handler[Entity]

type LambdaProcessFunc added in v1.1.37

type LambdaProcessFunc[Entity interface{}] func(ctx context.Context, event *model.Event, instance Entity) error

type Params added in v1.2.21

type Params struct {
	Addr     string
	Insecure bool
	Token    string
}

type RecordProcessFunc added in v1.1.37

type RecordProcessFunc[Entity interface{}] func(ctx context.Context, event *model.Event, instance Entity) (Entity, error)

type Repository

type Repository[Entity interface{}] interface {
	Mapper() abs.EntityMapper[Entity]
	Create(ctx context.Context, entity Entity) (Entity, error)
	Update(ctx context.Context, entity Entity) (Entity, error)
	Apply(ctx context.Context, entity Entity) (Entity, error)
	Get(ctx context.Context, id string) (Entity, error)
	Find(ctx context.Context, params FindParams) ([]Entity, uint32, error)
	Listen(ctx context.Context, consumer func(records []Entity)) error
}

func NewRepository

func NewRepository[Entity interface{}](client Client, mapper abs.EntityMapper[Entity]) Repository[Entity]

func R added in v1.1.37

func R[Entity interface{}](client Client, mapper abs.EntityMapper[Entity]) Repository[Entity]

type ServerConfig added in v1.2.21

type ServerConfig struct {
	Host           string
	Port           uint32 // GRPC and HTTP
	HttpPort       uint32 `yaml:"httpPort"` // If not specified, defaults to GRPC PORT
	Name           string
	Authentication *ConfigServerAuthentication
	Insecure       bool
}

func LocateConfigServer added in v1.2.36

func LocateConfigServer(server string) ServerConfig

func LocateServerByName added in v1.2.36

func LocateServerByName(serverName string) ServerConfig

Jump to

Keyboard shortcuts

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