pool

package
v0.0.0-...-8122643 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeDatabase  string = "database"
	TypeApiServer string = "api_server"
	TypePubsub    string = "pubsub"
)
View Source
const ErrorCodeCreateServiceDatabaseFailed = "create_service_database_failed"
View Source
const ErrorCodeInvalidServiceConfiguration = "invalid_service_configuration"
View Source
const ErrorCodeNoServiceWithRole = "no_service_with_role"
View Source
const ErrorCodePoolNameConflict = "pool_name_conflict"
View Source
const ErrorCodePoolNotActive = "pool_not_active"
View Source
const ErrorCodePoolNotFound = "pool_not_found"
View Source
const ErrorCodePoolServiceBindingsExist = "pool_service_bindings_exist"
View Source
const ErrorCodePoolServiceBoundToPool = "service_bound_to_pool"
View Source
const ErrorCodeServiceInitializationFailed = "service_initialization_failed"
View Source
const ErrorCodeServiceNameConflict = "service_name_conflict"
View Source
const ErrorCodeServiceNotActive = "service_not_active"
View Source
const ErrorCodeServiceNotFound = "service_not_found"
View Source
const ErrorCodeServiceRoleConflict = "service_role_conflict"

Variables

View Source
var ErrorDescriptions = map[string]string{
	ErrorCodePoolNotFound:                "Pool not found",
	ErrorCodeServiceNotFound:             "Service not found",
	ErrorCodePoolNameConflict:            "Pool with such name already exists, choose another name",
	ErrorCodeServiceNameConflict:         "Service with such name already exists, choose another name",
	ErrorCodeServiceRoleConflict:         "Pool already has service for that role",
	ErrorCodePoolServiceBindingsExist:    "Can't delete pool with services. First, remove all services from the pool",
	ErrorCodePoolServiceBoundToPool:      "Can't delete service bound to pool. First, remove the services from all pools",
	ErrorCodeNoServiceWithRole:           "Pool does not include service with requested role",
	ErrorCodeInvalidServiceConfiguration: "Invalid configuration of service in the pool",
	ErrorCodeServiceInitializationFailed: "Failed to connect to service",
	ErrorCodeServiceNotActive:            "Service not active. First, activate corresponsing service",
	ErrorCodePoolNotActive:               "Pool not active. First, activate corresponsing pool",
	ErrorCodeCreateServiceDatabaseFailed: "Failed to create database for pool service",
}

Functions

func CheckIfActivate

func CheckIfActivate(fields db.Fields) (bool, string, bool)

func ConnectDatabaseService

func ConnectDatabaseService(ctx op_context.Context, pool Pool, role string, dbName string, newDb ...bool) (db.DB, error)

func DbModels

func DbModels() []interface{}

func ParseDbService

func ParseDbService(service *PoolServiceBaseData) (*db.DBConfig, error)

func QueryDbModels

func QueryDbModels() []interface{}

func SelfPoolId

func SelfPoolId(store PoolStore) string

func SelfPoolName

func SelfPoolName(store PoolStore) string

Types

type OpLogPool

type OpLogPool struct {
	oplog.OplogBase
	PoolName    string `gorm:"index" json:"pool_name"`
	PoolId      string `gorm:"index" json:"pool_id"`
	ServiceName string `gorm:"index" json:"service_name"`
	ServiceId   string `gorm:"index" json:"service_id"`
	Role        string `gorm:"index" json:"role"`
}

type Pool

func ActivatePool

func ActivatePool(ctrl PoolController, ctx op_context.Context, id string, idIsName ...bool) (Pool, error)

func DeactivatePool

func DeactivatePool(ctrl PoolController, ctx op_context.Context, id string, idIsName ...bool) (Pool, error)

func FindPool

func FindPool(store PoolStore, id string) (Pool, error)

func LoadPool

func LoadPool(ctrl PoolController, ctx op_context.Context, id string, idIsName ...bool) (Pool, error)

type PoolBase

type PoolBase struct {
	PoolBaseEssentials
	Services map[string]*PoolServiceBinding `gorm:"-:all" json:"-"`
}

