machine

package
v0.0.0-...-3ee0b18 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_messages_internal_machine_commands_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type AppendCommand

type AppendCommand struct {
	Id        int64   `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	UserId    int64   `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	FileIds   []int64 `protobuf:"varint,3,rep,packed,name=file_ids,json=fileIds,proto3" json:"file_ids,omitempty"`
	Text      string  `protobuf:"bytes,4,opt,name=text,proto3" json:"text,omitempty"`
	Name      string  `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"`
	Private   bool    `protobuf:"varint,6,opt,name=private,proto3" json:"private,omitempty"`
	Title     string  `protobuf:"bytes,7,opt,name=title,proto3" json:"title,omitempty"`
	CreatedAt string  `protobuf:"bytes,8,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
	UpdatedAt string  `protobuf:"bytes,9,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
	// contains filtered or unexported fields
}

func (*AppendCommand) Descriptor deprecated

func (*AppendCommand) Descriptor() ([]byte, []int)

Deprecated: Use AppendCommand.ProtoReflect.Descriptor instead.

func (*AppendCommand) GetCreatedAt

func (x *AppendCommand) GetCreatedAt() string

func (*AppendCommand) GetFileIds

func (x *AppendCommand) GetFileIds() []int64

func (*AppendCommand) GetId

func (x *AppendCommand) GetId() int64

func (*AppendCommand) GetName

func (x *AppendCommand) GetName() string

func (*AppendCommand) GetPrivate

func (x *AppendCommand) GetPrivate() bool

func (*AppendCommand) GetText

func (x *AppendCommand) GetText() string

func (*AppendCommand) GetTitle

func (x *AppendCommand) GetTitle() string

func (*AppendCommand) GetUpdatedAt

func (x *AppendCommand) GetUpdatedAt() string

func (*AppendCommand) GetUserId

func (x *AppendCommand) GetUserId() int64

func (*AppendCommand) ProtoMessage

func (*AppendCommand) ProtoMessage()

func (*AppendCommand) ProtoReflect

func (x *AppendCommand) ProtoReflect() protoreflect.Message

func (*AppendCommand) Reset

func (x *AppendCommand) Reset()

func (*AppendCommand) String

func (x *AppendCommand) String() string

type AppendCommentCommand

type AppendCommentCommand struct {
	Id        int64  `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	MessageId int64  `protobuf:"varint,2,opt,name=message_id,json=messageId,proto3" json:"message_id,omitempty"`
	UserId    int64  `protobuf:"varint,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	Text      string `protobuf:"bytes,4,opt,name=text,proto3" json:"text,omitempty"`
	CreatedAt string `protobuf:"bytes,5,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
	UpdatedAt string `protobuf:"bytes,6,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
	Metadata  []byte `protobuf:"bytes,7,opt,name=metadata,proto3,oneof" json:"metadata,omitempty"`
	// contains filtered or unexported fields
}

func (*AppendCommentCommand) Descriptor deprecated

func (*AppendCommentCommand) Descriptor() ([]byte, []int)

Deprecated: Use AppendCommentCommand.ProtoReflect.Descriptor instead.

func (*AppendCommentCommand) GetCreatedAt

func (x *AppendCommentCommand) GetCreatedAt() string

func (*AppendCommentCommand) GetId

func (x *AppendCommentCommand) GetId() int64

func (*AppendCommentCommand) GetMessageId

func (x *AppendCommentCommand) GetMessageId() int64

func (*AppendCommentCommand) GetMetadata

func (x *AppendCommentCommand) GetMetadata() []byte

func (*AppendCommentCommand) GetText

func (x *AppendCommentCommand) GetText() string

func (*AppendCommentCommand) GetUpdatedAt

func (x *AppendCommentCommand) GetUpdatedAt() string

func (*AppendCommentCommand) GetUserId

func (x *AppendCommentCommand) GetUserId() int64

func (*AppendCommentCommand) ProtoMessage

func (*AppendCommentCommand) ProtoMessage()

func (*AppendCommentCommand) ProtoReflect

func (x *AppendCommentCommand) ProtoReflect() protoreflect.Message

func (*AppendCommentCommand) Reset

func (x *AppendCommentCommand) Reset()

func (*AppendCommentCommand) String

func (x *AppendCommentCommand) String() string

type AppendTranslationCommand

