Documentation
¶
Overview ¶
Handles global state that can be changed
Index ¶
- func AcquireBuilding(servers []int, buildId string) error
- func SignalStop(buildId string) error
- func Stop(serverId int) bool
- type BuildState
- func (this *BuildState) AddFreezePoint(freezePoint float64)
- func (this *BuildState) Async(fn func())
- func (this *BuildState) Defer(fn func())
- func (this *BuildState) Destroy() error
- func (this *BuildState) Done() bool
- func (this *BuildState) DoneBuilding()
- func (this *BuildState) ErrorFree() bool
- func (this *BuildState) FinishDeploy()
- func (this *BuildState) Freeze() error
- func (this *BuildState) Get(key string) (interface{}, bool)
- func (this *BuildState) GetError() error
- func (this *BuildState) GetExt(key string) (interface{}, bool)
- func (this *BuildState) GetExtExtras() ([]byte, error)
- func (this *BuildState) GetExtras() map[string]interface{}
- func (this *BuildState) GetP(key string, out interface{}) bool
- func (this *BuildState) GetProgress() float64
- func (this *BuildState) IncrementBuildProgress()
- func (this *BuildState) IncrementDeployProgress()
- func (this *BuildState) Marshal() string
- func (this *BuildState) OnError(fn func())
- func (this *BuildState) ReportError(err error)
- func (this *BuildState) Reset()
- func (this *BuildState) Set(key string, value interface{})
- func (this *BuildState) SetBuildStage(stage string)
- func (this *BuildState) SetBuildSteps(steps int)
- func (this *BuildState) SetDeploySteps(steps int)
- func (this *BuildState) SetExt(key string, value interface{}) error
- func (this *BuildState) SignalStop() error
- func (this *BuildState) Stop() bool
- func (this *BuildState) Store() error
- func (this *BuildState) Unfreeze() error
- func (this *BuildState) Write(file string, data string) error
- type CustomError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AcquireBuilding ¶
AcquireBuilding acquires a build lock. Any function which modifies the nodes in a testnet should only do so after calling this function and ensuring that the returned value is nil
func SignalStop ¶
SignalStop flags that the current build should be stopped, if there is a current build. Returns an error if there is no build in progress. Signal the build to stop by the build id.
Types ¶
type BuildState ¶
type BuildState struct {
Frozen bool
ExternExtras map[string]interface{} //will be exported
Extras map[string]interface{}
Servers []int
BuildId string
BuildError CustomError
BuildStage string
DeployProgress uint64
DeployTotal uint64
BuildProgress uint64
BuildTotal uint64
// contains filtered or unexported fields
}
Packages the build state nicely into an object
func GetBuildStateById ¶
func GetBuildStateById(buildId string) (*BuildState, error)
Get the current build state based off the build id. Will given an error if the build is not found
func GetBuildStateByServerId ¶
func GetBuildStateByServerId(serverId int) *BuildState
Get the current build state for a server.
func NewBuildState ¶
func NewBuildState(servers []int, buildId string) *BuildState
func RestoreBuildState ¶
func RestoreBuildState(buildID string) (*BuildState, error)
func (*BuildState) AddFreezePoint ¶
func (this *BuildState) AddFreezePoint(freezePoint float64)
func (*BuildState) Async ¶
func (this *BuildState) Async(fn func())
Set a function to be executed at some point during the build. All these functions must complete before the build is considered finished.
func (*BuildState) Defer ¶
func (this *BuildState) Defer(fn func())
Add a function to be executed asynchronously after the build is completed.
func (*BuildState) Destroy ¶
func (this *BuildState) Destroy() error
func (*BuildState) Done ¶
func (this *BuildState) Done() bool
func (*BuildState) DoneBuilding ¶
func (this *BuildState) DoneBuilding()
DoneBuilding signals that the building process has finished and releases the build lock.
func (*BuildState) ErrorFree ¶
func (this *BuildState) ErrorFree() bool
ErrorFree checks that there has not been an error reported with ReportError
func (*BuildState) FinishDeploy ¶
func (this *BuildState) FinishDeploy()
FinishDeploy signals that the deployment process has finished and the blockchain specific process will begin.
func (*BuildState) Freeze ¶
func (this *BuildState) Freeze() error
func (*BuildState) Get ¶
func (this *BuildState) Get(key string) (interface{}, bool)
func (*BuildState) GetError ¶
func (this *BuildState) GetError() error
GetError gets the currently stored error
func (*BuildState) GetExt ¶
func (this *BuildState) GetExt(key string) (interface{}, bool)
func (*BuildState) GetExtExtras ¶
func (this *BuildState) GetExtExtras() ([]byte, error)
func (*BuildState) GetExtras ¶
func (this *BuildState) GetExtras() map[string]interface{}
func (*BuildState) GetP ¶
func (this *BuildState) GetP(key string, out interface{}) bool
func (*BuildState) GetProgress ¶
func (this *BuildState) GetProgress() float64
func (*BuildState) IncrementBuildProgress ¶
func (this *BuildState) IncrementBuildProgress()
IncrementBuildProgress increments the build progress by one step.
func (*BuildState) IncrementDeployProgress ¶
func (this *BuildState) IncrementDeployProgress()
IncrementDeployProgress increments the deploy process by one step.
func (*BuildState) Marshal ¶
func (this *BuildState) Marshal() string
func (*BuildState) OnError ¶
func (this *BuildState) OnError(fn func())
func (*BuildState) ReportError ¶
func (this *BuildState) ReportError(err error)
ReportError stores the given error to be passed onto any who query the build status.
func (*BuildState) Reset ¶
func (this *BuildState) Reset()
func (*BuildState) Set ¶
func (this *BuildState) Set(key string, value interface{})
func (*BuildState) SetBuildStage ¶
func (this *BuildState) SetBuildStage(stage string)
SetBuildStage updates the text which will be displayed along with the build progress percentage when the status of the build is queried.
func (*BuildState) SetBuildSteps ¶
func (this *BuildState) SetBuildSteps(steps int)
SetBuildSteps sets the number of steps in the blockchain specific build process. Must be equivalent to the number of times IncrementBuildProgress() will be called.
func (*BuildState) SetDeploySteps ¶
func (this *BuildState) SetDeploySteps(steps int)
SetDeploySteps sets the number of steps in the deployment process. Should be given a number equivalent to the number of times IncrementDeployProgress will be called.
func (*BuildState) SetExt ¶
func (this *BuildState) SetExt(key string, value interface{}) error
Insert a value into the state store, currently only supports string and []string on the other side
func (*BuildState) SignalStop ¶
func (this *BuildState) SignalStop() error
SignalStop flags that the current build should be stopped, if there is a current build. Returns an error if there is no build in progress
func (*BuildState) Stop ¶
func (this *BuildState) Stop() bool
Stop checks if the stop signal has been sent. If this returns true, a building process should return. The ssh client checks this for you.
func (*BuildState) Store ¶
func (this *BuildState) Store() error
func (*BuildState) Unfreeze ¶
func (this *BuildState) Unfreeze() error
type CustomError ¶
type CustomError struct {
What string `json:"what"`
// contains filtered or unexported fields
}
This code is full of potential race conditons but these race conditons are extremely rare
CustomError is a custom wrapper for a go error, which has What containing error.Error()