rigger

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2021 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const NoReply = noReply(1)

表示不需要回复发送者,意味者,处理者需要自己正确处理回复

Variables

View Source
var (
	ErrInvalidLengthProtos = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowProtos   = fmt.Errorf("proto: integer overflow")
)

Functions

func AddRoutee added in v0.0.7

func AddRoutee(from actor.Context, routerPid *actor.PID, pid *actor.PID)

将一个进程添加到路由里去

func Broadcast added in v0.0.7

func Broadcast(from actor.Context, routerPid *actor.PID, msg proto.Message)

向所有拥有的进程广播消息,请注意: 如果有跨节点的进程请不要使用此接口,否则会导致运行时错误 TODO 使可以跨进程

func DependOn added in v0.0.13

func DependOn(app string, depApps ...string)

声明依赖

func FetchFutureError added in v0.0.12

func FetchFutureError(future *actor.Future) error

如果 future的结果是error, 则此函数可以快捷的取出future的错误,如果有错,则返回error,否则返回nil

func GetPid

func GetPid(name string) (*actor.PID, bool)

根据配置中的名字获取其进程id, 如果存在,则返回进程ID和true, 否则返回 nil,false 获取到进程ID,并不意味着此进程依然存活 本接口只适用于静态进程

func GetRoutees added in v0.0.7

func GetRoutees(from actor.Context, routerPid *actor.PID, timeout time.Duration) (*router.Routees, error)

获取所有的Routee

func GetRunningApplication

func GetRunningApplication(id string) (*actor.PID, bool)

获取正在运行中的应用,如果没有,第二个返回值为 false,否则为true

func IsLocalPid

func IsLocalPid(pid *actor.PID) bool

判断PID是否是本地PID

func IsRemotePid

func IsRemotePid(pid *actor.PID) bool

func Register

func Register(kind string, producer interface{})

注册生成器(producer, 关于producer请参考proto-actor 相关资料) 注册生成器时, 还会注册一个默认启动函数, 默认的启动函数规则: 1. 如果进程是普通(非动态/即非SimpleOneForOne)进程, 启动函数会以id作为启动后的进程的名字 2. 如果进程是动态进程,也即SimpleOneForOne, 启动函数不会对该进程命名 3. 如果进程是SimpleOneForOne,但又需要命名,此时需要调用 RegisterStartFun来注册自定义的启动函数

应该在init函数中调用此函数

func RegisterStartFun

func RegisterStartFun(name string, producer interface{}, startFun SpawnFun)

给进程注册producer及启动函数

应该在init函数中调用此函数

func RemoveRoutee added in v0.0.7

func RemoveRoutee(from actor.Context, routerPid *actor.PID, pid *actor.PID)

func Root added in v0.0.8

func Root() *actor.ActorSystem

获取所有rigger应用的根应用

func SpawnFromFun added in v0.0.7

func SpawnFromFun(parent actor.Context, fun actor.ReceiveFunc) *actor.PID

根据函数启动一个进程, 并返回进程id

func SpawnFromProducer added in v0.0.7

func SpawnFromProducer(parent actor.Context, producer actor.Producer) *actor.PID

* 启动一个进程

func Start

func Start(applicationId string, configPath string) error

启动应用 applicationId: 应用标识, 需要是一个已经注册的应用标识 configPath: 应用配置文件路径, 路径可以指向一个有效的yml文件, toml文件, ini文件, json文件等

func StartChild

func StartChild(from actor.Context, pid *actor.PID, spawnSpec *SpawnSpec) error

启动一个子进程,只对Supervisor有效 spawnSpecOrArgs: 可以接受的类型为*SpawnSpec 或其它任何类型 注意: 如果监控进程的模式是 SimpleOneForOne, 则spawnSpecOrArgs会当作动态启动参考原样回传给starter/OnStarted/OnPostStarted

func StartChildNotified

func StartChildNotified(from actor.Context, pid *actor.PID, spawnSpec *SpawnSpec) error

以异步的方式启动子进程,如果启动成功,会将新的进程ID通知给from进程

func StartChildSync

func StartChildSync(from actor.Context, pid *actor.PID, spawnSpec *SpawnSpec, timeout time.Duration) (*actor.PID, error)

启动子进程 已知问题: 如果在父进程内部启动子进程,会导致死锁超时

func StartFromCli added in v0.0.4

func StartFromCli()

从命令行的启动 函数从命令行相关配置,然后根据这些配置启动应用 命令行选项: -l 启动文件路径, 路径应该指向一个有效的yum文件, 此选项和-n必须至少有一个,且只有一个会生效, 优化使用-l可选选项 -n 应用名, 此选项和-l必须至少有一个,且只有一个会生效,优化使用-l, 可选选项 -c 应用配置文件路径, 路径可以指向一个有效的yml文件, toml文件, ini文件, json文件等, 可选项