type AppendTranslationCommand struct {
	MessageId int64  `protobuf:"varint,1,opt,name=message_id,json=messageId,proto3" json:"message_id,omitempty"`
	Lang      string `protobuf:"bytes,2,opt,name=lang,proto3" json:"lang,omitempty"`
	Title     string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"`
	Text      string `protobuf:"bytes,4,opt,name=text,proto3" json:"text,omitempty"`
	CreatedAt string `protobuf:"bytes,5,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
	UpdatedAt string `protobuf:"bytes,6,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
	// contains filtered or unexported fields
}

func (*AppendTranslationCommand) Descriptor deprecated

func (*AppendTranslationCommand) Descriptor() ([]byte, []int)

Deprecated: Use AppendTranslationCommand.ProtoReflect.Descriptor instead.

func (*AppendTranslationCommand) GetCreatedAt

func (x *AppendTranslationCommand) GetCreatedAt() string

func (*AppendTranslationCommand) GetLang

func (x *AppendTranslationCommand) GetLang() string

func (*AppendTranslationCommand) GetMessageId

func (x *AppendTranslationCommand) GetMessageId() int64

func (*AppendTranslationCommand) GetText

func (x *AppendTranslationCommand) GetText() string

func (*AppendTranslationCommand) GetTitle

func (x *AppendTranslationCommand) GetTitle() string

func (*AppendTranslationCommand) GetUpdatedAt

func (x *AppendTranslationCommand) GetUpdatedAt() string

func (*AppendTranslationCommand) ProtoMessage

func (*AppendTranslationCommand) ProtoMessage()

func (*AppendTranslationCommand) ProtoReflect

func (x *AppendTranslationCommand) ProtoReflect() protoreflect.Message

func (*AppendTranslationCommand) Reset

func (x *AppendTranslationCommand) Reset()

func (*AppendTranslationCommand) String

func (x *AppendTranslationCommand) String() string

type CommentsRepository

type CommentsRepository interface {
	Create(ctx context.Context, id, userID, messageID int64, text string, metadata []byte, createdAt, updatedAt string) (err error)
	Update(ctx context.Context, id, userID int64, text *string, updatedAt string) (err error)
	Delete(ctx context.Context, id, userID int64) (err error)
	DeleteMessageComments(ctx context.Context, messageID int64) (err error)
}

type DeleteCommand

type DeleteCommand struct {
	Id     int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	// contains filtered or unexported fields
}

func (*DeleteCommand) Descriptor deprecated

func (*DeleteCommand) Descriptor() ([]byte, []int)

Deprecated: Use DeleteCommand.ProtoReflect.Descriptor instead.

func (*DeleteCommand) GetId

func (x *DeleteCommand) GetId() int64

func (*DeleteCommand) GetUserId

func (x *DeleteCommand) GetUserId() int64

func (*DeleteCommand) ProtoMessage

func (*DeleteCommand) ProtoMessage()

func (*DeleteCommand) ProtoReflect

func (x *DeleteCommand) ProtoReflect() protoreflect.Message

func (*DeleteCommand) Reset

func (x *DeleteCommand) Reset()

func (*DeleteCommand) String

func (x *DeleteCommand) String() string

type DeleteCommentCommand

type DeleteCommentCommand struct {
	Id     int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	// contains filtered or unexported fields
}

func (*DeleteCommentCommand) Descriptor deprecated

func (*DeleteCommentCommand) Descriptor() ([]byte, []int)

Deprecated: Use DeleteCommentCommand.ProtoReflect.Descriptor instead.

func (*DeleteCommentCommand) GetId

func (x *DeleteCommentCommand) GetId() int64

func (*DeleteCommentCommand) GetUserId

func (x *DeleteCommentCommand) GetUserId() int64

func (*DeleteCommentCommand) ProtoMessage

func (*DeleteCommentCommand) ProtoMessage()

func (*DeleteCommentCommand) ProtoReflect

func (x *DeleteCommentCommand) ProtoReflect() protoreflect.Message

func (*DeleteCommentCommand) Reset

func (x *DeleteCommentCommand) Reset()

func (*DeleteCommentCommand) String

func (x *DeleteCommentCommand) String() string

type DeleteMessageCommentsCommand

type DeleteMessageCommentsCommand struct {
	MessageId int64 `protobuf:"varint,1,opt,name=message_id,json=messageId,proto3" json:"message_id,omitempty"`
	// contains filtered or unexported fields
}