func NewPool

func NewPool() *PoolBase

func (*PoolBase) Service

func (p *PoolBase) Service(role string) (*PoolServiceBinding, error)

func (*PoolBase) ServiceByName

func (p *PoolBase) ServiceByName(name string) (*PoolServiceBinding, error)

func (*PoolBase) SetServices

func (p *PoolBase) SetServices(services []*PoolServiceBinding)

func (PoolBase) TableName

func (PoolBase) TableName() string

type PoolBaseData

func (*PoolBaseData) Fill

func (p *PoolBaseData) Fill(pool Pool)

type PoolBaseEssentials

type PoolBaseEssentials struct {
	common.ObjectBase
	PoolBaseData
}

type PoolBindingPoolFields

type PoolBindingPoolFields struct {
	common.IDBase
	common.WithUniqueNameBase
}

type PoolBindingServiceFields

type PoolBindingServiceFields struct {
	common.IDBase
	PoolServiceBaseEssentials
}

type PoolController

type PoolController interface {
	AddPool(ctx op_context.Context, pool Pool) (Pool, error)
	FindPool(ctx op_context.Context, id string, idIsName ...bool) (Pool, error)
	UpdatePool(ctx op_context.Context, id string, fields db.Fields, idIsName ...bool) (Pool, error)
	DeletePool(ctx op_context.Context, id string, idIsName ...bool) error
	GetPools(ctx op_context.Context, filter *db.Filter) ([]*PoolBase, int64, error)

	AddService(ctx op_context.Context, service PoolService) (PoolService, error)
	FindService(ctx op_context.Context, id string, idIsName ...bool) (PoolService, error)
	UpdateService(ctx op_context.Context, id string, fields db.Fields, idIsName ...bool) (PoolService, error)
	DeleteService(ctx op_context.Context, id string, idIsName ...bool) error
	GetServices(ctx op_context.Context, filter *db.Filter) ([]*PoolServiceBase, int64, error)

	AddServiceToPool(ctx op_context.Context, poolId string, serviceId string, role string, idIsName ...bool) error
	RemoveServiceFromPool(ctx op_context.Context, poolId string, role string, idIsName ...bool) error
	RemoveAllServicesFromPool(ctx op_context.Context, poolId string, idIsName ...bool) error
	RemoveServiceFromAllPools(ctx op_context.Context, id string, idIsName ...bool) error

	GetPoolBindings(ctx op_context.Context, id string, idIsName ...bool) ([]*PoolServiceBinding, error)
	GetServiceBindings(ctx op_context.Context, id string, idIsName ...bool) ([]*PoolServiceBinding, error)
}

type PoolControllerBase

type PoolControllerBase struct {
	CRUD crud.CRUD
}

func NewPoolController

func NewPoolController(crud crud.CRUD) *PoolControllerBase

func (*PoolControllerBase) AddPool

func (m *PoolControllerBase) AddPool(ctx op_context.Context, pool Pool) (Pool, error)

func (*PoolControllerBase) AddService

func (m *PoolControllerBase) AddService(ctx op_context.Context, service PoolService) (PoolService, error)

func (*PoolControllerBase) AddServiceToPool

func (m *PoolControllerBase) AddServiceToPool(ctx op_context.Context, poolId string, serviceId string, role string, idIsName ...bool) error

func (*PoolControllerBase) CheckPoolNameUnique

func (m *PoolControllerBase) CheckPoolNameUnique(ctx op_context.Context, name interface{}) error

func (*PoolControllerBase) CheckServiceNameUnique

func (m *PoolControllerBase) CheckServiceNameUnique(ctx op_context.Context, name interface{}) error

func (*PoolControllerBase) DeletePool

func (m *PoolControllerBase) DeletePool(ctx op_context.Context, id string, idIsName ...bool) error

func (*PoolControllerBase) DeleteService

func (m *PoolControllerBase) DeleteService(ctx op_context.Context, id string, idIsName ...bool) error

func (*PoolControllerBase) FindPool

func (m *PoolControllerBase) FindPool(ctx op_context.Context, id string, idIsName ...bool) (Pool, error)