func StartWithConfig

func StartWithConfig(launchConfigPath string, appConfigPath string)

根据配置启动应用, 如果启动失败,会panic,所以未返回错误 函数接受两个配置文件: launchConfigPath 启动配置文件,目前为yum 文件, 里面描述了应该如何启动一个节点上的应用 appConfigPath 运行时环境配置文件, go-rigger不关心里面的内容, 此配置文件供用户自己使用,用户可以使用viper相关函数获取其中的数据

func ToError added in v0.0.12

func ToError(maybeError interface{}) error

将一个类型为error的接口转换成error

Types

type Application

type Application struct {
	Parent actor.SpawnerContext
	// contains filtered or unexported fields
}

应用 ----- Application ------

func (*Application) GetId

func (app *Application) GetId() string

Interface: supDelegateHolder

func (*Application) GetInitArgs

func (app *Application) GetInitArgs() interface{}

func (*Application) GetReceiveTimeout

func (app *Application) GetReceiveTimeout() time.Duration

func (*Application) IsFromConfig added in v0.0.8

func (app *Application) IsFromConfig() bool

func (*Application) Poison

func (app *Application) Poison()

func (*Application) PoisonFuture

func (app *Application) PoisonFuture() *actor.Future

func (*Application) SetChildStrategy

func (app *Application) SetChildStrategy(strategy actor.SupervisorStrategy)

func (*Application) SetDelegate

func (app *Application) SetDelegate(delegate *supDelegate)

func (*Application) Stop

func (app *Application) Stop()

func (*Application) StopFuture

func (app *Application) StopFuture() *actor.Future

type ApplicationBehaviour

type ApplicationBehaviour interface {
	SupervisorBehaviour
}

* 应用的行为模式模块

type ApplicationBehaviourProducer

type ApplicationBehaviourProducer func() ApplicationBehaviour

type Behaviour added in v0.0.14

type Behaviour []MessageHandler

func NewBehaviour added in v0.0.14

func NewBehaviour() Behaviour

func (*Behaviour) Become added in v0.0.14

func (b *Behaviour) Become(handler MessageHandler)

func (*Behaviour) BecomeStacked added in v0.0.14

func (b *Behaviour) BecomeStacked(receive MessageHandler)

func (*Behaviour) UnbecomeStacked added in v0.0.14

func (b *Behaviour) UnbecomeStacked()

type ErrDefault

type ErrDefault string

func (ErrDefault) Error

func (e ErrDefault) Error() string

type ErrNoParentNode

type ErrNoParentNode string

func (ErrNoParentNode) Error

func (e ErrNoParentNode) Error() string

type ErrNotRegister

type ErrNotRegister string

func (ErrNotRegister) Error

func (e ErrNotRegister) Error() string

type ErrPidIsNil

type ErrPidIsNil struct {
}

func (ErrPidIsNil) Error

func (e ErrPidIsNil) Error() string

type ErrSerializedSlicLenWrong

type ErrSerializedSlicLenWrong struct {
}

func (ErrSerializedSlicLenWrong) Error

type ErrSpawn

type ErrSpawn string

func (ErrSpawn) Error

func (e ErrSpawn) Error() string

type ErrUnSurportedProducer

type ErrUnSurportedProducer string

func (ErrUnSurportedProducer) Error

func (u ErrUnSurportedProducer) Error() string

type ErrWrongProducer

type ErrWrongProducer string

func (ErrWrongProducer) Error

func (e ErrWrongProducer) Error() string

type Error added in v0.0.10

type Error struct {
	ErrStr string `protobuf:"bytes,1,opt,name=errStr,proto3" json:"errStr,omitempty"`
}

表示Rigger通用错误, 可以跨节点传递,因此可以用来表示进程间消息处理的错误

func FromError added in v0.0.10

func FromError(err error) *Error

根据error生成一个rigger.Error

func FromString added in v0.0.10

func FromString(str string) *Error

根据字符串生成一个rigger.Error

func (*Error) Descriptor added in v0.0.10

func (*Error) Descriptor() ([]byte, []int)

func (*Error) Equal added in v0.0.10

func (this *Error) Equal(that interface{}) bool

func (*Error) Error added in v0.0.10

func (err *Error) Error() string

implment: error

func (*Error) GetErrStr added in v0.0.10

func (m *Error) GetErrStr() string

func (*Error) GoString added in v0.0.10

func (this *Error) GoString() string

func (*Error) Marshal added in v0.0.10

func (m *Error) Marshal() (dAtA []byte, err error)

func (*Error) MarshalTo added in v0.0.10

func (m *Error) MarshalTo(dAtA []byte) (int, error)

func (*Error) ProtoMessage added in v0.0.10

func (*Error) ProtoMessage()

func (*Error) Reset added in v0.0.10

func (m *Error) Reset()

func (*Error) Size added in v0.0.10

