teacluster

package
v0.1.72 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2019 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClusterEnabled = true
)

Variables

View Source
var SharedManager = NewManager()

Functions

func GenerateActionId

func GenerateActionId() uint64

func RangeFiles

func RangeFiles(f func(file *files.File, relativePath string))

func RegisterActionType

func RegisterActionType(actions ...ActionInterface)

Types

type Action

type Action struct {
	Id          uint64
	RequestTime time.Time
	RequestId   uint64
}

func (*Action) BaseAction

func (this *Action) BaseAction() *Action

func (*Action) Execute

func (this *Action) Execute() error

func (*Action) OnFail

func (this *Action) OnFail(fail *FailAction) error

func (*Action) OnSuccess

func (this *Action) OnSuccess(success *SuccessAction) error

type ActionInterface

type ActionInterface interface {
	Name() string
	Execute() error
	OnSuccess(success *SuccessAction) error
	OnFail(fail *FailAction) error
	TypeId() int8
	BaseAction() *Action
}

func FindActionInstance

func FindActionInstance(typeId int8) ActionInterface

type FailAction

type FailAction struct {
	Action

	Message string
}

func (*FailAction) Name

func (this *FailAction) Name() string

func (*FailAction) TypeId

func (this *FailAction) TypeId() int8

type Manager

type Manager struct {
	RestartChan chan bool
	// contains filtered or unexported fields
}

cluster communication manager

func NewManager

func NewManager() *Manager

func (*Manager) BuildSum

func (this *Manager) BuildSum()

func (*Manager) Error

func (this *Manager) Error() string

func (*Manager) IsActive

func (this *Manager) IsActive() bool

is active

func (*Manager) IsChanged

func (this *Manager) IsChanged() bool

determine cluster data changes

func (*Manager) PullItems

func (this *Manager) PullItems()

func (*Manager) PushItems

func (this *Manager) PushItems()

func (*Manager) Read

func (this *Manager) Read(f func(action ActionInterface))

read action from cluster

func (*Manager) Restart

func (this *Manager) Restart()

func (*Manager) SetIsChanged

func (this *Manager) SetIsChanged(isChanged bool)

func (*Manager) Start

func (this *Manager) Start() error

start manager

func (*Manager) Stop

func (this *Manager) Stop() error

stop manager

func (*Manager) Write

func (this *Manager) Write(action ActionInterface) error

write action message to cluster manager

type NotifyAction

type NotifyAction struct {
	Action
}

cluster -> slave node

func (*NotifyAction) Execute

func (this *NotifyAction) Execute() error

func (*NotifyAction) Name

func (this *NotifyAction) Name() string

func (*NotifyAction) TypeId

func (this *NotifyAction) TypeId() int8

type PingAction

type PingAction struct {
	Action

	Version int64
}

node -> cluster

func (*PingAction) Name

func (this *PingAction) Name() string

func (*PingAction) TypeId

func (this *PingAction) TypeId() int8

type PullAction

type PullAction struct {
	Action

	LocalItems []*configs.Item // items without data
}

node <- cluster

func (*PullAction) Execute

func (this *PullAction) Execute() error

func (*PullAction) Name

func (this *PullAction) Name() string

func (*PullAction) TypeId

func (this *PullAction) TypeId() int8

type PushAction

type PushAction struct {
	Action

	Items []*configs.Item
}

master -> cluster

func (*PushAction) AddItem

func (this *PushAction) AddItem(item *configs.Item)

func (*PushAction) Execute

func (this *PushAction) Execute() error

func (*PushAction) Name

func (this *PushAction) Name() string

func (*PushAction) OnFail

func (this *PushAction) OnFail(fail *FailAction) error

func (*PushAction) OnSuccess

func (this *PushAction) OnSuccess(success *SuccessAction) error

func (*PushAction) TypeId

func (this *PushAction) TypeId() int8

type RegisterAction

type RegisterAction struct {
	Action

	ClusterId     string
	ClusterSecret string
	NodeId        string
	NodeName      string
	NodeRole      string
}

func (*RegisterAction) Execute

func (this *RegisterAction) Execute() error

func (*RegisterAction) Name

func (this *RegisterAction) Name() string

func (*RegisterAction) OnFail

func (this *RegisterAction) OnFail(fail *FailAction) error

func (*RegisterAction) OnSuccess

func (this *RegisterAction) OnSuccess(success *SuccessAction) error

func (*RegisterAction) TypeId

func (this *RegisterAction) TypeId() int8

type SuccessAction

type SuccessAction struct {
	Action

	Message string
	Data    maps.Map
}

func (*SuccessAction) Name

func (this *SuccessAction) Name() string

func (*SuccessAction) TypeId

func (this *SuccessAction) TypeId() int8

type SumAction

type SumAction struct {
	Action
}

cluster -> master|node

func (*SumAction) Name

func (this *SumAction) Name() string

func (*SumAction) OnFail

func (this *SumAction) OnFail(fail *FailAction) error

func (*SumAction) OnSuccess

func (this *SumAction) OnSuccess(success *SuccessAction) error

func (*SumAction) TypeId

func (this *SumAction) TypeId() int8

type SyncAction

type SyncAction struct {
	Action

	ItemActions []*configs.ItemAction
}

cluster -> node

func (*SyncAction) Execute

func (this *SyncAction) Execute() error

func (*SyncAction) Name

func (this *SyncAction) Name() string

func (*SyncAction) TypeId

func (this *SyncAction) TypeId() int8

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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