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_sessions_internal_machine_commands_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type AppendCommand

type AppendCommand struct {
	UserId    int64  `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	Token     string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"`
	ExpiresAt string `protobuf:"bytes,3,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"`
	CreatedAt string `protobuf:"bytes,4,opt,name=created_at,json=createdAt,proto3" json:"created_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) GetExpiresAt

func (x *AppendCommand) GetExpiresAt() string

func (*AppendCommand) GetToken

func (x *AppendCommand) GetToken() 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 {
	Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
	// contains filtered or unexported fields
}

func (*DeleteCommand) Descriptor deprecated

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

Deprecated: Use DeleteCommand.ProtoReflect.Descriptor instead.

func (*DeleteCommand) GetToken

func (x *DeleteCommand) GetToken() string

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 DeleteUserSessionsCommand

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

func (*DeleteUserSessionsCommand) Descriptor deprecated

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

Deprecated: Use DeleteUserSessionsCommand.ProtoReflect.Descriptor instead.

func (*DeleteUserSessionsCommand) GetUserId

func (x *DeleteUserSessionsCommand) GetUserId() int64

func (*DeleteUserSessionsCommand) ProtoMessage

func (*DeleteUserSessionsCommand) ProtoMessage()

func (*DeleteUserSessionsCommand) ProtoReflect

func (*DeleteUserSessionsCommand) Reset

func (x *DeleteUserSessionsCommand) Reset()

func (*DeleteUserSessionsCommand) String

func (x *DeleteUserSessionsCommand) String() string

type Dumper

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

type Machine

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

func New

func New(sessionsRepo SessionsRepository, 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 RequestType

type RequestType uint16
const (
	AppendRequest RequestType = iota
	DeleteRequest
	DeleteUserSessionsRequest
)

type SessionsRepository

type SessionsRepository interface {
	Save(ctx context.Context, userID int64, token, createdAt, expiresAt string) (err error)
	Delete(ctx context.Context, token string) (err error)
	DeleteAll(ctx context.Context, userID int64) (err error)
}

Jump to

Keyboard shortcuts

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