storage

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

This section is empty.

Types

type APITokenRepository

type APITokenRepository interface {
	Create(ctx context.Context, token model.APIToken) (model.APIToken, error)
	GetByID(ctx context.Context, id string) (model.APIToken, error)
	GetByTokenHash(ctx context.Context, tokenHash string) (model.APIToken, error)
	ListByUser(ctx context.Context, userID string) ([]model.APIToken, error)
	Update(ctx context.Context, token model.APIToken) (model.APIToken, error)
	Delete(ctx context.Context, id string) error
}

type ContactRepository added in v1.0.10

type ContactRepository interface {
	Upsert(ctx context.Context, contact model.Contact) error
	GetByPhone(ctx context.Context, phone string) (model.Contact, error)
}

type ErrUnknownDriver

type ErrUnknownDriver struct {
	Driver string
}

func (*ErrUnknownDriver) Error

func (e *ErrUnknownDriver) Error() string

type EventLogRepository

type EventLogRepository interface {
	Create(ctx context.Context, eventLog model.EventLog) (model.EventLog, error)
	ListByInstance(ctx context.Context, instanceID string) ([]model.EventLog, error)
	DeleteByInstanceID(ctx context.Context, instanceID string) error
}

type HistorySyncRepository

type HistorySyncRepository interface {
	Create(ctx context.Context, payload model.WhatsappHistorySync) (model.WhatsappHistorySync, error)
	ListPendingByInstance(ctx context.Context, instanceID string) ([]model.WhatsappHistorySync, error)
	ListPendingByCycle(ctx context.Context, instanceID, cycleID string) ([]model.WhatsappHistorySync, error)
	UpdateStatus(ctx context.Context, id string, status model.HistorySyncPayloadStatus, processedAt *time.Time) error
	DeleteByInstance(ctx context.Context, instanceID string) error
}

type IdempotencyRepository added in v1.2.0

type IdempotencyRepository interface {
	// TryAcquire inserts the key and reports whether this caller owns the
	// request. When it does not, the stored record comes back for replay.
	TryAcquire(ctx context.Context, record model.IdempotencyRecord) (bool, model.IdempotencyRecord, error)
	Complete(ctx context.Context, instanceID, key string, responseStatus int, responseBody string) error
	Release(ctx context.Context, instanceID, key string) error
	DeleteExpired(ctx context.Context, now time.Time) (int64, error)
}

type InstanceRepository

type InstanceRepository interface {
	Create(ctx context.Context, instance model.Instance) (model.Instance, error)
	GetByID(ctx context.Context, id string) (model.Instance, error)
	GetByTokenHash(ctx context.Context, tokenHash string) (model.Instance, error)
	List(ctx context.Context, query string, limit, offset int) ([]model.Instance, int, error)
	ListByOwner(ctx context.Context, ownerUserID string, query string, limit, offset int) ([]model.Instance, int, error)
	Update(ctx context.Context, instance model.Instance) (model.Instance, error)
	Delete(ctx context.Context, id string) error
}

type MessageRepository

type MessageRepository interface {
	Create(ctx context.Context, message model.Message) (model.Message, error)
	ListByInstance(ctx context.Context, instanceID string) ([]model.Message, error)
	Update(ctx context.Context, msg model.Message) error
	UpdateStatusByWhatsAppID(ctx context.Context, whatsappID string, status string) error
	GetByWhatsAppID(ctx context.Context, whatsappID string) (model.Message, error)
	GetPendingMessages(ctx context.Context, limit int) ([]model.Message, error)
	DeleteByInstanceID(ctx context.Context, instanceID string) error
}

type Repositories

type Repositories struct {
	Instance     InstanceRepository
	Message      MessageRepository
	EventLog     EventLogRepository
	User         UserRepository
	APIToken     APITokenRepository
	HistorySync  HistorySyncRepository
	Contact      ContactRepository
	Idempotency  IdempotencyRepository
	RedisClient  *storage_redis.Client
	WebhookQueue queue.Queue
	OutboxQueue  queue.Queue
	RateLimiter  ratelimiter.Limiter
}

func NewRepositories

func NewRepositories(cfg config.Config, log *zap.Logger) (*Repositories, error)

type UserRepository

type UserRepository interface {
	Create(ctx context.Context, user model.User) (model.User, error)
	GetByID(ctx context.Context, id string) (model.User, error)
	GetByEmail(ctx context.Context, email string) (model.User, error)
	List(ctx context.Context, query string, limit, offset int) ([]model.User, int, error)
	UpdatePassword(ctx context.Context, id, passwordHash string) error
	Delete(ctx context.Context, id string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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