messages

package
v0.0.0-...-0451d2a Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidMessageID   = errors.New("invalid message id")
	ErrInvalidRoomID      = errors.New("invalid room id")
	ErrInvalidUserID      = errors.New("invalid user id")
	ErrInvalidText        = errors.New("invalid text")
	ErrInvalidMetadata    = errors.New("invalid metadata")
	ErrInvalidCreatedAt   = errors.New("invalid created at")
	ErrInvalidPublishedAt = errors.New("invalid published at")

	ErrInvalidMessage = errors.New("invalid message")

	ErrMessageNotFound = errors.New("message not found")
)

Functions

This section is empty.

Types

type Message

type Message struct {
	// contains filtered or unexported fields
}

func NewMessage

func NewMessage(id string, roomID string, userID string, text string, opts ...MessageOptions) (*Message, error)

func (*Message) CreatedAt

func (m *Message) CreatedAt() time.Time

func (*Message) Events

func (m *Message) Events() []pubsub.Event

func (*Message) ID

func (m *Message) ID() string

func (*Message) MarshalJSON

func (m *Message) MarshalJSON() ([]byte, error)

func (*Message) Metadata

func (m *Message) Metadata() Metadata

func (*Message) PublishedAt

func (m *Message) PublishedAt() time.Time

func (*Message) Restore

func (m *Message) Restore(memento *MessageMemento) (*Message, error)

func (*Message) RoomID

func (m *Message) RoomID() string

func (*Message) Text

func (m *Message) Text() string

func (*Message) UnmarshalJSON

func (m *Message) UnmarshalJSON(data []byte) error

func (*Message) UserID

func (m *Message) UserID() string

type MessageMemento

type MessageMemento struct {
	ID          string    `json:"id"`
	RoomID      string    `json:"room_id"`
	UserID      string    `json:"user_id"`
	Text        string    `json:"text"`
	Metadata    Metadata  `json:"metadata"`
	CreatedAt   time.Time `json:"created_at"`
	PublishedAt time.Time `json:"published_at"`
}

type MessageOptions

type MessageOptions func(*Message)

func WithMetadata

func WithMetadata(metadata Metadata) MessageOptions

func WithPublishedAt

func WithPublishedAt(publishedAt time.Time) MessageOptions

type Metadata

type Metadata map[string]any

type Storage

type Storage interface {
	Save(ctx context.Context, message *Message) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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