Import path:
gitlab.soludian.com/soludian/fountain/runnable
runnable
go
import "gitlab.soludian.com/soludian/fountain/runnable"Index
- Constants
- type AppInstance
- type ConfigInfo
- type Invoker
- type JobInstance
- type Route
- type Server
- type ServerInstance
- func ApplyServerOptions(options ...ServerOption) *ServerInstance
- func DefaultServerInstance() ServerInstance
- func (si ServerInstance) Destroy() error
- func (si ServerInstance) Equal(o any) bool
- func (si ServerInstance) GetServiceKey(prefix string) string
- func (si *ServerInstance) GetServiceValue() string
- func (si ServerInstance) Info() ServerInstance
- func (si ServerInstance) Initialize() error
- func (si ServerInstance) Label() string
- func (si ServerInstance) OnConfigChange()
- func (si ServerInstance) Serving()
- type ServerOption
- type Service
- type WeightGroup
Constants
go
const KPackageName = "runnable"type AppInstance
AppInstance type;
go
type AppInstance interface {
Initialize() error
// Serving was called in a goroutine
Serving()
Destroy() error
OnConfigChange()
Info() ServerInstance
}type ConfigInfo
ConfigInfo represents service configurator
go
type ConfigInfo struct {
Routes []Route
}type Invoker
go
type Invoker func() errortype JobInstance
JobInstance type;
go
type JobInstance interface {
Start() error
GetName() string
Stop() error
}type Route
Route...
go
type Route struct {
// weight group, according to
WeightGroups []WeightGroup
// method name
Method string
}type Server
Server...
go
type Server interface {
Initialize() error
Serving() // Serving was called in a goroutine
OnConfigChange() // Callback when config changed
Destroy() error
GracefulStop(ctx context.Context) error
Info() ServerInstance
}type ServerInstance
ServerInstance represents service info
go
type ServerInstance struct {
Name string `json:"name" conf:"name"`
ID string `json:"id" conf:"id"`
Image string `json:"image" conf:"image"`
Protocol constants.ServerProtocol `json:"protocol" conf:"protocol"`
Address string `json:"address" conf:"address"`
Weight float64 `json:"weight" conf:"weight"`
Enable bool `json:"enable" conf:"enable"`
Healthy bool `json:"healthy" conf:"healthy"`
Metadata map[string]string `json:"metadata" conf:"metadata"`
Region string `json:"region" conf:"region"`
Zone string `json:"zone" conf:"zone"`
Kind constants.ServiceKind `json:"kind" conf:"kind"`
Deployment string `json:"deployment" conf:"deployment"` // Deployment deployment group: traffic isolation of different groups, such as some services for internal calls and third-party calls, you can configure different deployments for traffic isolation
TrafficGroup string `json:"traffic_group" conf:"traffic_group"` // Group traffic group: traffic is load balanced between groups
Services map[string]*Service `json:"services" conf:"services"`
Logger flog.FlogInf `json:"-" conf:"-"`
}func ApplyServerOptions
go
func ApplyServerOptions(options ...ServerOption) *ServerInstanceApplyOptions sets optional options
func DefaultServerInstance
go
func DefaultServerInstance() ServerInstancefunc (ServerInstance) Destroy
go
func (si ServerInstance) Destroy() errorfunc (ServerInstance) Equal
go
func (si ServerInstance) Equal(o any) boolEqual must implement this method, which will be used in gRPC attributes to assert to determine whether it is equal
func (ServerInstance) GetServiceKey
go
func (si ServerInstance) GetServiceKey(prefix string) stringGetServiceKey ETCD registration needs to be used
func (*ServerInstance) GetServiceValue
go
func (si *ServerInstance) GetServiceValue() stringGetServiceValue ETCD registration needs to use the service information
func (ServerInstance) Info
go
func (si ServerInstance) Info() ServerInstancefunc (ServerInstance) Initialize
go
func (si ServerInstance) Initialize() errorfunc (ServerInstance) Label
go
func (si ServerInstance) Label() stringLabel...
func (ServerInstance) OnConfigChange
go
func (si ServerInstance) OnConfigChange()func (ServerInstance) Serving
go
func (si ServerInstance) Serving()type ServerOption
Option optional
go
type ServerOption func(c *ServerInstance)func WithServerAddress
go
func WithServerAddress(address string) ServerOptionWithAddress sets the address
func WithServerKind
go
func WithServerKind(kind constants.ServiceKind) ServerOptionWithKind sets the type
func WithServerMetaData
go
func WithServerMetaData(key, value string) ServerOptionWithMetaData sets metadata information
func WithServerName
go
func WithServerName(name string) ServerOptionWithName defines the service name
func WithServerProtocol
go
func WithServerProtocol(protocol constants.ServerProtocol) ServerOptionWithServerProtocol sets the protocol
type Service
Service...
go
type Service struct {
Namespace string `json:"namespace" conf:"namespace"`
Name string `json:"name" conf:"name"`
Labels map[string]string `json:"labels" conf:"labels"`
Methods []string `json:"methods" conf:"methods"`
}type WeightGroup
WeightGroup...
go
type WeightGroup struct {
Group string
Weight int
}Generated by gomarkdoc