func (*PoolControllerBase) FindService

func (m *PoolControllerBase) FindService(ctx op_context.Context, id string, idIsName ...bool) (PoolService, error)

func (*PoolControllerBase) GetPoolBindings

func (p *PoolControllerBase) GetPoolBindings(ctx op_context.Context, id string, idIsName ...bool) ([]*PoolServiceBinding, error)

func (*PoolControllerBase) GetPools

func (p *PoolControllerBase) GetPools(ctx op_context.Context, filter *db.Filter) ([]*PoolBase, int64, error)

func (*PoolControllerBase) GetServiceBindings

func (p *PoolControllerBase) GetServiceBindings(ctx op_context.Context, id string, idIsName ...bool) ([]*PoolServiceBinding, error)

func (*PoolControllerBase) GetServices

func (p *PoolControllerBase) GetServices(ctx op_context.Context, filter *db.Filter) ([]*PoolServiceBase, int64, error)

func (*PoolControllerBase) OpLog

func (m *PoolControllerBase) OpLog(ctx op_context.Context, operation string, oplog *OpLogPool)

func (*PoolControllerBase) PoolId

func (m *PoolControllerBase) PoolId(c op_context.CallContext, ctx op_context.Context, id string, idIsName ...bool) (string, error)

func (*PoolControllerBase) RemoveAllServicesFromPool

func (m *PoolControllerBase) RemoveAllServicesFromPool(ctx op_context.Context, id string, idIsName ...bool) error

func (*PoolControllerBase) RemoveServiceFromAllPools

func (m *PoolControllerBase) RemoveServiceFromAllPools(ctx op_context.Context, id string, idIsName ...bool) error

func (*PoolControllerBase) RemoveServiceFromPool

func (m *PoolControllerBase) RemoveServiceFromPool(ctx op_context.Context, id string, role string, idIsName ...bool) error

func (*PoolControllerBase) ServiceId

func (m *PoolControllerBase) ServiceId(c op_context.CallContext, ctx op_context.Context, id string, idIsName ...bool) (string, error)

func (*PoolControllerBase) UpdatePool

func (m *PoolControllerBase) UpdatePool(ctx op_context.Context, id string, fields db.Fields, idIsName ...bool) (Pool, error)

func (*PoolControllerBase) UpdateService

func (m *PoolControllerBase) UpdateService(ctx op_context.Context, id string, fields db.Fields, idIsName ...bool) (PoolService, error)

type PoolId

type PoolId struct {
	POOL_ID string `gorm:"index;index:,unique,composite:u" json:"pool_id"`
}

type PoolService

var NilService PoolService

func ActivateService

func ActivateService(ctrl PoolController, ctx op_context.Context, id string, idIsName ...bool) (PoolService, error)

func DeactivateService

func DeactivateService(ctrl PoolController, ctx op_context.Context, id string, idIsName ...bool) (PoolService, error)

type PoolServiceAssociation

type PoolServiceAssociation interface {
	common.Object
	Pool() string
	Role() string
	Service() string
}

type PoolServiceAssociationBase

type PoolServiceAssociationBase struct {
	common.ObjectBase
	PoolServiceAssociationEssentials
}

func (PoolServiceAssociationBase) TableName

func (PoolServiceAssociationBase) TableName() string

type PoolServiceAssociationCmd

type PoolServiceAssociationCmd struct {
	WithRole
	SERVICE_ID string `gorm:"index" json:"service_id" validate:"required" vmessage:"Service ID can not be empty"`
}

func (*PoolServiceAssociationCmd) Service

func (p *PoolServiceAssociationCmd) Service() string

type PoolServiceAssociationEssentials

type PoolServiceAssociationEssentials struct {
	PoolId
	PoolServiceAssociationCmd
}

func (*PoolServiceAssociationEssentials) Pool

type PoolServiceBase

type PoolServiceBase struct {
	common.ObjectBase
	PoolServiceBaseEssentials
}

func NewService

func NewService() *PoolServiceBase

func (PoolServiceBase) TableName

func (PoolServiceBase) TableName() string

type PoolServiceBaseEssentials

