Documentation ¶
Index ¶
- Variables
- func Pulse(ctx context.Context) insolar.PulseNumber
- func TestContextWithPulse(ctx context.Context, pn insolar.PulseNumber) context.Context
- type Flow
- type FlowMock
- func (mmContinue *FlowMock) Continue(ctx context.Context)
- func (mmContinue *FlowMock) ContinueAfterCounter() uint64
- func (mmContinue *FlowMock) ContinueBeforeCounter() uint64
- func (mmHandle *FlowMock) Handle(ctx context.Context, h1 Handle) (err error)
- func (mmHandle *FlowMock) HandleAfterCounter() uint64
- func (mmHandle *FlowMock) HandleBeforeCounter() uint64
- func (mmMigrate *FlowMock) Migrate(ctx context.Context, h1 Handle) (err error)
- func (mmMigrate *FlowMock) MigrateAfterCounter() uint64
- func (mmMigrate *FlowMock) MigrateBeforeCounter() uint64
- func (m *FlowMock) MinimockContinueDone() bool
- func (m *FlowMock) MinimockContinueInspect()
- func (m *FlowMock) MinimockFinish()
- func (m *FlowMock) MinimockHandleDone() bool
- func (m *FlowMock) MinimockHandleInspect()
- func (m *FlowMock) MinimockMigrateDone() bool
- func (m *FlowMock) MinimockMigrateInspect()
- func (m *FlowMock) MinimockProcedureDone() bool
- func (m *FlowMock) MinimockProcedureInspect()
- func (m *FlowMock) MinimockWait(timeout mm_time.Duration)
- func (mmProcedure *FlowMock) Procedure(ctx context.Context, proc Procedure, cancelable bool) (err error)
- func (mmProcedure *FlowMock) ProcedureAfterCounter() uint64
- func (mmProcedure *FlowMock) ProcedureBeforeCounter() uint64
- type FlowMockContinueExpectation
- type FlowMockContinueParams
- type FlowMockHandleExpectation
- type FlowMockHandleParams
- type FlowMockHandleResults
- type FlowMockMigrateExpectation
- type FlowMockMigrateParams
- type FlowMockMigrateResults
- type FlowMockProcedureExpectation
- type FlowMockProcedureParams
- type FlowMockProcedureResults
- type Handle
- type MakeHandle
- type Procedure
- type ProcedureMock
- func (m *ProcedureMock) MinimockFinish()
- func (m *ProcedureMock) MinimockProceedDone() bool
- func (m *ProcedureMock) MinimockProceedInspect()
- func (m *ProcedureMock) MinimockWait(timeout mm_time.Duration)
- func (mmProceed *ProcedureMock) Proceed(ctx context.Context) (err error)
- func (mmProceed *ProcedureMock) ProceedAfterCounter() uint64
- func (mmProceed *ProcedureMock) ProceedBeforeCounter() uint64
- type ProcedureMockProceedExpectation
- type ProcedureMockProceedParams
- type ProcedureMockProceedResults
Constants ¶
This section is empty.
Variables ¶
var ErrCancelled = errors.New("flow cancelled")
Functions ¶
func TestContextWithPulse ¶
Types ¶
type Flow ¶
type Flow interface { // Handle gives control to another handle and waits for its return. Consider it "calling" another dispatcher. Handle(context.Context, Handle) error // Procedure starts a routine and blocks Handle execution until cancellation happens or routine returns. // If cancellation happens first, ErrCancelled will immediately be returned to the Handle. The Procedure // continues to execute in the background, but it's state must be discarded by the Handle as invalid. // If Routine returns first, Procedure error (if any) will be returned. // Procedure can figure out whether it's execution was canceled and there is no point to continue // the execution by reading from context.Done() Procedure(ctx context.Context, proc Procedure, cancelable bool) error // Migrate blocks caller execution until cancellation happens then runs provided Handle in a new flow. // Note that this method can be called after cancellation. Use it to migrate processing after Handle or Procedure // returned ErrCancelled. // // IMPORTANT: Migrate can be called only once per flow. Calling it the second time will result in error. Migrate(context.Context, Handle) error // Continue blocks caller execution until cancellation happens then updates 'cancel' and returns control to caller. // It might be called multiple times, but each time it will wait for cancellation. // Might be used to continue processing in Handle after Procedure returns ErrCancelled Continue(context.Context) }
Flow will be pasted to all Handles to control execution. This is very important not to blow this interface. Keep it minimal.
type FlowMock ¶
type FlowMock struct { ContinueMock mFlowMockContinue HandleMock mFlowMockHandle MigrateMock mFlowMockMigrate ProcedureMock mFlowMockProcedure // contains filtered or unexported fields }
FlowMock implements Flow
func NewFlowMock ¶
NewFlowMock returns a mock for Flow
func (*FlowMock) ContinueAfterCounter ¶
ContinueAfterCounter returns a count of finished FlowMock.Continue invocations
func (*FlowMock) ContinueBeforeCounter ¶
ContinueBeforeCounter returns a count of FlowMock.Continue invocations
func (*FlowMock) HandleAfterCounter ¶
HandleAfterCounter returns a count of finished FlowMock.Handle invocations
func (*FlowMock) HandleBeforeCounter ¶
HandleBeforeCounter returns a count of FlowMock.Handle invocations
func (*FlowMock) MigrateAfterCounter ¶
MigrateAfterCounter returns a count of finished FlowMock.Migrate invocations
func (*FlowMock) MigrateBeforeCounter ¶
MigrateBeforeCounter returns a count of FlowMock.Migrate invocations
func (*FlowMock) MinimockContinueDone ¶
MinimockContinueDone returns true if the count of the Continue invocations corresponds the number of defined expectations
func (*FlowMock) MinimockContinueInspect ¶
func (m *FlowMock) MinimockContinueInspect()
MinimockContinueInspect logs each unmet expectation
func (*FlowMock) MinimockFinish ¶
func (m *FlowMock) MinimockFinish()
MinimockFinish checks that all mocked methods have been called the expected number of times
func (*FlowMock) MinimockHandleDone ¶
MinimockHandleDone returns true if the count of the Handle invocations corresponds the number of defined expectations
func (*FlowMock) MinimockHandleInspect ¶
func (m *FlowMock) MinimockHandleInspect()
MinimockHandleInspect logs each unmet expectation
func (*FlowMock) MinimockMigrateDone ¶
MinimockMigrateDone returns true if the count of the Migrate invocations corresponds the number of defined expectations
func (*FlowMock) MinimockMigrateInspect ¶
func (m *FlowMock) MinimockMigrateInspect()
MinimockMigrateInspect logs each unmet expectation
func (*FlowMock) MinimockProcedureDone ¶
MinimockProcedureDone returns true if the count of the Procedure invocations corresponds the number of defined expectations
func (*FlowMock) MinimockProcedureInspect ¶
func (m *FlowMock) MinimockProcedureInspect()
MinimockProcedureInspect logs each unmet expectation
func (*FlowMock) MinimockWait ¶
MinimockWait waits for all mocked methods to be called the expected number of times
func (*FlowMock) Procedure ¶
func (mmProcedure *FlowMock) Procedure(ctx context.Context, proc Procedure, cancelable bool) (err error)
Procedure implements Flow
func (*FlowMock) ProcedureAfterCounter ¶
ProcedureAfterCounter returns a count of finished FlowMock.Procedure invocations
func (*FlowMock) ProcedureBeforeCounter ¶
ProcedureBeforeCounter returns a count of FlowMock.Procedure invocations
type FlowMockContinueExpectation ¶
type FlowMockContinueExpectation struct { Counter uint64 // contains filtered or unexported fields }
FlowMockContinueExpectation specifies expectation struct of the Flow.Continue
type FlowMockContinueParams ¶
type FlowMockContinueParams struct {
// contains filtered or unexported fields
}
FlowMockContinueParams contains parameters of the Flow.Continue
type FlowMockHandleExpectation ¶
type FlowMockHandleExpectation struct { Counter uint64 // contains filtered or unexported fields }
FlowMockHandleExpectation specifies expectation struct of the Flow.Handle
func (*FlowMockHandleExpectation) Then ¶
func (e *FlowMockHandleExpectation) Then(err error) *FlowMock
Then sets up Flow.Handle return parameters for the expectation previously defined by the When method
type FlowMockHandleParams ¶
type FlowMockHandleParams struct {
// contains filtered or unexported fields
}
FlowMockHandleParams contains parameters of the Flow.Handle
type FlowMockHandleResults ¶
type FlowMockHandleResults struct {
// contains filtered or unexported fields
}
FlowMockHandleResults contains results of the Flow.Handle
type FlowMockMigrateExpectation ¶
type FlowMockMigrateExpectation struct { Counter uint64 // contains filtered or unexported fields }
FlowMockMigrateExpectation specifies expectation struct of the Flow.Migrate
func (*FlowMockMigrateExpectation) Then ¶
func (e *FlowMockMigrateExpectation) Then(err error) *FlowMock
Then sets up Flow.Migrate return parameters for the expectation previously defined by the When method
type FlowMockMigrateParams ¶
type FlowMockMigrateParams struct {
// contains filtered or unexported fields
}
FlowMockMigrateParams contains parameters of the Flow.Migrate
type FlowMockMigrateResults ¶
type FlowMockMigrateResults struct {
// contains filtered or unexported fields
}
FlowMockMigrateResults contains results of the Flow.Migrate
type FlowMockProcedureExpectation ¶
type FlowMockProcedureExpectation struct { Counter uint64 // contains filtered or unexported fields }
FlowMockProcedureExpectation specifies expectation struct of the Flow.Procedure
func (*FlowMockProcedureExpectation) Then ¶
func (e *FlowMockProcedureExpectation) Then(err error) *FlowMock
Then sets up Flow.Procedure return parameters for the expectation previously defined by the When method
type FlowMockProcedureParams ¶
type FlowMockProcedureParams struct {
// contains filtered or unexported fields
}
FlowMockProcedureParams contains parameters of the Flow.Procedure
type FlowMockProcedureResults ¶
type FlowMockProcedureResults struct {
// contains filtered or unexported fields
}
FlowMockProcedureResults contains results of the Flow.Procedure
type Handle ¶
Handle is a one-function synchronous process that can call routines to do long processing. IMPORTANT: Asynchronous code is NOT ALLOWED here. To create a new Handle of a given message use dispatcher.NewHandler procedure. You can find an example in insolar/ladger/artifactmanager/dispatcher.go
type MakeHandle ¶
MakeHandle is a function that constructs new Handle.
type Procedure ¶
type Procedure interface { // Proceed is called when Procedure is given control. When it returns, control will be given back to Handle. Proceed(context.Context) error }
Procedure is a task that can execute itself. Please note that the Procedure is marked as canceled if a pulse happens during it's execution. This means that it continues to execute in the background, though it's return value will be discarded. Thus if you have multiple steps that can be executed in different pulses split them into separate Procedures. Otherwise join the steps into a single Procedure. It's a good idea to keep Procedures in a separate package to hide internal state from Handle.
type ProcedureMock ¶
type ProcedureMock struct { ProceedMock mProcedureMockProceed // contains filtered or unexported fields }
ProcedureMock implements Procedure
func NewProcedureMock ¶
func NewProcedureMock(t minimock.Tester) *ProcedureMock
NewProcedureMock returns a mock for Procedure
func (*ProcedureMock) MinimockFinish ¶
func (m *ProcedureMock) MinimockFinish()
MinimockFinish checks that all mocked methods have been called the expected number of times
func (*ProcedureMock) MinimockProceedDone ¶
func (m *ProcedureMock) MinimockProceedDone() bool
MinimockProceedDone returns true if the count of the Proceed invocations corresponds the number of defined expectations
func (*ProcedureMock) MinimockProceedInspect ¶
func (m *ProcedureMock) MinimockProceedInspect()
MinimockProceedInspect logs each unmet expectation
func (*ProcedureMock) MinimockWait ¶
func (m *ProcedureMock) MinimockWait(timeout mm_time.Duration)
MinimockWait waits for all mocked methods to be called the expected number of times
func (*ProcedureMock) Proceed ¶
func (mmProceed *ProcedureMock) Proceed(ctx context.Context) (err error)
Proceed implements Procedure
func (*ProcedureMock) ProceedAfterCounter ¶
func (mmProceed *ProcedureMock) ProceedAfterCounter() uint64
ProceedAfterCounter returns a count of finished ProcedureMock.Proceed invocations
func (*ProcedureMock) ProceedBeforeCounter ¶
func (mmProceed *ProcedureMock) ProceedBeforeCounter() uint64
ProceedBeforeCounter returns a count of ProcedureMock.Proceed invocations
type ProcedureMockProceedExpectation ¶
type ProcedureMockProceedExpectation struct { Counter uint64 // contains filtered or unexported fields }
ProcedureMockProceedExpectation specifies expectation struct of the Procedure.Proceed
func (*ProcedureMockProceedExpectation) Then ¶
func (e *ProcedureMockProceedExpectation) Then(err error) *ProcedureMock
Then sets up Procedure.Proceed return parameters for the expectation previously defined by the When method
type ProcedureMockProceedParams ¶
type ProcedureMockProceedParams struct {
// contains filtered or unexported fields
}
ProcedureMockProceedParams contains parameters of the Procedure.Proceed
type ProcedureMockProceedResults ¶
type ProcedureMockProceedResults struct {
// contains filtered or unexported fields
}
ProcedureMockProceedResults contains results of the Procedure.Proceed