func (m *Error) Size() (n int)

func (*Error) String added in v0.0.10

func (this *Error) String() string

func (*Error) Unmarshal added in v0.0.10

func (m *Error) Unmarshal(dAtA []byte) error

func (*Error) XXX_DiscardUnknown added in v0.0.10

func (m *Error) XXX_DiscardUnknown()

func (*Error) XXX_Marshal added in v0.0.10

func (m *Error) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Error) XXX_Merge added in v0.0.10

func (m *Error) XXX_Merge(src proto.Message)

func (*Error) XXX_Size added in v0.0.10

func (m *Error) XXX_Size() int

func (*Error) XXX_Unmarshal added in v0.0.10

func (m *Error) XXX_Unmarshal(b []byte) error

type ErrorResp

type ErrorResp struct {
	Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"`
}

表示出错的回复

func (*ErrorResp) Descriptor

func (*ErrorResp) Descriptor() ([]byte, []int)

func (*ErrorResp) Equal

func (this *ErrorResp) Equal(that interface{}) bool

func (*ErrorResp) GetError

func (m *ErrorResp) GetError() string

func (*ErrorResp) GoString

func (this *ErrorResp) GoString() string

func (*ErrorResp) Marshal

func (m *ErrorResp) Marshal() (dAtA []byte, err error)

func (*ErrorResp) MarshalTo

func (m *ErrorResp) MarshalTo(dAtA []byte) (int, error)

func (*ErrorResp) ProtoMessage

func (*ErrorResp) ProtoMessage()

func (*ErrorResp) Reset

func (m *ErrorResp) Reset()

func (*ErrorResp) Size

func (m *ErrorResp) Size() (n int)

func (*ErrorResp) String

func (this *ErrorResp) String() string

func (*ErrorResp) Unmarshal

func (m *ErrorResp) Unmarshal(dAtA []byte) error

func (*ErrorResp) XXX_DiscardUnknown

func (m *ErrorResp) XXX_DiscardUnknown()

func (*ErrorResp) XXX_Marshal

func (m *ErrorResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ErrorResp) XXX_Merge

func (m *ErrorResp) XXX_Merge(src proto.Message)

func (*ErrorResp) XXX_Size

func (m *ErrorResp) XXX_Size() int

func (*ErrorResp) XXX_Unmarshal

func (m *ErrorResp) XXX_Unmarshal(b []byte) error

type Forward

type Forward struct {
	To      *actor.PID    // 转发给谁
	Message proto.Message // 需要转发的消息
	RespondType
}

转发结构体,如果处理完消息后返回此值,则会继续将消息转发给指定进程, 且,后续接收进程会根据Responded的值选择是否回复初始发送者 为了满足GeneralServerBehaviour.OnMessage的接口规范, 手动实现了proto.Message

func (Forward) ProtoMessage

func (f Forward) ProtoMessage()

func (Forward) Reset

func (f Forward) Reset()

func (Forward) String

func (f Forward) String() string

type GeneralServer

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

通用服务器

func (*GeneralServer) Poison

func (server *GeneralServer) Poison()

func (*GeneralServer) PoisonFuture

func (server *GeneralServer) PoisonFuture() *actor.Future

func (*GeneralServer) Request

func (server *GeneralServer) Request(sender actor.SenderContext, msg interface{})

func (*GeneralServer) RequestFuture

func (server *GeneralServer) RequestFuture(sender actor.SenderContext, msg interface{}, timeout time.Duration) *actor.Future

func (*GeneralServer) RequestFutureDefault

func (server *GeneralServer) RequestFutureDefault(sender actor.SenderContext, msg interface{}) *actor.Future

默认5秒超时

func (*GeneralServer) Send

func (server *GeneralServer) Send(sender actor.SenderContext, msg interface{})

Interface: Sender 给genser发送一条消息

func (*GeneralServer) StartSpec

func (server *GeneralServer) StartSpec(spec *SpawnSpec) (*GeneralServer, error)

使用启动规范启动一个Actor

func (*GeneralServer) Stop

func (server *GeneralServer) Stop()

Interface: Stoppable

func (*GeneralServer) StopFuture

func (server *GeneralServer) StopFuture() *actor.Future

func (*GeneralServer) WithRawSupervisor

func (server *GeneralServer) WithRawSupervisor(strategy actor.SupervisorStrategy) *GeneralServer

func (*GeneralServer) WithSpawner

func (server *GeneralServer) WithSpawner(spawner interface{}) *GeneralServer

func (*GeneralServer) WithSupervisor

func (server *GeneralServer) WithSupervisor(maybeSupervisor interface{}) *GeneralServer

添加监控,需要在Start之前执行,并且只能设置一次非空supervisor,如果重复设置,则简单忽略

type GeneralServerBehaviour

type GeneralServerBehaviour interface {
	// 启动时的回调,应该在此回调中进行初始化,不管是正常启动或是重启,都会调用此事件
	LifeCyclePart
	// 结果需要返回给请求进程,为了保证能够跨节点,需要是proto.Message
	OnMessage(ctx actor.Context, message interface{}) proto.Message
}

通用服务器行为模式

type GeneralServerBehaviourProducer

type GeneralServerBehaviourProducer func() GeneralServerBehaviour

行为模式生成器

type HotUpdateSpec added in v0.0.10

type HotUpdateSpec struct {
}

func (*HotUpdateSpec) Descriptor added in v0.0.10

func (*HotUpdateSpec) Descriptor() ([]byte, []int)

func (*HotUpdateSpec) Equal added in v0.0.10

func (this *HotUpdateSpec) Equal(that interface{}) bool

func (*HotUpdateSpec) GoString added in v0.0.10

func (this *HotUpdateSpec) GoString() string

func (*HotUpdateSpec) Marshal added in v0.0.10

func (m *HotUpdateSpec) Marshal() (dAtA []byte, err error)

func (*HotUpdateSpec) MarshalTo added in v0.0.10

func (m *HotUpdateSpec) MarshalTo(dAtA []byte) (int, error)

func (*HotUpdateSpec) ProtoMessage added in v0.0.10

func (*HotUpdateSpec) ProtoMessage()

func (*HotUpdateSpec) Reset added in v0.0.10

func (m *HotUpdateSpec) Reset()

func (*HotUpdateSpec) Size added in v0.0.10

func (m *HotUpdateSpec) Size() (n int)

func (*HotUpdateSpec) String added in v0.0.10

func (this *HotUpdateSpec) String() string

func (*HotUpdateSpec) Unmarshal added in v0.0.10

func (m *HotUpdateSpec) Unmarshal(dAtA []byte) error

func (*HotUpdateSpec) XXX_DiscardUnknown added in v0.0.10

func (m *HotUpdateSpec) XXX_DiscardUnknown()

func (*HotUpdateSpec) XXX_Marshal added in v0.0.10

func (m *HotUpdateSpec) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*HotUpdateSpec) XXX_Merge added in v0.0.10

func (m *HotUpdateSpec) XXX_Merge(src proto.Message)

func (*HotUpdateSpec) XXX_Size added in v0.0.10

func (m *HotUpdateSpec) XXX_Size() int

func (*HotUpdateSpec) XXX_Unmarshal added in v0.0.10

func (m *HotUpdateSpec) XXX_Unmarshal(b []byte) error

type LifeCyclePart

type LifeCyclePart interface {
	OnRestarting(ctx actor.Context)
	/*
		启动时的回调,应该在此回调中进行初始化,不管是正常启动或是重启,都会调用此事件
		当回调此接口时,意味着,本进程之前的所有进程都已经回调完成 OnStarted 接口
		如果返回的错误不为空,则认为进程初始化失败,此时:
		1. 监控进程会停止启动其后的所有进程
		2. 会马上停止初始化失败的进程
	*/
	OnStarted(ctx actor.Context, args interface{}) error
	/*
		初始化完成后执行,在调用前会先通知调用者初始化完成,建议将比较费时的初始化操作放在此回调中进行
		以防止初始化太久而导致超时, 对于Supervisro进程来说,调用此方法时,会保证所有子进程都已经启动完成
	*/
	OnPostStarted(ctx actor.Context, args interface{})
	/*
		进程即将停止时,进行回调
	*/
	OnStopping(ctx actor.Context)
	/*
		进程停止后进行回调
	*/
	OnStopped(ctx actor.Context)
}

actor 生命周期接口 所有的go-rigger进程行为模式,都需要实现此接口

type MessageHandler added in v0.0.14

type MessageHandler func(ctx actor.Context, message interface{}) proto.Message

type OkResp

type OkResp struct {
}

表示成功的回复

func (*OkResp) Descriptor

func (*OkResp) Descriptor() ([]byte, []int)

func (*OkResp) Equal

func (this *OkResp) Equal(that interface{}) bool

func (*OkResp) GoString

func (this *OkResp) GoString() string

func (*OkResp) Marshal

func (m *OkResp) Marshal() (dAtA []byte, err error)

func (*OkResp) MarshalTo

func (m *OkResp) MarshalTo(dAtA []byte) (int, error)

func (*OkResp) ProtoMessage

func (*OkResp) ProtoMessage()

func (*OkResp) Reset

func (m *OkResp) Reset()

func (*OkResp) Size

func (m *OkResp) Size() (n int)

func (*OkResp) String

func (this *OkResp) String() string

func (*OkResp) Unmarshal

func (m *OkResp) Unmarshal(dAtA []byte) error

func (*OkResp) XXX_DiscardUnknown

func (m *OkResp) XXX_DiscardUnknown()

func (*OkResp) XXX_Marshal

func (m *OkResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*OkResp) XXX_Merge

func (m *OkResp) XXX_Merge(src proto.Message)

func (*OkResp) XXX_Size

func (m *OkResp) XXX_Size() int

func (*OkResp) XXX_Unmarshal

func (m *OkResp) XXX_Unmarshal(b []byte) error

type RemoteStartChildCmd

type RemoteStartChildCmd struct {
	SpawnSpecBytes []byte `protobuf:"bytes,1,opt,name=spawnSpecBytes,proto3" json:"spawnSpecBytes,omitempty"`
}

用于远程启动子进程的命令

func (*RemoteStartChildCmd) Descriptor

func (*RemoteStartChildCmd) Descriptor() ([]byte, []int)

func (*RemoteStartChildCmd) Equal

func (this *RemoteStartChildCmd) Equal(that interface{}) bool

func (*RemoteStartChildCmd) GetSpawnSpecBytes added in v0.0.15

func (m *RemoteStartChildCmd) GetSpawnSpecBytes() []byte

func (*RemoteStartChildCmd) GoString

func (this *RemoteStartChildCmd) GoString() string

func (*RemoteStartChildCmd) Marshal

func (m *RemoteStartChildCmd) Marshal() (dAtA []byte, err error)

func (*RemoteStartChildCmd) MarshalTo

func (m *RemoteStartChildCmd) MarshalTo(dAtA []byte) (int, error)

func (*RemoteStartChildCmd) ProtoMessage

func (*RemoteStartChildCmd) ProtoMessage()

func (*RemoteStartChildCmd) Reset

func (m *RemoteStartChildCmd) Reset()

func (*RemoteStartChildCmd) Size

func (m *RemoteStartChildCmd) Size() (n int)

func (*RemoteStartChildCmd) String

func (this *RemoteStartChildCmd) String() string

func (*RemoteStartChildCmd) Unmarshal

func (m *RemoteStartChildCmd) Unmarshal(dAtA []byte) error

func (*RemoteStartChildCmd) XXX_DiscardUnknown

func (m *RemoteStartChildCmd) XXX_DiscardUnknown()

func (*RemoteStartChildCmd) XXX_Marshal

func (m *RemoteStartChildCmd) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RemoteStartChildCmd) XXX_Merge

func (m *RemoteStartChildCmd) XXX_Merge(src proto.Message)

func (*RemoteStartChildCmd) XXX_Size

func (m *RemoteStartChildCmd) XXX_Size() int

func (*RemoteStartChildCmd) XXX_Unmarshal

func (m *RemoteStartChildCmd) XXX_Unmarshal(b []byte) error

type RespondType

type RespondType byte

回复类型, 用于转发(Forward)中

const (
	RespondNone   RespondType = 1 + iota // 不回复
	RespondOrigin                        // 回复给原始发送进程
	RespondSelf                          // 回复给本进程
)

type RouterGroupBehaviour added in v0.0.7

type RouterGroupBehaviour interface {
	// 获取类型
	OnGetType() RouterType
	// 获取初始的路由进程ID
	OnGetRoutee() []*actor.PID
}

router group行为模式

type RouterGroupBehaviourProducer added in v0.0.7

type RouterGroupBehaviourProducer func() RouterGroupBehaviour

type RouterType added in v0.0.7

type RouterType int

路由类型

const (
	RandomType         RouterType = 1 + iota // 随机选择一个进程,进行消息转发
	BroadcastType                            // 广播类型,即将消息转发给所有进程
	RoundRobinType                           // 轮询
	ConsistentHashType                       // 固定哈希, 即哈希值一样的消息始终在同一个进程处理
)

type SpawnFun

type SpawnFun func(parent actor.SpawnerContext, props *actor.Props, args interface{}) (pid *actor.PID, err error)

启动函数, go-rigger使用此类型的启动进程

type SpawnLoacalApplicationSpec added in v0.0.8

type SpawnLoacalApplicationSpec struct {
	LaunchConfigPath      string `protobuf:"bytes,1,opt,name=launchConfigPath,proto3" json:"launchConfigPath,omitempty"`
	ApplicationConfigPath string `protobuf:"bytes,2,opt,name=applicationConfigPath,proto3" json:"applicationConfigPath,omitempty"`
	ApplicationId         string `protobuf:"bytes,3,opt,name=applicationId,proto3" json:"applicationId,omitempty"`
}

func (*SpawnLoacalApplicationSpec) Descriptor added in v0.0.8

func (*SpawnLoacalApplicationSpec) Descriptor() ([]byte, []int)

func (*SpawnLoacalApplicationSpec) Equal added in v0.0.8

func (this *SpawnLoacalApplicationSpec) Equal(that interface{}) bool

func (*SpawnLoacalApplicationSpec) GetApplicationConfigPath added in v0.0.8

