prot

package
v0.30.29 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

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)

AddCreator 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 ContinuePSM

func ContinuePSM(shift 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 FillStatus added in v0.25.13

func FillStatus(protocol string, key psm.StateKey, ps *pb.ProtocolStatus) *pb.ProtocolStatus

func FindAndStartTask

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

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

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(
	agentDID,
	connID string,
	task comm.Task,
	opl didcomm.Payload,
	stateType 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
connID = connection ID
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

	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)

InOut 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 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
	TaskHeader  *comm.TaskHeader // updated task data
}

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