memory

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ProviderName = "memory"

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatProvider

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

ChatProvider implements port.ChatSender using an in-memory store.

func NewChatProvider

func NewChatProvider(store *Store) *ChatProvider

NewChatProvider creates a new memory chat provider.

func (*ChatProvider) Name

func (c *ChatProvider) Name() string

Name returns the provider name.

func (*ChatProvider) Send

Send stores the chat message in memory and returns a success result.

func (*ChatProvider) Store

func (c *ChatProvider) Store() *Store

Store returns the underlying memory store.

type EmailProvider

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

EmailProvider implements port.EmailSender using an in-memory store.

func NewEmailProvider

func NewEmailProvider(store *Store, mailpitCfg MailpitConfig) *EmailProvider

NewEmailProvider creates a new memory email provider.

func (*EmailProvider) Name

func (e *EmailProvider) Name() string

Name returns the provider name.

func (*EmailProvider) Send

Send stores the email in memory and optionally forwards to Mailpit.

type MailpitConfig

type MailpitConfig struct {
	Enabled bool
}

MailpitConfig holds configuration for SMTP forwarding to Mailpit.

type PushProvider

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

PushProvider implements port.PushSender using an in-memory store.

func NewPushProvider

func NewPushProvider(store *Store) *PushProvider

NewPushProvider creates a new memory push provider.

func (*PushProvider) Name

func (p *PushProvider) Name() string

Name returns the provider name.

func (*PushProvider) Send

Send stores the push notification in memory and returns a success result.

func (*PushProvider) Store

func (p *PushProvider) Store() *Store

Store returns the underlying memory store.

type SMSProvider

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

SMSProvider implements port.SMSSender using an in-memory store.

func NewSMSProvider

func NewSMSProvider(store *Store) *SMSProvider

NewSMSProvider creates a new memory SMS provider.

func (*SMSProvider) Name

func (s *SMSProvider) Name() string

Name returns the provider name.

func (*SMSProvider) Send

Send stores the SMS in memory and returns a success result.

func (*SMSProvider) Store

func (s *SMSProvider) Store() *Store

Store returns the underlying memory store.

type Store

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

Store implements an in-memory message store for all message types.

func GetStore added in v1.1.2

func GetStore() *Store

GetStore returns the singleton memory store instance. This is used by the memory provider internally and by handlers that need access to stored messages.

func NewStore

func NewStore() *Store

NewStore creates a new in-memory store.

func (*Store) AddChat

func (s *Store) AddChat(stored *StoredChat)

AddChat adds a stored chat message.

func (*Store) AddEmail

func (s *Store) AddEmail(stored *StoredEmail)

AddEmail adds a stored email.

func (*Store) AddPush

func (s *Store) AddPush(stored *StoredPush)

AddPush adds a stored push notification.

func (*Store) AddSMS

func (s *Store) AddSMS(stored *StoredSMS)

AddSMS adds a stored SMS.

func (*Store) AllSMS

func (s *Store) AllSMS() []*StoredSMS

AllSMS returns a copy of all stored SMS messages.

func (*Store) ChatByID

func (s *Store) ChatByID(id string) *StoredChat

ChatByID returns a stored chat message by its ID, or nil if not found.

func (*Store) Chats

func (s *Store) Chats() []*StoredChat

Chats returns a copy of all stored chat messages.

func (*Store) Clear

func (s *Store) Clear()

Clear removes all stored messages.

func (*Store) Count

func (s *Store) Count() int

Count returns the total number of stored messages across all types.

func (*Store) DeleteChatByID

func (s *Store) DeleteChatByID(id string) bool

DeleteChatByID deletes a chat message by ID. Returns true if deleted.

func (*Store) DeleteEmailByID

func (s *Store) DeleteEmailByID(id string) bool

DeleteEmailByID deletes an email by ID. Returns true if deleted.

func (*Store) DeletePushByID

func (s *Store) DeletePushByID(id string) bool

DeletePushByID deletes a push notification by ID. Returns true if deleted.

func (*Store) DeleteSMSByID

func (s *Store) DeleteSMSByID(id string) bool

DeleteSMSByID deletes an SMS by ID. Returns true if deleted.

func (*Store) EmailByID

func (s *Store) EmailByID(id string) *StoredEmail

EmailByID returns a stored email by its ID, or nil if not found.

func (*Store) Emails

func (s *Store) Emails() []*StoredEmail

Emails returns a copy of all stored emails.

func (*Store) PushByID

func (s *Store) PushByID(id string) *StoredPush

PushByID returns a stored push notification by its ID, or nil if not found.

func (*Store) Pushes

func (s *Store) Pushes() []*StoredPush

Pushes returns a copy of all stored push notifications.

func (*Store) SMSByID

func (s *Store) SMSByID(id string) *StoredSMS

SMSByID returns a stored SMS by its ID, or nil if not found.

func (*Store) Stats

func (s *Store) Stats() map[string]int

Stats returns message counts by type.

type StoredChat

type StoredChat struct {
	ID        string                 `json:"id"`
	CreatedAt time.Time              `json:"created_at"`
	Chat      *contracts.ChatMessage `json:"chat"`
}

StoredChat wraps a chat message with metadata for storage.

type StoredEmail

type StoredEmail struct {
	ID        string           `json:"id"`
	CreatedAt time.Time        `json:"created_at"`
	Email     *contracts.Email `json:"email"`
}

StoredEmail wraps an email with metadata for storage.

type StoredPush

type StoredPush struct {
	ID        string                      `json:"id"`
	CreatedAt time.Time                   `json:"created_at"`
	Push      *contracts.PushNotification `json:"push"`
}

StoredPush wraps a push notification with metadata for storage.

type StoredSMS

type StoredSMS struct {
	ID        string         `json:"id"`
	CreatedAt time.Time      `json:"created_at"`
	SMS       *contracts.SMS `json:"sms"`
}

StoredSMS wraps an SMS with metadata for storage.

Jump to

Keyboard shortcuts

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