func (m *SpawnLoacalApplicationSpec) GetApplicationConfigPath() string

func (*SpawnLoacalApplicationSpec) GetApplicationId added in v0.0.8

func (m *SpawnLoacalApplicationSpec) GetApplicationId() string

func (*SpawnLoacalApplicationSpec) GetLaunchConfigPath added in v0.0.8

func (m *SpawnLoacalApplicationSpec) GetLaunchConfigPath() string

func (*SpawnLoacalApplicationSpec) GoString added in v0.0.8

func (this *SpawnLoacalApplicationSpec) GoString() string

func (*SpawnLoacalApplicationSpec) Marshal added in v0.0.8

func (m *SpawnLoacalApplicationSpec) Marshal() (dAtA []byte, err error)

func (*SpawnLoacalApplicationSpec) MarshalTo added in v0.0.8

func (m *SpawnLoacalApplicationSpec) MarshalTo(dAtA []byte) (int, error)

func (*SpawnLoacalApplicationSpec) ProtoMessage added in v0.0.8

func (*SpawnLoacalApplicationSpec) ProtoMessage()

func (*SpawnLoacalApplicationSpec) Reset added in v0.0.8

func (m *SpawnLoacalApplicationSpec) Reset()

func (*SpawnLoacalApplicationSpec) Size added in v0.0.8

func (m *SpawnLoacalApplicationSpec) Size() (n int)

func (*SpawnLoacalApplicationSpec) String added in v0.0.8

func (this *SpawnLoacalApplicationSpec) String() string

func (*SpawnLoacalApplicationSpec) Unmarshal added in v0.0.8

func (m *SpawnLoacalApplicationSpec) Unmarshal(dAtA []byte) error

func (*SpawnLoacalApplicationSpec) XXX_DiscardUnknown added in v0.0.8

func (m *SpawnLoacalApplicationSpec) XXX_DiscardUnknown()

func (*SpawnLoacalApplicationSpec) XXX_Marshal added in v0.0.8

func (m *SpawnLoacalApplicationSpec) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SpawnLoacalApplicationSpec) XXX_Merge added in v0.0.8

func (m *SpawnLoacalApplicationSpec) XXX_Merge(src proto.Message)

func (*SpawnLoacalApplicationSpec) XXX_Size added in v0.0.8

func (m *SpawnLoacalApplicationSpec) XXX_Size() int

func (*SpawnLoacalApplicationSpec) XXX_Unmarshal added in v0.0.8

func (m *SpawnLoacalApplicationSpec) XXX_Unmarshal(b []byte) error

type SpawnLocalApplicationResp added in v0.0.8

type SpawnLocalApplicationResp struct {
	Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"`
}

func (*SpawnLocalApplicationResp) Descriptor added in v0.0.8

func (*SpawnLocalApplicationResp) Descriptor() ([]byte, []int)

func (*SpawnLocalApplicationResp) Equal added in v0.0.8

func (this *SpawnLocalApplicationResp) Equal(that interface{}) bool

func (*SpawnLocalApplicationResp) GetError added in v0.0.8

func (m *SpawnLocalApplicationResp) GetError() string

func (*SpawnLocalApplicationResp) GoString added in v0.0.8

func (this *SpawnLocalApplicationResp) GoString() string

func (*SpawnLocalApplicationResp) Marshal added in v0.0.8

func (m *SpawnLocalApplicationResp) Marshal() (dAtA []byte, err error)

func (*SpawnLocalApplicationResp) MarshalTo added in v0.0.8

func (m *SpawnLocalApplicationResp) MarshalTo(dAtA []byte) (int, error)

func (*SpawnLocalApplicationResp) ProtoMessage added in v0.0.8

func (*SpawnLocalApplicationResp) ProtoMessage()

func (*SpawnLocalApplicationResp) Reset added in v0.0.8

func (m *SpawnLocalApplicationResp) Reset()

func (*SpawnLocalApplicationResp) Size added in v0.0.8

func (m *SpawnLocalApplicationResp) Size() (n int)

func (*SpawnLocalApplicationResp) String added in v0.0.8

func (this *SpawnLocalApplicationResp) String() string

func (*SpawnLocalApplicationResp) Unmarshal added in v0.0.8

func (m *SpawnLocalApplicationResp) Unmarshal(dAtA []byte) error

func (*SpawnLocalApplicationResp) XXX_DiscardUnknown added in v0.0.8

func (m *SpawnLocalApplicationResp) XXX_DiscardUnknown()

func (*SpawnLocalApplicationResp) XXX_Marshal added in v0.0.8

func (m *SpawnLocalApplicationResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SpawnLocalApplicationResp) XXX_Merge added in v0.0.8

func (m *SpawnLocalApplicationResp) XXX_Merge(src proto.Message)

func (*SpawnLocalApplicationResp) XXX_Size added in v0.0.8

