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: 16 Imported by: 0

Documentation

Index

Constants

View Source
const RaftRPC = 1

Variables

View Source
var File_threads_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"`
	ParentId    int64  `protobuf:"varint,3,opt,name=parent_id,json=parentId,proto3" json:"parent_id,omitempty"`
	Name        string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"`
	Private     bool   `protobuf:"varint,5,opt,name=private,proto3" json:"private,omitempty"`
	NextId      int64  `protobuf:"varint,6,opt,name=next_id,json=nextId,proto3" json:"next_id,omitempty"`
	PrevId      int64  `protobuf:"varint,7,opt,name=prev_id,json=prevId,proto3" json:"prev_id,omitempty"`
	Description string `protobuf:"bytes,8,opt,name=description,proto3" json:"description,omitempty"`
	CreatedAt   string `protobuf:"bytes,9,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
	UpdatedAt   string `protobuf:"bytes,10,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
	Title       string `protobuf:"bytes,11,opt,name=title,proto3" json:"title,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) GetDescription

func (x *AppendCommand) GetDescription() string

func (*AppendCommand) GetId

func (x *AppendCommand) GetId() int64

func (*AppendCommand) GetName

func (x *AppendCommand) GetName() string

func (*AppendCommand) GetNextId

func (x *AppendCommand) GetNextId() int64

func (*AppendCommand) GetParentId

func (x *AppendCommand) GetParentId() int64

func (*AppendCommand) GetPrevId

func (x *AppendCommand) GetPrevId() int64

func (*AppendCommand) GetPrivate

func (x *AppendCommand) GetPrivate() bool

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 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 Dumper

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

type Machine

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

func New

func New(threadsRepo ThreadsRepository, 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 PrivateCommand

type PrivateCommand 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"`
	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) GetId

func (x *PrivateCommand) GetId() 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 PrivateMessagesCommand

type PrivateMessagesCommand 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"`
	// contains filtered or unexported fields
}

func (*PrivateMessagesCommand) Descriptor deprecated

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

Deprecated: Use PrivateMessagesCommand.ProtoReflect.Descriptor instead.

func (*PrivateMessagesCommand) GetIds

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

func (*PrivateMessagesCommand) GetUserId

func (x *PrivateMessagesCommand) GetUserId() int64

func (*PrivateMessagesCommand) ProtoMessage

func (*PrivateMessagesCommand) ProtoMessage()

func (*PrivateMessagesCommand) ProtoReflect

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

func (*PrivateMessagesCommand) Reset

func (x *PrivateMessagesCommand) Reset()

func (*PrivateMessagesCommand) String

func (x *PrivateMessagesCommand) String() string

type PublishCommand

type PublishCommand 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"`
	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) GetId

func (x *PublishCommand) GetId() 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 PublishMessagesCommand

type PublishMessagesCommand 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"`
	// contains filtered or unexported fields
}

func (*PublishMessagesCommand) Descriptor deprecated

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

Deprecated: Use PublishMessagesCommand.ProtoReflect.Descriptor instead.

func (*PublishMessagesCommand) GetIds

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

func (*PublishMessagesCommand) GetUserId

func (x *PublishMessagesCommand) GetUserId() int64

func (*PublishMessagesCommand) ProtoMessage

func (*PublishMessagesCommand) ProtoMessage()

func (*PublishMessagesCommand) ProtoReflect

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

func (*PublishMessagesCommand) Reset

func (x *PublishMessagesCommand) Reset()

func (*PublishMessagesCommand) String

func (x *PublishMessagesCommand) String() string

type ReorderCommand

type ReorderCommand 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"`
	NextId    int64  `protobuf:"varint,3,opt,name=next_id,json=nextId,proto3" json:"next_id,omitempty"`
	PrevId    int64  `protobuf:"varint,4,opt,name=prev_id,json=prevId,proto3" json:"prev_id,omitempty"`
	ParentId  int64  `protobuf:"varint,5,opt,name=parent_id,json=parentId,proto3" json:"parent_id,omitempty"`
	UpdatedAt string `protobuf:"bytes,6,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
	// contains filtered or unexported fields
}

func (*ReorderCommand) Descriptor deprecated

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

Deprecated: Use ReorderCommand.ProtoReflect.Descriptor instead.

func (*ReorderCommand) GetId

func (x *ReorderCommand) GetId() int64

func (*ReorderCommand) GetNextId

func (x *ReorderCommand) GetNextId() int64

func (*ReorderCommand) GetParentId

func (x *ReorderCommand) GetParentId() int64

func (*ReorderCommand) GetPrevId

func (x *ReorderCommand) GetPrevId() int64

func (*ReorderCommand) GetUpdatedAt

func (x *ReorderCommand) GetUpdatedAt() string

func (*ReorderCommand) GetUserId

func (x *ReorderCommand) GetUserId() int64

func (*ReorderCommand) ProtoMessage

func (*ReorderCommand) ProtoMessage()

func (*ReorderCommand) ProtoReflect

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

func (*ReorderCommand) Reset

func (x *ReorderCommand) Reset()

func (*ReorderCommand) String

func (x *ReorderCommand) String() string

type RequestType

type RequestType uint16
const (
	AppendRequest RequestType = iota
	UpdateRequest
	DeleteRequest
	PublishRequest
	PrivateRequest
	ReorderRequest
	PublishMessagesRequest
	PrivateMessagesRequest
)

type StreamLayer

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

func NewStreamLayer

func NewStreamLayer(ln net.Listener) *StreamLayer

func (*StreamLayer) Accept

func (s *StreamLayer) Accept() (net.Conn, error)

func (*StreamLayer) Addr

func (s *StreamLayer) Addr() net.Addr

func (*StreamLayer) Close

func (s *StreamLayer) Close() error

func (*StreamLayer) Dial

func (s *StreamLayer) Dial(addr raft.ServerAddress, timeout time.Duration) (
	net.Conn, error,
)

type ThreadsRepository

type ThreadsRepository interface {
	AppendThread(ctx context.Context, id, userID, parentID, nextID, prevID int64, name, description, title string, private bool, createdAt, updatedAt string) (err error)
	UpdateThread(ctx context.Context, id, userID int64, name, description, title *string, updatedAt string) (err error)
	PrivateThread(ctx context.Context, id, userID int64, updatedAt string) error
	PublishThread(ctx context.Context, id, userID int64, updatedAt string) error
	DeleteThread(ctx context.Context, id, userID int64) error
	ReorderThread(ctx context.Context, id, userID, parentID, nextID, prevID int64, updatedAt string) (err error)
	PrivateMessages(ctx context.Context, ids []int64, userID int64) error
	PublishMessages(ctx context.Context, ids []int64, userID int64) 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"`
	Name        *string `protobuf:"bytes,3,opt,name=name,proto3,oneof" json:"name,omitempty"`
	Description *string `protobuf:"bytes,4,opt,name=description,proto3,oneof" json:"description,omitempty"`
	Title       *string `protobuf:"bytes,5,opt,name=title,proto3,oneof" json:"title,omitempty"`
	UpdatedAt   string  `protobuf:"bytes,6,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) GetDescription

func (x *UpdateCommand) GetDescription() string

func (*UpdateCommand) GetId

func (x *UpdateCommand) GetId() int64

func (*UpdateCommand) GetName

func (x *UpdateCommand) GetName() 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

Jump to

Keyboard shortcuts

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