Documentation ¶
Index ¶
- Constants
- Variables
- func CompressMessage(message *Message, level int) error
- func DecodeObject(data []byte, object BankObject) error
- func DecompressMessage(message *Message) error
- func DecryptMessageFrom(ctx context.Context, to *security.Key, from security.EncryptionPublicKey, ...) error
- func EncodeObject(object BankObject) ([]byte, error)
- func EncryptMessageFor(ctx context.Context, from *security.Key, to security.EncryptionPublicKey, ...) error
- func FromMessage(message *Message, object BankObject) error
- func RequestMessage(ctx context.Context, appName string, subject string, req, resp BankObject) error
- func SignMessage(ctx context.Context, key *security.Key, message *Message) error
- func ToNats(messaging Messaging) *nats.Conn
- func VerifyMessageSignature(key security.SignaturePublicKey, message *Message) (bool, error)
- func WithMessaging(ctx context.Context, messaging Messaging) context.Context
- type BankObject
- type Message
- func (m *Message) Decode(data []byte) error
- func (m *Message) Encode() ([]byte, error)
- func (m *Message) IsCompressed() bool
- func (m *Message) IsEncrypted() bool
- func (m *Message) IsSigned() bool
- func (m *Message) SetCompressed(compressed bool)
- func (m *Message) SetEncrypted(encrypted bool)
- func (m *Message) SetSigned(signed bool)
- type MessageFlag
- type MessageHandler
- type Messaging
- type NC
- type RequestHandler
Constants ¶
View Source
const (
CurrentVersion = "1.0"
)
View Source
const (
MessagingKey = "Key.MessagingKey"
)
Variables ¶
View Source
var ( ErrHandleRequest = errors.New("Request handle failed") ErrRequestFailed = errors.New("Request Failed") )
Functions ¶
func CompressMessage ¶ added in v0.1.0
func DecodeObject ¶ added in v0.1.0
func DecodeObject(data []byte, object BankObject) error
Decode store BankObject from bytes. Decoded with gob
func DecompressMessage ¶ added in v0.1.0
func DecryptMessageFrom ¶ added in v0.1.0
func EncodeObject ¶ added in v0.1.0
func EncodeObject(object BankObject) ([]byte, error)
encode return bytes from BankObject. Encoded with gob
func EncryptMessageFor ¶ added in v0.1.0
func FromMessage ¶ added in v0.1.0
func FromMessage(message *Message, object BankObject) error
func RequestMessage ¶ added in v0.0.2
func SignMessage ¶ added in v0.1.0
func VerifyMessageSignature ¶ added in v0.1.0
func VerifyMessageSignature(key security.SignaturePublicKey, message *Message) (bool, error)
Types ¶
type BankObject ¶ added in v0.1.0
type Message ¶ added in v0.1.0
type Message struct { Version string // Version for compatibility From string `json:",omitempty"` // From is the public key of sender Data []byte `json:",omitempty"` // Data payload Flags uint `json:",omitempty"` // Flags for Compressed, Encrypted, Signed Error string `json:",omitempty"` // Error in message processing }
Message used for all communication between components
func HandleRequest ¶ added in v0.0.2
func HandleRequest(ctx context.Context, appName string, message *Message, request BankObject, handle RequestHandler) (*Message, error)
func NewMessage ¶ added in v0.1.0
func NewMessage() *Message
func ToMessage ¶ added in v0.1.0
func ToMessage(from string, object BankObject) *Message
func (*Message) IsCompressed ¶ added in v0.1.0
func (*Message) IsEncrypted ¶ added in v0.1.0
func (*Message) SetCompressed ¶ added in v0.1.0
func (*Message) SetEncrypted ¶ added in v0.1.0
type MessageFlag ¶ added in v0.1.0
type MessageFlag uint32
type MessageHandler ¶ added in v0.1.0
type Messaging ¶ added in v0.1.0
type Messaging interface { NC() NC SubscribeWorkers(ctx context.Context, subject string, workerCount int, handle MessageHandler) Subscribe(ctx context.Context, subject string, handle MessageHandler) Publish(ctx context.Context, subject string, message *Message) error Request(ctx context.Context, subject string, message *Message) (*Message, error) RequestWithTimeout(ctx context.Context, subject string, message *Message, timeout time.Duration) (*Message, error) }
func FromContext ¶ added in v0.1.0
type RequestHandler ¶ added in v0.0.2
type RequestHandler func(ctx context.Context, request BankObject) (BankObject, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.