func (m *SpawnLocalApplicationResp) XXX_Size() int

func (*SpawnLocalApplicationResp) XXX_Unmarshal added in v0.0.8

func (m *SpawnLocalApplicationResp) XXX_Unmarshal(b []byte) error

type SpawnResponse

type SpawnResponse struct {
	Sender *actor.PID `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"`
	Parent *actor.PID `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"`
	Pid    *actor.PID `protobuf:"bytes,3,opt,name=pid,proto3" json:"pid,omitempty"`
	Error  string     `protobuf:"bytes,4,opt,name=error,proto3" json:"error,omitempty"`
}

起进程回复

func (*SpawnResponse) Descriptor

func (*SpawnResponse) Descriptor() ([]byte, []int)

func (*SpawnResponse) Equal

func (this *SpawnResponse) Equal(that interface{}) bool

func (*SpawnResponse) GetError

func (m *SpawnResponse) GetError() string

func (*SpawnResponse) GetParent

func (m *SpawnResponse) GetParent() *actor.PID

func (*SpawnResponse) GetPid

func (m *SpawnResponse) GetPid() *actor.PID

func (*SpawnResponse) GetSender

func (m *SpawnResponse) GetSender() *actor.PID

func (*SpawnResponse) GoString

func (this *SpawnResponse) GoString() string

func (*SpawnResponse) Marshal

func (m *SpawnResponse) Marshal() (dAtA []byte, err error)

func (*SpawnResponse) MarshalTo

func (m *SpawnResponse) MarshalTo(dAtA []byte) (int, error)

func (*SpawnResponse) ProtoMessage

func (*SpawnResponse) ProtoMessage()

func (*SpawnResponse) Reset

func (m *SpawnResponse) Reset()

func (*SpawnResponse) Size

func (m *SpawnResponse) Size() (n int)

func (*SpawnResponse) String

func (this *SpawnResponse) String() string

func (*SpawnResponse) Unmarshal

func (m *SpawnResponse) Unmarshal(dAtA []byte) error

func (*SpawnResponse) XXX_DiscardUnknown

func (m *SpawnResponse) XXX_DiscardUnknown()

func (*SpawnResponse) XXX_Marshal

func (m *SpawnResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SpawnResponse) XXX_Merge

func (m *SpawnResponse) XXX_Merge(src proto.Message)

func (*SpawnResponse) XXX_Size

func (m *SpawnResponse) XXX_Size() int

func (*SpawnResponse) XXX_Unmarshal

func (m *SpawnResponse) XXX_Unmarshal(b []byte) error

type SpawnSpec

type SpawnSpec struct {
	/*
		进程名,如果此值不为空,则使用此名字注册进程, 如果为空,则:
		1. 如果是动态启动的进程, rigger 不会自动注册进程,此时,如果用户想要注册,则应该rigger.RegisterStartFun注册启动函数,
		   并在启动函数中使用SpawnNamed来规定注册名
		2. 如果是静态进程, 则会使用 Kind 作为注册名
		3. Application只有rigger能启动, rigger会以Application的 Kind 作为其它注册名
	*/
	Name string
	Kind string // Kind, 必选参数, 框架会根据此ID查询启动 Producer和StartFun
	//Producer     interface{} // props producer,生成一个对应行为模式的实例,也即行为模式工厂
	//Starter      SpawnFun
	Args         interface{}   // 启动参数, 原样传入 Starter, 与 LifeCyclePart.OnStarted
	SpawnTimeout time.Duration // 超时时间,如果为0表示不等待,也即异步启动
	// 平静期超时时间,如果在指定时间内没收到任何消息,则会触发TimeroutReceiver回调,此值不为0时,需要实现TimeoutReceiver
	ReceiveTimeout time.Duration
	// contains filtered or unexported fields
}
启动规范,描述了如何启动一个进程

如果父进程的监控策略是 SimpleOneForOne 且是通过接口: StartChild, StartChildNotified, StartChildSync 等接口启动子进程时, 此时参数中的 *SpawnSpec 只有 SpawnSpec.Name, SpawnSpec.Args 这两个字段有意义, 其余字段的数据会被简单丢弃,并使用父进程规定的对应值

func NewSpawnSpec added in v0.0.15

func NewSpawnSpec() *SpawnSpec

新创建一个 SpawnSpec 结构, SpawnSpec.SpawnTimeout 默认值为预定义值: startTimeOut (10_000_000_000 ns)

func SimpleSpawnSpec added in v0.0.15

func SimpleSpawnSpec(name string, args interface{}) *SpawnSpec

生成一个用于 SimpleOneForOne 模式的 SpawnSpec

func SpawnSpecWithKind added in v0.0.15

func SpawnSpecWithKind(kind string) *SpawnSpec

根据进程类型(kind) 生成一个默认的SpawnSpec

