31 lines
694 B
Go
31 lines
694 B
Go
|
package http
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"forge.cadoles.com/arcad/edge/pkg/bus"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
AddressIncomingMessage bus.Address = "http/incoming-message"
|
||
|
AddressOutgoingMessage bus.Address = "http/outgoing-message"
|
||
|
)
|
||
|
|
||
|
type IncomingMessage struct {
|
||
|
Context context.Context
|
||
|
Payload map[string]any
|
||
|
}
|
||
|
|
||
|
func NewIncomingMessageEnvelope(ctx context.Context, payload map[string]any) bus.Envelope {
|
||
|
return bus.NewEnvelope(AddressIncomingMessage, &IncomingMessage{ctx, payload})
|
||
|
}
|
||
|
|
||
|
type OutgoingMessage struct {
|
||
|
SessionID string
|
||
|
Data any
|
||
|
}
|
||
|
|
||
|
func NewOutgoingMessageEnvelope(sessionID string, data any) bus.Envelope {
|
||
|
return bus.NewEnvelope(AddressOutgoingMessage, &OutgoingMessage{sessionID, data})
|
||
|
}
|