func (*DeleteMessageCommentsCommand) Descriptor deprecated

func (*DeleteMessageCommentsCommand) Descriptor() ([]byte, []int)

Deprecated: Use DeleteMessageCommentsCommand.ProtoReflect.Descriptor instead.

func (*DeleteMessageCommentsCommand) GetMessageId

func (x *DeleteMessageCommentsCommand) GetMessageId() int64

func (*DeleteMessageCommentsCommand) ProtoMessage

func (*DeleteMessageCommentsCommand) ProtoMessage()

func (*DeleteMessageCommentsCommand) ProtoReflect

func (*DeleteMessageCommentsCommand) Reset

func (x *DeleteMessageCommentsCommand) Reset()

func (*DeleteMessageCommentsCommand) String

type DeleteTranslationCommand

type DeleteTranslationCommand struct {
	MessageId int64  `protobuf:"varint,1,opt,name=message_id,json=messageId,proto3" json:"message_id,omitempty"`
	Lang      string `protobuf:"bytes,2,opt,name=lang,proto3" json:"lang,omitempty"`
	// contains filtered or unexported fields
}

func (*DeleteTranslationCommand) Descriptor deprecated

func (*DeleteTranslationCommand) Descriptor() ([]byte, []int)

Deprecated: Use DeleteTranslationCommand.ProtoReflect.Descriptor instead.

func (*DeleteTranslationCommand) GetLang

func (x *DeleteTranslationCommand) GetLang() string

func (*DeleteTranslationCommand) GetMessageId

func (x *DeleteTranslationCommand) GetMessageId() int64

func (*DeleteTranslationCommand) ProtoMessage

func (*DeleteTranslationCommand) ProtoMessage()

func (*DeleteTranslationCommand) ProtoReflect

func (x *DeleteTranslationCommand) ProtoReflect() protoreflect.Message

func (*DeleteTranslationCommand) Reset

func (x *DeleteTranslationCommand) Reset()

func (*DeleteTranslationCommand) String

func (x *DeleteTranslationCommand) String() string

type DeleteUserMessagesCommand

type DeleteUserMessagesCommand struct {
	UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	// contains filtered or unexported fields
}

func (*DeleteUserMessagesCommand) Descriptor deprecated

func (*DeleteUserMessagesCommand) Descriptor() ([]byte, []int)

Deprecated: Use DeleteUserMessagesCommand.ProtoReflect.Descriptor instead.

func (*DeleteUserMessagesCommand) GetUserId

func (x *DeleteUserMessagesCommand) GetUserId() int64

func (*DeleteUserMessagesCommand) ProtoMessage

func (*DeleteUserMessagesCommand) ProtoMessage()

func (*DeleteUserMessagesCommand) ProtoReflect

func (*DeleteUserMessagesCommand) Reset

func (x *DeleteUserMessagesCommand) Reset()

func (*DeleteUserMessagesCommand) String

func (x *DeleteUserMessagesCommand) String() string

type Dumper

type Dumper interface {
	Open(ctx context.Context) (ch chan *api.MessagesSnapshot, err error)
	Restore(ctx context.Context, user *api.MessagesSnapshot) (err error)
	Close() (err error)
}

type Machine

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

func New

func New(messagesRepo MessagesRepository, translationsRepo TranslationsRepository,
	commentsRepo CommentsRepository, dumper Dumper, log *logger.Logger) *Machine

func (*Machine) Apply

func (f *Machine) Apply(record *raft.Log) interface{}

func (*Machine) Restore

func (f *Machine) Restore(reader io.ReadCloser) (err error)

func (*Machine) Snapshot

func (f *Machine) Snapshot() (raft.FSMSnapshot, error)

type MessagesRepository

type MessagesRepository interface {
	Create(ctx context.Context, id int64, text, title string, userID int64, private bool, name, createdAt, updatedAt string) (err error)
	Update(ctx context.Context, userID, id int64, text, title, name *string, updatedAt string) (err error)
	DeleteMessage(ctx context.Context, userID, id int64) (err error)
	Publish(ctx context.Context, userID int64, ids []int64, updatedAt string) (err error)
	Private(ctx context.Context, userID int64, ids []int64, updatedAt string) (err error)
	DeleteUserMessages(ctx context.Context, userID int64) (err error)
}

type PrivateCommand

