Documentation ¶
Index ¶
Constants ¶
const ( ErrChannelRegistered = serviceError("channel is already registered for the action event") ErrNilChannel = serviceError("cannot pass nil channel") ErrInvalidChannel = serviceError("invalid channel passed to unregister the action event") ErrThreadIDNotFound = serviceError("threadID not found") ErrInvalidMessage = serviceError("invalid message") ErrNoHeader = serviceError("the header is not provided") )
Service errors
Variables ¶
This section is empty.
Functions ¶
func AutoExecuteActionEvent ¶
func AutoExecuteActionEvent(ch chan DIDCommAction) error
AutoExecuteActionEvent is a utility function to execute Action events automatically. The function requires a channel to be passed-in to listen to dispatcher.DIDCommAction and triggers the Continue function on the action event. This is a blocking function and use this function with a goroutine.
Usage:
s := didexchange.New(....) actionCh := make(chan dispatcher.DIDCommAction) err = s.RegisterActionEvent(actionCh) go service.AutoExecuteActionEvent(actionCh)
Types ¶
type Action ¶
type Action struct {
// contains filtered or unexported fields
}
Action thread-safe action register structure
func (*Action) ActionEvent ¶
func (a *Action) ActionEvent() chan<- DIDCommAction
ActionEvent returns event action channel
func (*Action) RegisterActionEvent ¶
func (a *Action) RegisterActionEvent(ch chan<- DIDCommAction) error
RegisterActionEvent on protocol messages. The consumer need to invoke the callback to resume processing. Only one channel can be registered for the action events. The function will throw error if a channel is already registered.
func (*Action) UnregisterActionEvent ¶
func (a *Action) UnregisterActionEvent(ch chan<- DIDCommAction) error
UnregisterActionEvent on protocol messages. Refer RegisterActionEvent().
type DIDCommAction ¶
type DIDCommAction struct { // Name of the protocol. // // Supported protocols // - DID Exchange : didexchange.DIDExchange ProtocolName string // DIDComm message Message *DIDCommMsg // Continue function to be called by the consumer for further processing the message. Continue func(args interface{}) // Stop invocation notifies the service that the consumer action event processing has failed or the consumer wants // to stop the processing. Stop func(err error) // Properties contains value based on specific protocol. The consumers need to call the protocol client // functions to get the data. // // Clients function to retrieve data based on protocol. // - DID Exchange : didexchange.EventProperties Properties EventProperties }
DIDCommAction message type to pass events in go channels.
type DIDCommMsg ¶
DIDCommMsg did comm msg
func NewDIDCommMsg ¶
func NewDIDCommMsg(payload []byte) (*DIDCommMsg, error)
NewDIDCommMsg returns DIDCommMsg with Header
func (*DIDCommMsg) Clone ¶
func (m *DIDCommMsg) Clone() *DIDCommMsg
Clone creates new DIDCommMsg with the same data the cloned message is safe for delivering to the client it prevents modifying by the client
func (*DIDCommMsg) ThreadID ¶
func (m *DIDCommMsg) ThreadID() (string, error)
ThreadID returns msg ~thread.thid if there is no ~thread.thid returns msg @id message is invalid if ~thread.thid exist and @id is absent NOTE: Header field should be filled before calling ThreadID func it can be done by using NewDIDCommMsg([]byte) func or directly set a Header value
type Destination ¶
Destination provides the recipientKeys, routingKeys, and serviceEndpoint populated from Invitation
type Event ¶
type Event interface { // RegisterActionEvent on protocol messages. The events are triggered for incoming message types based on // the protocol service. The consumer need to invoke the callback to resume processing. // Only one channel can be registered for the action events. The function will throw error if a channel is already // registered. RegisterActionEvent(ch chan<- DIDCommAction) error // UnregisterActionEvent on protocol messages. Refer RegisterActionEvent(). UnregisterActionEvent(ch chan<- DIDCommAction) error // RegisterMsgEvent on protocol messages. The message events are triggered for incoming messages. Service // will not expect any callback on these events unlike Action event. RegisterMsgEvent(ch chan<- StateMsg) error // UnregisterMsgEvent on protocol messages. Refer RegisterMsgEvent(). UnregisterMsgEvent(ch chan<- StateMsg) error }
Event event related apis.
type EventProperties ¶
type EventProperties interface{}
EventProperties type for event related data.
type Handler ¶
type Handler interface { // HandleInbound handles inbound messages. HandleInbound(msg *DIDCommMsg) (string, error) // HandleOutbound handles outbound messages. HandleOutbound(msg *DIDCommMsg, dest *Destination) error }
Handler provides protocol service handle api.
type Header ¶
type Header struct { ID string `json:"@id"` Thread decorator.Thread `json:"~thread"` Type string `json:"@type"` }
Header helper structure which keeps reusable fields
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message thread-safe message register structure
func (*Message) RegisterMsgEvent ¶
RegisterMsgEvent on protocol messages. The message events are triggered for incoming messages. Event will not expect any callback on these events unlike Action events.
func (*Message) UnregisterMsgEvent ¶
UnregisterMsgEvent on protocol messages. Refer RegisterMsgEvent().
type StateMsg ¶
type StateMsg struct { // Name of the protocol. // // Supported protocols // - DID Exchange : didexchange.DIDExchange ProtocolName string // type of the message (pre or post), refer service.StateMsgType Type StateMsgType // current state. Refer protocol RFC for possible states. StateID string // DIDComm message along with message type Msg *DIDCommMsg // Properties contains value based on specific protocol. The consumers need to call the protocol client // functions to get the data. // // Clients function to retrieve data based on protocol. // - DID Exchange : didexchange.Event Properties EventProperties }
StateMsg is used in MsgEvent to pass the state details to the consumer. Refer service.Event.RegisterMsgEvent for more details.
type StateMsgType ¶
type StateMsgType int
StateMsgType state msg type
const ( // PreState pre state PreState StateMsgType = iota // PostState post state PostState )