service

package
v0.0.0-...-4206155 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package service is a generated GoMock package.

Index

Constants

View Source
const (
	PacketTTL = 30 * time.Minute
)

Variables

View Source
var (
	EventsTotal = promauto.NewCounterVec(prometheus.CounterOpts{
		Namespace: "ejaculation_counter",
		Name:      "events_total",
		Help:      "Total number of events triggered by messages.",
	}, []string{"name", "action"})
	EventsErrorTotal = promauto.NewCounterVec(prometheus.CounterOpts{
		Namespace: "ejaculation_counter",
		Name:      "events_error_total",
		Help:      "Total number of errors when creating events.",
	}, []string{"action"})
)
View Source
var (
	NoMatchError = fmt.Errorf("no matches found")
)

Functions

This section is empty.

Types

type Account

type Account struct {
	ID          string `json:"id"`
	Acct        string `json:"acct"`
	DisplayName string `json:"display_name"`
	Username    string `json:"user_name"`
}

type Action

type Action interface {
	Name() string
	Target(message Message) bool
	Event(ctx context.Context, message Message) (Event, int, error)
}

type Administration

type Administration interface {
	Do(ctx context.Context, event AdministrationEvent) error
}

type AdministrationEvent

type AdministrationEvent struct {
	InReplyToID string
	Acct        string
	Type        string
	Command     string
	Visibility  string
}

func (AdministrationEvent) Name

func (AdministrationEvent) Name() string

type Count

type Count struct {
	UserID int64     `db:"user_id"`
	Date   time.Time `db:"date"`
	Count  int       `db:"count"`
}

type Doublet

type Doublet interface {
	Get() []string
}

func NewDoublet

func NewDoublet(repository repository.DoubletRepository) Doublet

type Emoji

type Emoji struct {
	Shortcode string `json:"shortcode"`
}

type Event

type Event interface {
	Name() string
}

type Increment

type Increment interface {
	Do(ctx context.Context, event IncrementEvent) error
}

type IncrementEvent

type IncrementEvent struct {
	Year  int
	Month int
	Day   int
}

func (IncrementEvent) Name

func (IncrementEvent) Name() string

type Message

type Message struct {
	ID          string    `json:"id"`
	Account     Account   `json:"account"`
	CreatedAt   time.Time `json:"created_at"`
	Content     string    `json:"content"`
	Emojis      []Emoji   `json:"emojis"`
	InReplyToID string    `json:"in_reply_to_id"`
	IsReblog    bool      `json:"is_reblog"`
	Tags        []Tag     `json:"tags"`
	Visibility  string    `json:"visibility"`
	// contains filtered or unexported fields
}

func NewMessage

func NewMessage(tag uint64, timestamp time.Time) Message

func (Message) Name

func (m Message) Name() string

func (Message) Tag

func (m Message) Tag() uint64

func (Message) Timestamp

func (m Message) Timestamp() time.Time

type MockAction

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

MockAction is a mock of Action interface.

func NewMockAction

func NewMockAction(ctrl *gomock.Controller) *MockAction

NewMockAction creates a new mock instance.

func (*MockAction) EXPECT

func (m *MockAction) EXPECT() *MockActionMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockAction) Event

func (m *MockAction) Event(ctx context.Context, message Message) (Event, int, error)

Event mocks base method.

func (*MockAction) Name

func (m *MockAction) Name() string

Name mocks base method.

func (*MockAction) Target

func (m *MockAction) Target(message Message) bool

Target mocks base method.

type MockActionMockRecorder

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

MockActionMockRecorder is the mock recorder for MockAction.

func (*MockActionMockRecorder) Event

func (mr *MockActionMockRecorder) Event(ctx, message any) *gomock.Call

Event indicates an expected call of Event.

func (*MockActionMockRecorder) Name

func (mr *MockActionMockRecorder) Name() *gomock.Call

Name indicates an expected call of Name.

func (*MockActionMockRecorder) Target

func (mr *MockActionMockRecorder) Target(message any) *gomock.Call

Target indicates an expected call of Target.

type Packet

type Packet interface {
	Tag() uint64
	Timestamp() time.Time
}

type Processor

type Processor interface {
	Execute(ctx context.Context, packets <-chan Packet)
}

func NewProcessor

func NewProcessor(
	queue QueueReader,
	reply Reply,
	increment Increment,
	update Update,
	administration Administration,
	actions []Action,
	clock func() time.Time,
) Processor

type QueueReader

type QueueReader interface {
	Consume(ctx context.Context)
	Packets() <-chan Packet
	Ack(tag uint64) error
	Reject(tag uint64) error
	Close(exit bool) error
}

type Reply

type Reply interface {
	Send(ctx context.Context, event ReplyEvent) error
	SendError(ctx context.Context, event ReplyErrorEvent) error
}

type ReplyErrorEvent

type ReplyErrorEvent struct {
	InReplyToID string
	Acct        string
	ActionName  string
	Visibility  string
}

func (ReplyErrorEvent) Name

func (ReplyErrorEvent) Name() string

type ReplyEvent

type ReplyEvent struct {
	InReplyToID string
	Acct        string
	Body        io.ReadCloser
	Visibility  string
}

func (ReplyEvent) Name

func (ReplyEvent) Name() string

type Tag

type Tag struct {
	Name string `json:"name"`
}

type Through

type Through interface {
	Get() []string
}

func NewThrough

func NewThrough(repository repository.ThroughRepository) Through

type Tick

type Tick struct {
	Year  int `json:"year"`
	Month int `json:"month"`
	Day   int `json:"day"`
	// contains filtered or unexported fields
}

func NewTick

func NewTick(tag uint64, timestamp time.Time) Tick

func (Tick) Name

func (t Tick) Name() string

func (Tick) Tag

func (t Tick) Tag() uint64

func (Tick) Timestamp

func (t Tick) Timestamp() time.Time

type Update

type Update interface {
	Do(ctx context.Context, event UpdateEvent) error
}

type UpdateEvent

type UpdateEvent struct {
	Year  int
	Month int
	Day   int
}

func (UpdateEvent) Name

func (UpdateEvent) Name() string

type User

type User struct {
	ID         int64  `db:"id"`
	ScreenName string `db:"screen_name"`
}

Jump to

Keyboard shortcuts

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