type PoolServiceBaseEssentials struct {
	PoolServiceBaseData
	common.WithUniqueNameBase
}

type PoolServiceBinding

type PoolServiceBinding struct {
	common.ObjectBase   `source:"pool_service_associations"`
	WithRole            `source:"pool_service_associations"`
	PoolServiceBaseData `source:"pool_services"`
	PoolId              string `json:"pool_id" source:"pools.id" display:"Pool ID"`
	PoolName            string `json:"pool_name" source:"pools.name" display:"Pool"`
	ServiceId           string `json:"service_id" source:"pool_services.id" display:"Service ID"`
	ServiceName         string `json:"service_name" source:"pool_services.name" display:"Service"`
}

func (*PoolServiceBinding) Name

func (s *PoolServiceBinding) Name() string

func (*PoolServiceBinding) SetName

func (s *PoolServiceBinding) SetName(name string)

type PoolStore

type PoolStore interface {
	Pool(id string) (Pool, error)
	SelfPool() (Pool, error)
	PoolByName(name string) (Pool, error)
	Pools() []Pool
	PoolController() PoolController
	SelfPoolService(role string) (*PoolServiceBinding, error)
	SelfPoolServiceByName(name string) (*PoolServiceBinding, error)
}

type PoolStoreBase

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

func NewPoolStore

func NewPoolStore(config ...PoolStoreConfigI) *PoolStoreBase

func (*PoolStoreBase) Config

func (p *PoolStoreBase) Config() interface{}

func (*PoolStoreBase) Init

func (p *PoolStoreBase) Init(ctx op_context.Context, configPath ...string) error

func (*PoolStoreBase) Pool

func (p *PoolStoreBase) Pool(id string) (Pool, error)

func (*PoolStoreBase) PoolByName

func (p *PoolStoreBase) PoolByName(id string) (Pool, error)

func (*PoolStoreBase) PoolController

func (p *PoolStoreBase) PoolController() PoolController

func (*PoolStoreBase) Pools

func (p *PoolStoreBase) Pools() []Pool

func (*PoolStoreBase) SelfPool

func (p *PoolStoreBase) SelfPool() (Pool, error)

func (*PoolStoreBase) SelfPoolService

func (p *PoolStoreBase) SelfPoolService(role string) (*PoolServiceBinding, error)

func (*PoolStoreBase) SelfPoolServiceByName

func (p *PoolStoreBase) SelfPoolServiceByName(name string) (*PoolServiceBinding, error)

type PoolStoreConfig

type PoolStoreConfig struct {
	PoolController PoolController
}

func (*PoolStoreConfig) GetPoolController

func (p *PoolStoreConfig) GetPoolController() PoolController

type PoolStoreConfigI

type PoolStoreConfigI interface {
	GetPoolController() PoolController
}

type Secrets

type Secrets interface {
	Secret1() string
	Secret2() string
}

type SecretsBase

type SecretsBase struct {
	SECRET1 string `json:"secret1" long:"secret1" description:"If set then sak for secret 1"`
	SECRET2 string `json:"secret2" long:"secret2" description:"If set then ask for secret 2"`
}

func (*SecretsBase) Secret1

func (s *SecretsBase) Secret1() string

func (*SecretsBase) Secret2

func (s *SecretsBase) Secret2() string

type ServiceConfig

type ServiceConfig interface {
	Provider() string
	PublicHost() string
	PublicPort() uint16
	PublicUrl() string
	PrivateHost() string
	PrivatePort() uint16
	PrivateUrl() string
	Parameter1() string
	Parameter2() string
	Parameter3() string
	Parameter1Name() string
	Parameter2Name() string
	Parameter3Name() string
	User() string
	IpAddress() string
	ApiVersion() string
	PathPrefix() string
}

type ServiceConfigBase

