messages

package
v1.16.1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorTTLExpired = "TTL expired"
)

Variables

View Source
var ErrMessageAlreadyExists = errors.New("duplicate id")
View Source
var ErrMessageNotFound = gorm.ErrRecordNotFound
View Source
var Module = fx.Module(
	"messages",
	fx.Decorate(func(log *zap.Logger) *zap.Logger {
		return log.Named("messages")
	}),
	fx.Provide(func(p ServiceParams) FxResult {
		svc := NewService(p)
		return FxResult{
			Service:   svc,
			AsCleaner: svc,
		}
	}),
	fx.Provide(newRepository),
	fx.Provide(NewHashingTask, fx.Private),
)

Functions

This section is empty.

Types

type Config

type Config struct {
	ProcessedLifetime time.Duration
}

type EnqueueOptions

type EnqueueOptions struct {
	SkipPhoneValidation bool
}

type ErrValidation

type ErrValidation string

func (ErrValidation) Error

func (e ErrValidation) Error() string

type FxResult

type FxResult struct {
	fx.Out

	Service   *Service
	AsCleaner cleaner.Cleanable `group:"cleaners"`
}

type HashingTask

type HashingTask struct {
	Messages *repository
	Config   HashingTaskConfig
	Logger   *zap.Logger
	// contains filtered or unexported fields
}

func NewHashingTask

func NewHashingTask(params HashingTaskParams) *HashingTask

func (*HashingTask) Enqeue

func (t *HashingTask) Enqeue(id uint64)

func (*HashingTask) Run

func (t *HashingTask) Run(ctx context.Context)

type HashingTaskConfig

type HashingTaskConfig struct {
	Interval time.Duration
}

type HashingTaskParams

type HashingTaskParams struct {
	fx.In

	Messages *repository
	Config   HashingTaskConfig
	Logger   *zap.Logger
}

type MessagesSelectFilter

type MessagesSelectFilter struct {
	DeviceID string
}

type MessagesSelectOptions

type MessagesSelectOptions struct {
	WithRecipients bool
	WithDevice     bool
	WithStates     bool
}

type Service

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

func NewService

func NewService(params ServiceParams) *Service

func (*Service) Clean

func (s *Service) Clean(ctx context.Context) error

func (*Service) Enqeue

func (s *Service) Enqeue(device models.Device, message smsgateway.Message, opts EnqueueOptions) (smsgateway.MessageState, error)

func (*Service) GetState

func (s *Service) GetState(user models.User, ID string) (smsgateway.MessageState, error)

func (*Service) RunBackgroundTasks

func (s *Service) RunBackgroundTasks(ctx context.Context, wg *sync.WaitGroup)

func (*Service) SelectPending

func (s *Service) SelectPending(deviceID string) ([]smsgateway.Message, error)

func (*Service) UpdateState

func (s *Service) UpdateState(deviceID string, message smsgateway.MessageState) error

type ServiceParams

type ServiceParams struct {
	fx.In

	IDGen db.IDGen

	Config Config

	Messages    *repository
	HashingTask *HashingTask

	PushSvc *push.Service
	Logger  *zap.Logger
}

Jump to

Keyboard shortcuts

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