Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateURL(subPath string, m *Machine) (URL *url.URL, err error)
- type BasicMessage
- type Email
- type Event
- type EventData
- type Hook
- type Issuing
- type Machine
- func (m *Machine) Answers(q *agency.Question) *Transition
- func (m *Machine) CurrentState() *State
- func (m *Machine) Initialize() (err error)
- func (m *Machine) Start() []*Event
- func (m *Machine) Step(t *Transition)
- func (m *Machine) String() string
- func (m *Machine) Triggers(status *agency.ProtocolStatus) *Transition
- func (m *Machine) TriggersByHook() *Transition
- type MachineData
- type NotificationType
- type Proof
- type ProofAttr
- type State
- type Transition
- func (t *Transition) BuildSendAnswers(status *agency.AgentStatus) []*Event
- func (t *Transition) BuildSendEvents(status *agency.ProtocolStatus) []*Event
- func (t *Transition) BuildSendEventsFromHook(hookData map[string]string) []*Event
- func (t *Transition) FmtFromMem(send *Event) string
- func (t *Transition) GenPIN(_ *Event)
Constants ¶
View Source
const ( TriggerTypeOurMessage = "OUR_STATUS" TriggerTypeUseInput = "INPUT" // works like echo TriggerTypeUseInputSave = "INPUT_SAVE" // saves input data TriggerTypeFormat = "FORMAT" TriggerTypeFormatFromMem = "FORMAT_MEM" TriggerTypePIN = "GEN_PIN" TriggerTypeData = "" TriggerTypeValidateInputEqual = "INPUT_VALIDATE_EQUAL" TriggerTypeValidateInputNotEqual = "INPUT_VALIDATE_NOT_EQUAL" TriggerTypeInputEqual = "INPUT_EQUAL" TriggerTypeAcceptAndInputValues = "ACCEPT_AND_INPUT_VALUES" TriggerTypeNotAcceptValues = "NOT_ACCEPT_VALUES" )
View Source
const ( MessageNone = "" MessageBasicMessage = "basic_message" MessageIssueCred = "issue_cred" MessageTrustPing = "trust_ping" MessagePresentProof = "present_proof" MessageConnection = "connection" MessageAnswer = "answer" MessageEmail = "email" MessageHook = "hook" )
View Source
const ( EmailProtocol = 100 QAProtocol = 101 HookProtocol = 102 )
Variables ¶
View Source
var ProtocolType = map[string]agency.Protocol_Type{ MessageNone: agency.Protocol_NONE, MessageConnection: agency.Protocol_DIDEXCHANGE, MessageIssueCred: agency.Protocol_ISSUE_CREDENTIAL, MessagePresentProof: agency.Protocol_PRESENT_PROOF, MessageTrustPing: agency.Protocol_TRUST_PING, MessageBasicMessage: agency.Protocol_BASIC_MESSAGE, MessageEmail: EmailProtocol, MessageAnswer: QAProtocol, MessageHook: HookProtocol, }
View Source
var QuestionTypeID = map[string]agency.Question_Type{ "ANSWER_NEEDED_PING": agency.Question_PING_WAITS, "ANSWER_NEEDED_ISSUE_PROPOSE": agency.Question_ISSUE_PROPOSE_WAITS, "ANSWER_NEEDED_PROOF_PROPOSE": agency.Question_PROOF_PROPOSE_WAITS, "ANSWER_NEEDED_PROOF_VERIFY": agency.Question_PROOF_VERIFY_WAITS, }
Functions ¶
Types ¶
type BasicMessage ¶
type BasicMessage struct {
Content string
}
type Event ¶
type Event struct { Protocol string `json:"protocol"` // Note! See ProtocolType below TypeID string `json:"type_id"` // Note! See NotificationType below Rule string `json:"rule"` Data string `json:"data,omitempty"` NoStatus bool `json:"no_status,omitempty"` *EventData `json:"event_data,omitempty"` ProtocolType agency.Protocol_Type `json:"-"` NotificationType NotificationType `json:"-"` *agency.ProtocolStatus `json:"-"` *Transition `json:"-"` }
func (Event) TriggersByHook ¶
type EventData ¶
type EventData struct { BasicMessage *BasicMessage `json:"basic_message,omitempty"` Issuing *Issuing `json:"issuing,omitempty"` Email *Email `json:"email,omitempty"` Proof *Proof `json:"proof,omitempty"` Hook *Hook `json:"hook,omitempty"` }
type Machine ¶
type Machine struct { Name string `json:"name,omitempty"` Initial *Transition `json:"initial"` States map[string]*State `json:"states"` Current string `json:"-"` Initialized bool `json:"-"` Memory map[string]string `json:"-"` }
func NewMachine ¶
func NewMachine(data MachineData) *Machine
func (*Machine) CurrentState ¶
func (*Machine) Initialize ¶
Initialize initializes and optimizes the state machine because the JSON is meant for humans to write and machines to read. Initialize also moves machine to the initial state. It returns error if machine has them.
func (*Machine) Step ¶
func (m *Machine) Step(t *Transition)
func (*Machine) Triggers ¶
func (m *Machine) Triggers(status *agency.ProtocolStatus) *Transition
Triggers returns a transition if machine has it in its current state. If not it returns nil.
func (*Machine) TriggersByHook ¶
func (m *Machine) TriggersByHook() *Transition
TriggersByHook returns a transition if machine has it in its current state. If not it returns nil.
type MachineData ¶
type NotificationType ¶
type NotificationType int32
func NotificationTypeID ¶
func NotificationTypeID(typeName string) NotificationType
type State ¶
type State struct {
Transitions []*Transition `json:"transitions"`
}
type Transition ¶
type Transition struct { Trigger *Event `json:"trigger,omitempty"` Sends []*Event `json:"sends,omitempty"` Target string `json:"target"` Machine *Machine `json:"-"` }
func (*Transition) BuildSendAnswers ¶
func (t *Transition) BuildSendAnswers(status *agency.AgentStatus) []*Event
func (*Transition) BuildSendEvents ¶
func (t *Transition) BuildSendEvents(status *agency.ProtocolStatus) []*Event
func (*Transition) BuildSendEventsFromHook ¶
func (t *Transition) BuildSendEventsFromHook(hookData map[string]string) []*Event
func (*Transition) FmtFromMem ¶
func (t *Transition) FmtFromMem(send *Event) string
func (*Transition) GenPIN ¶
func (t *Transition) GenPIN(_ *Event)
Click to show internal directories.
Click to hide internal directories.