type ServiceConfigBase struct {
	PROVIDER        string `gorm:"index;column:provider" json:"provider" long:"provider" description:"Service provider" required:"true"`
	PUBLIC_HOST     string `gorm:"index" json:"public_host" long:"public_host" description:"Public host of the service (optional)"`
	PUBLIC_PORT     uint16 `gorm:"index" json:"public_port" long:"public_port" description:"Public port of the service (optional)"`
	PUBLIC_URL      string `gorm:"index" json:"public_url" long:"public_url" description:"Public url of the service (optional)" display:"Public URL"`
	PRIVATE_HOST    string `gorm:"index" json:"private_host" long:"private_host" description:"Private host of the service (optional)"`
	PRIVATE_PORT    uint16 `gorm:"index" json:"private_port" long:"private_port" description:"Private port of the service (optional)"`
	PRIVATE_URL     string `gorm:"index" json:"private_url" long:"private_url" description:"Private URL of the service (optional)" display:"Private URL"`
	USER            string `gorm:"index" json:"user" long:"user" description:"User for login to the service (optional)"`
	DB_NAME         string `gorm:"index;column:db_name" json:"db_name" long:"db_name" description:"Name of database (optional)" display:"Database"`
	PARAMETER1      string `gorm:"index;column:parameter1" json:"parameter1" long:"parameter1" description:"Generic parameter1 of the service (optional)"`
	PARAMETER2      string `gorm:"index;column:parameter2" json:"parameter2" long:"parameter2" description:"Generic parameter2 of the service (optional)"`
	PARAMETER3      string `gorm:"index;column:parameter3" json:"parameter3" long:"parameter3" description:"Generic parameter3 of the service (optional)"`
	PARAMETER1_NAME string `` /* 148-byte string literal not displayed */
	PARAMETER2_NAME string `` /* 148-byte string literal not displayed */
	PARAMETER3_NAME string `` /* 148-byte string literal not displayed */
	IP_ADDRESS      string `gorm:"index" json:"ip_address" long:"ip_address" description:"IP address of the service (optional)"`
	API_VERSION     string `gorm:"index" json:"api_version" long:"api_version" default:"1.0.0" description:"API version of the service (optional)"`
	PATH_PREFIX     string `gorm:"index" json:"path_prefix" long:"path_prefix" default:"/api" description:"URL path prefix of the service (optional)"`
}

func (*ServiceConfigBase) ApiVersion

func (s *ServiceConfigBase) ApiVersion() string

func (*ServiceConfigBase) DbName

func (s *ServiceConfigBase) DbName() string

func (*ServiceConfigBase) IpAddress

func (s *ServiceConfigBase) IpAddress() string

func (*ServiceConfigBase) Parameter1

func (s *ServiceConfigBase) Parameter1() string

func (*ServiceConfigBase) Parameter1Name

func (s *ServiceConfigBase) Parameter1Name() string

func (*ServiceConfigBase) Parameter2

func (s *ServiceConfigBase) Parameter2() string

func (*ServiceConfigBase) Parameter2Name

func (s *ServiceConfigBase) Parameter2Name() string

func (*ServiceConfigBase) Parameter3

func (s *ServiceConfigBase) Parameter3() string

func (*ServiceConfigBase) Parameter3Name

func (s *ServiceConfigBase) Parameter3Name() string

func (*ServiceConfigBase) PathPrefix

func (s *ServiceConfigBase) PathPrefix() string

func (*ServiceConfigBase) PrivateHost

func (s *ServiceConfigBase) PrivateHost() string

func (*ServiceConfigBase) PrivatePort

func (s *ServiceConfigBase) PrivatePort() uint16

func (*ServiceConfigBase) PrivateUrl

func (s *ServiceConfigBase) PrivateUrl() string

func (*ServiceConfigBase) Provider

func (s *ServiceConfigBase) Provider() string

func (*ServiceConfigBase) PublicHost

func (s *ServiceConfigBase) PublicHost() string

func (*ServiceConfigBase) PublicPort

func (s *ServiceConfigBase) PublicPort() uint16

func (*ServiceConfigBase) PublicUrl

func (s *ServiceConfigBase) PublicUrl() string

func (*ServiceConfigBase) User

func (s *ServiceConfigBase) User() string

type WithRole

type WithRole struct {
	ROLE string `` /* 137-byte string literal not displayed */
}

func (*WithRole) Role

func (p *WithRole) Role() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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