machinechannel

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHeartbeatInterval = 15 * time.Second
	DefaultHeartbeatTimeout  = 45 * time.Second
	DefaultReconnectBackoff  = 5 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectedSessionRecord

type ConnectedSessionRecord struct {
	MachineID        uuid.UUID
	SessionID        string
	ConnectedAt      time.Time
	SystemInfo       domain.SystemInfo
	ToolInventory    []domain.ToolInfo
	ResourceSnapshot *domain.ResourceSnapshot
}

type CreateTokenRecord

type CreateTokenRecord struct {
	MachineID uuid.UUID
	TokenHash string
	ExpiresAt time.Time
}

type Daemon

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

func NewDaemon

func NewDaemon(logger *slog.Logger) *Daemon

func (*Daemon) Run

func (d *Daemon) Run(ctx context.Context, config domain.DaemonConfig) error

type DisconnectedSessionRecord

type DisconnectedSessionRecord struct {
	MachineID      uuid.UUID
	SessionID      string
	DisconnectedAt time.Time
	Reason         string
}

type ExpiredSession

type ExpiredSession struct {
	MachineID      uuid.UUID
	SessionID      string
	DisconnectedAt time.Time
}

type HeartbeatRecord

type HeartbeatRecord struct {
	MachineID        uuid.UUID
	SessionID        string
	HeartbeatAt      time.Time
	SystemInfo       *domain.SystemInfo
	ToolInventory    []domain.ToolInfo
	ResourceSnapshot *domain.ResourceSnapshot
}

type MachineRecord

type MachineRecord struct {
	ID                    uuid.UUID
	OrganizationID        uuid.UUID
	Name                  string
	ConnectionMode        string
	Status                string
	ChannelCredentialKind string
	ChannelTokenID        *string
}

type RegisteredSession

type RegisteredSession struct {
	MachineID       uuid.UUID
	SessionID       string
	ConnectedAt     time.Time
	LastHeartbeatAt time.Time
	Replaced        bool
	// contains filtered or unexported fields
}

type Repository

type Repository interface {
	GetMachine(ctx context.Context, machineID uuid.UUID) (MachineRecord, error)
	IssueToken(ctx context.Context, input CreateTokenRecord) (TokenRecord, error)
	TokenByHash(ctx context.Context, tokenHash string) (TokenRecord, error)
	TouchTokenLastUsed(ctx context.Context, tokenID uuid.UUID, usedAt time.Time) error
	RevokeToken(ctx context.Context, machineID uuid.UUID, tokenID uuid.UUID, revokedAt time.Time) error
	RecordConnectedSession(ctx context.Context, input ConnectedSessionRecord) (MachineRecord, error)
	RecordHeartbeat(ctx context.Context, input HeartbeatRecord) (MachineRecord, error)
	RecordDisconnectedSession(ctx context.Context, input DisconnectedSessionRecord) (MachineRecord, error)
}

type Service

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

func NewService

func NewService(repo Repository) *Service

func (*Service) Authenticate

func (s *Service) Authenticate(ctx context.Context, rawToken string) (domain.Claims, error)

func (*Service) IssueToken

func (s *Service) IssueToken(ctx context.Context, input domain.IssueInput) (domain.IssuedToken, error)

func (*Service) RecordConnectedSession

func (s *Service) RecordConnectedSession(ctx context.Context, input ConnectedSessionRecord) (MachineRecord, error)

func (*Service) RecordDisconnectedSession

func (s *Service) RecordDisconnectedSession(ctx context.Context, input DisconnectedSessionRecord) (MachineRecord, error)

func (*Service) RecordHeartbeat

func (s *Service) RecordHeartbeat(ctx context.Context, input HeartbeatRecord) (MachineRecord, error)

func (*Service) RevokeToken

func (s *Service) RevokeToken(ctx context.Context, machineID uuid.UUID, tokenID uuid.UUID) error

type SessionCloser

type SessionCloser interface {
	Close(reason string) error
}

type SessionRegistry

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

func NewSessionRegistry

func NewSessionRegistry(timeout time.Duration) *SessionRegistry

func (*SessionRegistry) CloseAll

func (r *SessionRegistry) CloseAll(reason string) []RegisteredSession

func (*SessionRegistry) Count

func (r *SessionRegistry) Count() int

func (*SessionRegistry) Expire

func (r *SessionRegistry) Expire(now time.Time) []ExpiredSession

func (*SessionRegistry) Heartbeat

func (r *SessionRegistry) Heartbeat(sessionID string, heartbeatAt time.Time) (RegisteredSession, bool)

func (*SessionRegistry) Register

func (r *SessionRegistry) Register(machineID uuid.UUID, sessionID string, connectedAt time.Time, closer SessionCloser) (RegisteredSession, *RegisteredSession)

func (*SessionRegistry) Remove

func (r *SessionRegistry) Remove(sessionID string) (RegisteredSession, bool)

func (*SessionRegistry) Snapshot

func (r *SessionRegistry) Snapshot(machineID uuid.UUID) (RegisteredSession, bool)

type TokenRecord

type TokenRecord struct {
	TokenID   uuid.UUID
	MachineID uuid.UUID
	TokenHash string
	Status    string
	ExpiresAt time.Time
	RevokedAt *time.Time
}

Jump to

Keyboard shortcuts

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