Skip to content

Import path: gitlab.soludian.com/soludian/fountain/runnable

runnable

go
import "gitlab.soludian.com/soludian/fountain/runnable"

Index

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() error

type 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) *ServerInstance

ApplyOptions sets optional options

func DefaultServerInstance

go
func DefaultServerInstance() ServerInstance

func (ServerInstance) Destroy

go
func (si ServerInstance) Destroy() error

func (ServerInstance) Equal

go
func (si ServerInstance) Equal(o any) bool

Equal 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) string

GetServiceKey ETCD registration needs to be used

func (*ServerInstance) GetServiceValue

go
func (si *ServerInstance) GetServiceValue() string

GetServiceValue ETCD registration needs to use the service information

func (ServerInstance) Info

go
func (si ServerInstance) Info() ServerInstance

func (ServerInstance) Initialize

go
func (si ServerInstance) Initialize() error

func (ServerInstance) Label

go
func (si ServerInstance) Label() string

Label...

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) ServerOption

WithAddress sets the address

func WithServerKind

go
func WithServerKind(kind constants.ServiceKind) ServerOption

WithKind sets the type

func WithServerMetaData

go
func WithServerMetaData(key, value string) ServerOption

WithMetaData sets metadata information

func WithServerName

go
func WithServerName(name string) ServerOption

WithName defines the service name

func WithServerProtocol

go
func WithServerProtocol(protocol constants.ServerProtocol) ServerOption

WithServerProtocol 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