prot

package
v0.25.2 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const StatusReady = "ready"
View Source
const StatusWaiting = "waiting"

Variables

This section is empty.

Functions

func AddAndSetFlagUpdatePSM

func AddAndSetFlagUpdatePSM(
	machineKey psm.StateKey,
	subState psm.SubState,
	unsetSubState psm.SubState) (err error)

AddFlagUpdatePSM updates existing PSM by adding a sub-state with state flag:

lastSubState | subState  => adding a new sub state flag to last one

and if needed sub-state can be cleared before adding a new one:

lastSubState = lastSubState ^& unsetSubState

func AddContinuator

func AddContinuator(t string, proc comm.ProtProc)

func AddCreator added in v0.24.29

func AddCreator(t string, proc comm.ProtProc)

AddStarter adds association between CA API message type and protocol. The association is used to start protocol with FindAndStart function.

func AddStarter

func AddStarter(t string, proc comm.ProtProc)

func AddStatusProvider

func AddStatusProvider(t string, proc comm.ProtProc)

func Continue

func Continue(packet comm.Packet, im didcomm.Msg)

func ContinuePSM

func ContinuePSM(ts Again) (err error)

ContinuePSM continues PSM when, usually user, has answered what do with the protocol. According to the Aries protocol spec there are messages that need to be verified by user if they can be continued. With this function user's decision is given to the PSM. The PSM can continue or it can send NACK to other end and terminate. All that's defined in Again struct.

func CreateTask added in v0.24.29

func CreateTask(header *comm.TaskHeader, protocol *pb.Protocol) (t comm.Task, err error)

func ExecPSM

func ExecPSM(ts Transition) (err error)

ExecPSM is a generic protocol handler function for PSM transitions. ts will guide the the execution. Note! that MHandler should return false in all of the NACK cases: when receiving NACK even not responding, and when terminating current PSM with NACK.

func FindAndStartTask

func FindAndStartTask(receiver comm.Receiver, task comm.Task)

FindAndStartTask start the protocol by using CA API Type in the packet.PL.

func GetStatus

func GetStatus(protocol string, key *psm.StateKey) interface{}

func NotifyEdge

func NotifyEdge(ne notifyEdge)

NotifyEdge sends notification to CA's controllores.

func Resume

func Resume(rcvr comm.Receiver, typeID, protocolID string, ack bool)

func StartPSM

func StartPSM(ts Initial) (err error)

StartPSM starts the protocol state machine according to Initial struct by finally sending the protocol message. During the processing the Initial data, the function calls the Save callback where the caller can perform needed processing.

func UpdatePSM

func UpdatePSM(meDID, msgMe string, task comm.Task, opl didcomm.Payload, subs psm.SubState) (err error)

UpdatePSM adds new sub state to PSM with timestamp and all the working data. The PSM key is meDID (worker agent) and the task.Nonce. The PSM includes all state history.

meDID = handling agent DID i.e. worker agent DID
msgMe = our end's connection aka pairwise DID (important!)
task  = current comm.Task struct for additional protocol information
opl   = output payload we are building to send, state by state
subs  = current sub state of the protocol state machine (PSM)

Types

type Again

type Again struct {
	CA          comm.Receiver // the start CA
	InMsg       didcomm.Msg   // Client data
	SendNext    string        // the type of the PL we will send next if any
	WaitingNext string        // the type of the PL we will wait if any
	SendOnNACK  string        // the type to send when we NACK
	Transfer                  // input/output protocol msg
}

type InOut

type InOut func(connID string, im, om didcomm.MessageHdr) (ack bool, err error)

TransitionHandler is a type for Transition to process PSM state transition. It receivers input msg and produce output msg. Implementor should return false if it wants to NACK otherwise true.

type Initial

type Initial struct {
	SendNext    string        // the type of the PL we will send next if any
	WaitingNext string        // the type of the PL we will wait if any
	Ca          comm.Receiver // the start CA
	T           comm.Task     // the start TAsk
	Setup                     // setup & save the msg data at the PSM start
}

Initial is a PSM starting config. It will init PSM accordingly. What msg send next and what message wait for. It has Save handler where PSM persistence can be handled

type Setup

type Setup func(key psm.StateKey, msg didcomm.MessageHdr) (err error)

type TaskStatus

type TaskStatus struct {
	ID                string      `json:"id"`
	Type              string      `json:"type"`
	Status            string      `json:"status"`
	Name              string      `json:"name"`
	TimestampMs       uint64      `json:"timestamp"`
	PendingUserAction bool        `json:"pendingUserAction"`
	Payload           interface{} `json:"payload"`
}

func StatusForTask

func StatusForTask(workerDID string, taskID string) *TaskStatus

type Transfer

type Transfer func(wa comm.Receiver, im, om didcomm.MessageHdr) (ack bool, err error)

type Transition

type Transition struct {
	comm.Packet
	SendNext    string // the type of the PL we will send next if any
	WaitingNext string // the type of the PL we will wait if any
	SendOnNACK  string // the type to send when we NACK
	InOut              // the handler func, NOTE! return false in all NACK cases
}

Transition is a Protocol State Machine transition definition. It combines rules to execute state transition i.e. move to next state.

Jump to

Keyboard shortcuts

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