messageHelpers

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: Apache-2.0 Imports: 4 Imported by: 6

README

messageHelpers

messageHelpers defines shared message types for inter-service communication — user, session, behaviour, authority, and translation messages.

Types

Type Description
UserMessage User identity payload with Key, Code, Source, Locale, Theme, Timezone, Role, and Payload fields
SessionMessage Session payload with SessionID, Expiry, User, Token, Locale, and Payload fields
BehaviourMessage Behaviour/action payload with Key, Source, and Payload fields
AuthorityMessage Authority envelope with Key, User, Behaviour, Payload, and Source fields
GrantMessage Grant request/response containing User and Behaviour
RevokeMessage Revoke request/response containing User and Behaviour
DeclareMessage Domain behaviour declaration with Domain and Behaviour fields
TranslationMessage Translation request/response with Text, Locale, Origin, Translation, and Payload fields

Methods

Each message type provides Request(...) and Response(...) builder methods.

  • UserMessage and BehaviourMessage also have Validate(*log.Logger) error
  • TranslationMessage has ReponseWithPayload(...) for payload-carrying responses

Example

import "github.com/mt1976/frantic-core/messageHelpers"

func main() {
    user := messageHelpers.UserMessage{}.Request("key", "code", "source")
    session := messageHelpers.SessionMessage{}.Request("sessionID", time.Now(), user)
    _ = session
}

Documentation

Overview

Package messageHelpers defines shared message types used between services and application components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorityMessage added in v1.2.56

type AuthorityMessage struct {
	Key       string           `json:"Key"`
	User      UserMessage      `json:"User"`
	Behaviour BehaviourMessage `json:"Behaviour"`
	Payload   any              `json:"Payload"`
	Source    string           `json:"Source"`
}

type BehaviourMessage added in v1.2.56

type BehaviourMessage struct {
	Key     string `json:"Key"`
	Source  string `json:"Source"`
	Payload any    `json:"Payload"`
}

func (*BehaviourMessage) Validate added in v1.2.58

func (m *BehaviourMessage) Validate(log *log.Logger) error

type DeclareMessage added in v1.2.56

type DeclareMessage struct {
	Domain    string           `json:"Domain"`
	Behaviour BehaviourMessage `json:"Behaviour"`
}

func (*DeclareMessage) Request added in v1.2.56

func (m *DeclareMessage) Request(domain string, behaviour string) DeclareMessage

func (*DeclareMessage) Response added in v1.2.56

func (m *DeclareMessage) Response(payload any) DeclareMessage

type GrantMessage added in v1.2.56

type GrantMessage struct {
	User      UserMessage      `json:"User"`
	Behaviour BehaviourMessage `json:"Behaviour"`
}

func (*GrantMessage) Request added in v1.2.56

func (m *GrantMessage) Request(user UserMessage, behaviour BehaviourMessage) GrantMessage

func (*GrantMessage) Response added in v1.2.56

func (m *GrantMessage) Response(payload any) GrantMessage

type RevokeMessage added in v1.2.56

type RevokeMessage struct {
	User      UserMessage      `json:"User"`
	Behaviour BehaviourMessage `json:"Behaviour"`
}

func (*RevokeMessage) Request added in v1.2.56

func (m *RevokeMessage) Request(user UserMessage, behaviour BehaviourMessage) RevokeMessage

func (*RevokeMessage) Response added in v1.2.56

func (m *RevokeMessage) Response(payload any) RevokeMessage

type SessionMessage

type SessionMessage struct {
	SessionID    string      `json:"SessionID"`
	Expiry       time.Time   `json:"Expiry"`
	UserKey      string      `json:"UserKey"`
	UserCode     string      `json:"UserCode"`
	SessionToken any         `json:"SessionToken"`
	User         UserMessage `json:"User"`
	Payload      any         `json:"Payload"`
	Locale       string      `json:"Locale"`
	Spare1       string      `json:"Spare1"`
	Spare2       string      `json:"Spare2"`
}

func (*SessionMessage) Request added in v1.2.56

func (m *SessionMessage) Request(sessionID string, expiry time.Time, user UserMessage) SessionMessage

func (*SessionMessage) Response added in v1.2.56

func (m *SessionMessage) Response(payload any) SessionMessage

type TranslationMessage added in v1.2.56

type TranslationMessage struct {
	Text        string `json:"Text"`
	Locale      string `json:"Locale"`
	Origin      string `json:"Origin"`
	Translation string `json:"Translation"`
	Payload     any    `json:"Payload"`
}

func (*TranslationMessage) ReponseWithPayload added in v1.2.56

func (m *TranslationMessage) ReponseWithPayload(translation string, payload any) TranslationMessage

func (*TranslationMessage) Request added in v1.2.56

func (m *TranslationMessage) Request(text string, locale string, origin string) TranslationMessage

func (*TranslationMessage) Response added in v1.2.56

func (m *TranslationMessage) Response(translation string) TranslationMessage

type UserMessage

type UserMessage struct {
	Key      string `json:"Key"`
	Code     string `json:"Code"`
	Payload  any    `json:"Payload"`
	Source   string `json:"Source"`
	Locale   string `json:"Locale"`
	Theme    string `json:"Theme"`
	Timezone string `json:"Timezone"`
	Role     string `json:"Role"`
	Spare0   string `json:"Spare0"`
	Spare1   string `json:"Spare1"`
	Spare2   string `json:"Spare2"`
}

func (*UserMessage) Request added in v1.2.56

func (m *UserMessage) Request(key, code, source, locale, theme, timezone, role string) UserMessage

func (*UserMessage) Response added in v1.2.56

func (m *UserMessage) Response(payload any) UserMessage

func (*UserMessage) Validate added in v1.2.56

func (m *UserMessage) Validate(log *log.Logger) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL