grpc_server

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	*proto.Database

	Lock sync.Mutex
	Cond *sync.Cond
}

func NewDatabase

func NewDatabase() *Database

func (*Database) StatusResponse

func (d *Database) StatusResponse() *api.DbStatusResponse

func (*Database) Update

func (d *Database) Update(db *proto.Database) bool

Return true if the database status is changed

type DbInstance

type DbInstance struct {
	Name      string
	PgVersion int32
	Online    bool

	Databases map[string]*Database

	DbJobChan chan *proto.DbJob
	// contains filtered or unexported fields
}

func NewDbInstance

func NewDbInstance(name string, pgVersion int32, logger *zerolog.Logger, subcriber *DbStatusSubscriber) *DbInstance

func (*DbInstance) CreateDb

func (a *DbInstance) CreateDb(vo *api.CreateDbRequest) error

func (*DbInstance) GetDb

func (a *DbInstance) GetDb(name string) *Database

func (*DbInstance) MigrateOut

func (a *DbInstance) MigrateOut(request *api.MigrateOutDbRequest, callback func() error) error

Return true if send the migrateOut job

func (*DbInstance) MustGetDb

func (a *DbInstance) MustGetDb(name string) *Database

func (*DbInstance) Send

func (a *DbInstance) Send(job *proto.DbJob)

func (*DbInstance) ServeDbJob

func (a *DbInstance) ServeDbJob(s proto.DbJobSvc_RegisterServer)

func (*DbInstance) StatusResponse

func (a *DbInstance) StatusResponse() *api.InstanceStatusResponse

func (*DbInstance) UpdateDatabase

func (a *DbInstance) UpdateDatabase(db *proto.Database)

func (*DbInstance) UpdateDatabases

func (a *DbInstance) UpdateDatabases(databases []*proto.Database)

type DbInstanceManager

type DbInstanceManager struct {
	Instances map[string]*DbInstance

	InstSubscriber *InstanceStatusSubscriber
	// contains filtered or unexported fields
}

func NewDbInstanceManager

func NewDbInstanceManager() *DbInstanceManager

func (*DbInstanceManager) CreateDb

func (m *DbInstanceManager) CreateDb(request *api.CreateDbRequest) error

func (*DbInstanceManager) FilterInstances

func (m *DbInstanceManager) FilterInstances(filter *api.InstanceFilter) []*DbInstance

func (*DbInstanceManager) FirstMatchedInstance

func (m *DbInstanceManager) FirstMatchedInstance(filter *api.InstanceFilter) *DbInstance

func (*DbInstanceManager) GetDb

func (m *DbInstanceManager) GetDb(vo *api.DbRequest) (*proto.Database, error)

func (*DbInstanceManager) GetDbStatus

func (m *DbInstanceManager) GetDbStatus(request *api.DbRequest) (*api.DbStatusResponse, error)

func (*DbInstanceManager) GetInstance

func (m *DbInstanceManager) GetInstance(instName string) *DbInstance

func (*DbInstanceManager) NewInstance

func (m *DbInstanceManager) NewInstance(instName string, pgVersion int32, logger *zerolog.Logger) (*DbInstance, error)

func (*DbInstanceManager) SubscribeDbStatus

func (m *DbInstanceManager) SubscribeDbStatus(callback api.SubscribeDbStatusFunc)

func (*DbInstanceManager) SubscribeInstanceStatus

func (m *DbInstanceManager) SubscribeInstanceStatus(callback api.SubscribeInstanceStatusFunc)

func (*DbInstanceManager) WaitReady

func (m *DbInstanceManager) WaitReady(instName, dbName string, timeout time.Duration) bool

type DbJobSvcHandler

type DbJobSvcHandler struct {
	proto.UnimplementedDbJobSvcServer
	*DbInstanceManager

	GrpcConfig *config.GrpcConfig

	QuitCtx context.Context
}

func NewDbJobSvcHandler

func NewDbJobSvcHandler(config *config.GrpcConfig, quitCtx context.Context) *DbJobSvcHandler

func (*DbJobSvcHandler) NotifyDbStatus

func (h *DbJobSvcHandler) NotifyDbStatus(ctx context.Context, db *proto.Database) (*emptypb.Empty, error)

func (*DbJobSvcHandler) Register

type DbStatusSubscriber

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

func (*DbStatusSubscriber) OnStatusChanged

func (s *DbStatusSubscriber) OnStatusChanged(instance *DbInstance, db *Database)

func (*DbStatusSubscriber) Subscribe

func (s *DbStatusSubscriber) Subscribe(subscriber api.SubscribeDbStatusFunc)

type GrpcServer

type GrpcServer struct {
	Config *config.GrpcConfig

	GrpcServer *grpc.Server
	Auth       *grpcAuth.GrpcAuth

	SvcHandler *DbJobSvcHandler
	QuitCtx    context.Context
}

func NewGrpcServer

func NewGrpcServer(config *config.GrpcConfig, quitCtx context.Context) *GrpcServer

func (*GrpcServer) Init

func (s *GrpcServer) Init(setter server.GlobalSetter) error

func (*GrpcServer) PostInit

func (s *GrpcServer) PostInit(getter server.GlobalGetter) error

func (*GrpcServer) Run

func (s *GrpcServer) Run()

func (*GrpcServer) Shutdown

func (s *GrpcServer) Shutdown(ctx context.Context)

type InstanceStatusSubscriber

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

func (*InstanceStatusSubscriber) OnStatusChanged

func (s *InstanceStatusSubscriber) OnStatusChanged(instance *DbInstance)

func (*InstanceStatusSubscriber) Subscribe

func (s *InstanceStatusSubscriber) Subscribe(subscriber api.SubscribeInstanceStatusFunc)

Jump to

Keyboard shortcuts

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