type PrivateCommand struct {
	Ids       []int64 `protobuf:"varint,1,rep,packed,name=ids,proto3" json:"ids,omitempty"`
	UserId    int64   `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	UpdatedAt string  `protobuf:"bytes,3,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
	// contains filtered or unexported fields
}

func (*PrivateCommand) Descriptor deprecated

func (*PrivateCommand) Descriptor() ([]byte, []int)

Deprecated: Use PrivateCommand.ProtoReflect.Descriptor instead.

func (*PrivateCommand) GetIds

func (x *PrivateCommand) GetIds() []int64

func (*PrivateCommand) GetUpdatedAt

func (x *PrivateCommand) GetUpdatedAt() string

func (*PrivateCommand) GetUserId

func (x *PrivateCommand) GetUserId() int64

func (*PrivateCommand) ProtoMessage

func (*PrivateCommand) ProtoMessage()

func (*PrivateCommand) ProtoReflect

func (x *PrivateCommand) ProtoReflect() protoreflect.Message

func (*PrivateCommand) Reset

func (x *PrivateCommand) Reset()

func (*PrivateCommand) String

func (x *PrivateCommand) String() string

type PublishCommand

type PublishCommand struct {
	Ids       []int64 `protobuf:"varint,1,rep,packed,name=ids,proto3" json:"ids,omitempty"`
	UserId    int64   `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	UpdatedAt string  `protobuf:"bytes,3,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
	// contains filtered or unexported fields
}

func (*PublishCommand) Descriptor deprecated

func (*PublishCommand) Descriptor() ([]byte, []int)

Deprecated: Use PublishCommand.ProtoReflect.Descriptor instead.

func (*PublishCommand) GetIds

func (x *PublishCommand) GetIds() []int64

func (*PublishCommand) GetUpdatedAt

func (x *PublishCommand) GetUpdatedAt() string

func (*PublishCommand) GetUserId

func (x *PublishCommand) GetUserId() int64

func (*PublishCommand) ProtoMessage

func (*PublishCommand) ProtoMessage()

func (*PublishCommand) ProtoReflect

func (x *PublishCommand) ProtoReflect() protoreflect.Message

func (*PublishCommand) Reset

func (x *PublishCommand) Reset()

func (*PublishCommand) String

func (x *PublishCommand) String() string

type RequestType

type RequestType uint16
const (
	AppendRequest RequestType = iota
	UpdateRequest
	DeleteRequest
	PublishRequest
	PrivateRequest
	DeleteUserMessagesRequest
	AppendTranslationRequest
	UpdateTranslationRequest
	DeleteTranslationRequest

	AppendCommentRequest
	UpdateCommentRequest
	DeleteCommentRequest
	DeleteMessageCommentsRequest
)

type TranslationsRepository

type TranslationsRepository interface {
	SaveTranslation(ctx context.Context, messageID int64, lang, text, title, createdAt, updatedAt string) (err error)
	UpdateTranslation(ctx context.Context, messageID int64, lang string, text, title *string, updatedAt string) (err error)
	DeleteTranslation(ctx context.Context, messageID int64, lang string) (err error)
	DeleteMessage(ctx context.Context, messageID int64) (err error)
}

type UpdateCommand

type UpdateCommand struct {
	Id        int64   `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	UserId    int64   `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	FileIds   []int64 `protobuf:"varint,3,rep,packed,name=file_ids,json=fileIds,proto3" json:"file_ids,omitempty"`
	Text      *string `protobuf:"bytes,4,opt,name=text,proto3,oneof" json:"text,omitempty"`
	Name      *string `protobuf:"bytes,5,opt,name=name,proto3,oneof" json:"name,omitempty"`
	Title     *string `protobuf:"bytes,6,opt,name=title,proto3,oneof" json:"title,omitempty"`
	UpdatedAt string  `protobuf:"bytes,7,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
	// contains filtered or unexported fields
}

func (*UpdateCommand) Descriptor deprecated

func (*UpdateCommand) Descriptor() ([]byte, []int)

Deprecated: Use UpdateCommand.ProtoReflect.Descriptor instead.

func (*UpdateCommand) GetFileIds

func (x *UpdateCommand) GetFileIds() []int64

func (*UpdateCommand) GetId

func (x *UpdateCommand) GetId() int64

func (*UpdateCommand) GetName

func (x *UpdateCommand) GetName() string

func (*UpdateCommand) GetText

func (x *UpdateCommand) GetText() string

func (*UpdateCommand) GetTitle

func (x *UpdateCommand) GetTitle() string

func (*UpdateCommand) GetUpdatedAt

func (x *UpdateCommand) GetUpdatedAt() string

func (*UpdateCommand) GetUserId

func (x *UpdateCommand) GetUserId() int64

func (*UpdateCommand) ProtoMessage

func (*UpdateCommand) ProtoMessage()

func (*UpdateCommand) ProtoReflect

func (x *UpdateCommand) ProtoReflect() protoreflect.Message

func (*UpdateCommand) Reset

func (x *UpdateCommand) Reset()

func (*UpdateCommand) String

func (x *UpdateCommand) String() string

type UpdateCommentCommand

type UpdateCommentCommand struct {
	Id        int64   `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	UserId    int64   `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	Text      *string `protobuf:"bytes,3,opt,name=text,proto3,oneof" json:"text,omitempty"`
	Metadata  []byte  `protobuf:"bytes,4,opt,name=metadata,proto3,oneof" json:"metadata,omitempty"`
	UpdatedAt string  `protobuf:"bytes,5,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
	// contains filtered or unexported fields
}