func SpawnSpecWithName added in v0.0.15

func SpawnSpecWithName(kind string, name string) *SpawnSpec

生成一个命名的启动规范

func (*SpawnSpec) WithArgs added in v0.0.15

func (ss *SpawnSpec) WithArgs(args interface{}) *SpawnSpec

func (*SpawnSpec) WithKind added in v0.0.15

func (ss *SpawnSpec) WithKind(kind string) *SpawnSpec

func (*SpawnSpec) WithName added in v0.0.15

func (ss *SpawnSpec) WithName(name string) *SpawnSpec

func (*SpawnSpec) WithReceiveTimeout added in v0.0.15

func (ss *SpawnSpec) WithReceiveTimeout(duration time.Duration) *SpawnSpec

func (*SpawnSpec) WithSpawnTimeout added in v0.0.15

func (ss *SpawnSpec) WithSpawnTimeout(duration time.Duration) *SpawnSpec

type StartingNode

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

type Stoppable

type Stoppable interface {
	Stop()
	StopFuture() *actor.Future
	Poison()
	PoisonFuture() *actor.Future
}

type StrategyFlag

type StrategyFlag int

策略常量

const (
	OneForOne StrategyFlag = iota // 只重启失败的进程
	AllForOne
	SimpleOneForOne // 只重启失败的进程,并且,此模式下,只允许动态启动子进程
)

type Supervisor

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

TODO 当前重启会有问题,重启后可能不会走回调

func NewSupervisor

func NewSupervisor() *Supervisor

func StartSupervisor

func StartSupervisor(parent interface{}, id string) (*Supervisor, error)

启动一个监控进程

func StartSupervisorSpec

func StartSupervisorSpec(parent interface{}, spec *SpawnSpec) (*Supervisor, error)

Parent:*Application, *Supervisor, *Generalserver, actor.Context, *actor.ActorSystem

func (*Supervisor) GetId

func (sup *Supervisor) GetId() string

Interface: supDelegateHolder

func (*Supervisor) GetInitArgs

func (sup *Supervisor) GetInitArgs() interface{}

func (*Supervisor) GetReceiveTimeout

func (sup *Supervisor) GetReceiveTimeout() time.Duration

func (*Supervisor) IsFromConfig added in v0.0.8

func (sup *Supervisor) IsFromConfig() bool

func (*Supervisor) Poison

func (sup *Supervisor) Poison()

func (*Supervisor) PoisonFuture

func (sup *Supervisor) PoisonFuture() *actor.Future

func (*Supervisor) SetChildStrategy

func (sup *Supervisor) SetChildStrategy(strategy actor.SupervisorStrategy)

func (*Supervisor) SetDelegate

func (sup *Supervisor) SetDelegate(delegate *supDelegate)

func (*Supervisor) StartSpec

func (sup *Supervisor) StartSpec(spec *SpawnSpec) (*Supervisor, error)

func (*Supervisor) Stop

func (sup *Supervisor) Stop()

Interface: Stoppable

func (*Supervisor) StopFuture

func (sup *Supervisor) StopFuture() *actor.Future

func (*Supervisor) WithSpawner

func (sup *Supervisor) WithSpawner(spawner interface{}) *Supervisor

func (*Supervisor) WithSupervisor

func (sup *Supervisor) WithSupervisor(maybeSupervisor interface{}) *Supervisor

设置其监控者,只能设置一次,重复设置则简单忽略

type SupervisorBehaviour

type SupervisorBehaviour interface {
	LifeCyclePart
	/*
		获取监控标志时的回调
		childSpecs: 子进程规范, 描述如何启动子进程, 可以为以下类型:
			1. *SpawnSpec
			2. string, 此时为子规范的ID, 监控进程会根据此id去配置中查找对应的启动规范
	*/
	OnGetSupFlag(ctx actor.Context) (supFlag SupervisorFlag, childSpecs []*SpawnSpec)
}

监控进程行为模式接口

type SupervisorBehaviourProducer

type SupervisorBehaviourProducer func() SupervisorBehaviour

type SupervisorFlag

type SupervisorFlag struct {
	MaxRetries     int           // 最大重启次数
	WithinDuration time.Duration // 多久时间内重启
	Decider        actor.DeciderFunc
	StrategyFlag   StrategyFlag // 重启策略标志
}

监控标志

type TimeoutReceiver

type TimeoutReceiver interface {
	OnTimeout(ctx actor.Context)
}

如果起动进程时,ReceiveTimeout为大于0的值,则超时后会触发此回调 如果进程设置了超时时间,则必须实现本接口,否则,触发超时时,会引发异常 TODO 考虑在启动进程时进行断言

type UnexceptedStartResult

type UnexceptedStartResult string

func (UnexceptedStartResult) Error

func (u UnexceptedStartResult) Error() string

Jump to

Keyboard shortcuts

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