func (*UpdateCommentCommand) Descriptor deprecated

func (*UpdateCommentCommand) Descriptor() ([]byte, []int)

Deprecated: Use UpdateCommentCommand.ProtoReflect.Descriptor instead.

func (*UpdateCommentCommand) GetId

func (x *UpdateCommentCommand) GetId() int64

func (*UpdateCommentCommand) GetMetadata

func (x *UpdateCommentCommand) GetMetadata() []byte

func (*UpdateCommentCommand) GetText

func (x *UpdateCommentCommand) GetText() string

func (*UpdateCommentCommand) GetUpdatedAt

func (x *UpdateCommentCommand) GetUpdatedAt() string

func (*UpdateCommentCommand) GetUserId

func (x *UpdateCommentCommand) GetUserId() int64

func (*UpdateCommentCommand) ProtoMessage

func (*UpdateCommentCommand) ProtoMessage()

func (*UpdateCommentCommand) ProtoReflect

func (x *UpdateCommentCommand) ProtoReflect() protoreflect.Message

func (*UpdateCommentCommand) Reset

func (x *UpdateCommentCommand) Reset()

func (*UpdateCommentCommand) String

func (x *UpdateCommentCommand) String() string

type UpdateTranslationCommand

type UpdateTranslationCommand struct {
	MessageId int64   `protobuf:"varint,1,opt,name=message_id,json=messageId,proto3" json:"message_id,omitempty"`
	Lang      string  `protobuf:"bytes,2,opt,name=lang,proto3" json:"lang,omitempty"`
	Title     *string `protobuf:"bytes,3,opt,name=title,proto3,oneof" json:"title,omitempty"`
	Text      *string `protobuf:"bytes,4,opt,name=text,proto3,oneof" json:"text,omitempty"`
	UpdatedAt string  `protobuf:"bytes,5,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
	// contains filtered or unexported fields
}

func (*UpdateTranslationCommand) Descriptor deprecated

func (*UpdateTranslationCommand) Descriptor() ([]byte, []int)

Deprecated: Use UpdateTranslationCommand.ProtoReflect.Descriptor instead.

func (*UpdateTranslationCommand) GetLang

func (x *UpdateTranslationCommand) GetLang() string

func (*UpdateTranslationCommand) GetMessageId

func (x *UpdateTranslationCommand) GetMessageId() int64

func (*UpdateTranslationCommand) GetText

func (x *UpdateTranslationCommand) GetText() string

func (*UpdateTranslationCommand) GetTitle

func (x *UpdateTranslationCommand) GetTitle() string

func (*UpdateTranslationCommand) GetUpdatedAt

func (x *UpdateTranslationCommand) GetUpdatedAt() string

func (*UpdateTranslationCommand) ProtoMessage

func (*UpdateTranslationCommand) ProtoMessage()

func (*UpdateTranslationCommand) ProtoReflect

func (x *UpdateTranslationCommand) ProtoReflect() protoreflect.Message

func (*UpdateTranslationCommand) Reset

func (x *UpdateTranslationCommand) Reset()

func (*UpdateTranslationCommand) String

func (x *UpdateTranslationCommand) String() string

Jump to

Keyboard shortcuts

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