db

package
v0.0.0-...-2254657 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddRoomMemberParams

type AddRoomMemberParams struct {
	ConnectionUuid string
	RoomUuid       string
}

type Connection

type Connection struct {
	Uuid        string
	MachineUuid string
	CreatedAt   pgtype.Timestamptz
	LastUpdated pgtype.Timestamptz
}

type CreateConnectionParams

type CreateConnectionParams struct {
	Uuid        string
	MachineUuid string
}

type CreateMachineParams

type CreateMachineParams struct {
	Uuid        string
	MachineType string
}

type CreateRoomParams

type CreateRoomParams struct {
	Uuid            string
	MachineUuid     string
	Name            string
	Script          string
	DestroyOnOrphan bool
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type Machine

type Machine struct {
	Uuid        string
	MachineType string
	CreatedAt   pgtype.Timestamp
	LastUpdated pgtype.Timestamp
}

type MachineTypeLeader

type MachineTypeLeader struct {
	MachineUuid string
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) AddRoomMember

func (q *Queries) AddRoomMember(ctx context.Context, arg AddRoomMemberParams) error

CREATE TABLE room_membership (

connection_uuid TEXT NOT NULL REFERENCES connections(uuid) ON DELETE CASCADE,
room_uuid TEXT NOT NULL REFERENCES rooms(uuid) ON DELETE CASCADE

);

func (*Queries) CreateConnection

func (q *Queries) CreateConnection(ctx context.Context, arg CreateConnectionParams) error

CREATE TABLE connections (

uuid TEXT PRIMARY KEY,
machine_uuid TEXT NOT NULL REFERENCES machines(uuid) ,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
last_updated TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP

);

func (*Queries) CreateLeader

func (q *Queries) CreateLeader(ctx context.Context, machineUuid string) error

func (*Queries) CreateMachine

func (q *Queries) CreateMachine(ctx context.Context, arg CreateMachineParams) error

func (*Queries) CreateRoom

func (q *Queries) CreateRoom(ctx context.Context, arg CreateRoomParams) error

func (*Queries) DeleteConnection

func (q *Queries) DeleteConnection(ctx context.Context, uuid string) error

func (*Queries) DeleteLeader

func (q *Queries) DeleteLeader(ctx context.Context, machineUuid string) error

func (*Queries) DeleteMachine

func (q *Queries) DeleteMachine(ctx context.Context, uuid string) error

func (*Queries) DeleteRoom

func (q *Queries) DeleteRoom(ctx context.Context, uuid string) error

func (*Queries) FindMachine

func (q *Queries) FindMachine(ctx context.Context, uuid string) (Connection, error)

func (*Queries) GetConnections

func (q *Queries) GetConnections(ctx context.Context) ([]Connection, error)

func (*Queries) GetConnectionsByMachine

func (q *Queries) GetConnectionsByMachine(ctx context.Context, machineUuid string) ([]Connection, error)

func (*Queries) GetLeaderForType

func (q *Queries) GetLeaderForType(ctx context.Context, machineType string) (string, error)

func (*Queries) GetMachine

func (q *Queries) GetMachine(ctx context.Context, uuid string) (Machine, error)

func (*Queries) GetMachineLeaderCountByType

func (q *Queries) GetMachineLeaderCountByType(ctx context.Context, machineType string) (int64, error)

func (*Queries) GetMachines

func (q *Queries) GetMachines(ctx context.Context) ([]Machine, error)

func (*Queries) GetMachinesByType

func (q *Queries) GetMachinesByType(ctx context.Context, machineType string) ([]Machine, error)

func (*Queries) GetMembershipByConnection

func (q *Queries) GetMembershipByConnection(ctx context.Context, connectionUuid string) ([]string, error)

func (*Queries) GetOrphanedRooms

func (q *Queries) GetOrphanedRooms(ctx context.Context) ([]Room, error)

func (*Queries) GetRoomMembers

func (q *Queries) GetRoomMembers(ctx context.Context, roomUuid string) ([]string, error)

func (*Queries) GetRooms

func (q *Queries) GetRooms(ctx context.Context) ([]Room, error)

CREATE TABLE rooms (

uuid TEXT PRIMARY KEY,
machine_uuid TEXT NOT NULL REFERENCES machines(uuid) ,
name TEXT NOT NULL,
script TEXT NOT NULL,
destroy_on_orphan BOOLEAN NOT NULL

);

func (*Queries) GetRoomsByMachine

func (q *Queries) GetRoomsByMachine(ctx context.Context, machineUuid string) ([]Room, error)

func (*Queries) RemoveRoomMember

func (q *Queries) RemoveRoomMember(ctx context.Context, arg RemoveRoomMemberParams) error

func (*Queries) SetMachineAsLeader

func (q *Queries) SetMachineAsLeader(ctx context.Context, machineUuid string) error

func (*Queries) SetRoomOwner

func (q *Queries) SetRoomOwner(ctx context.Context, arg SetRoomOwnerParams) error

func (*Queries) TouchConnection

func (q *Queries) TouchConnection(ctx context.Context, uuid string) error

func (*Queries) TouchMachine

func (q *Queries) TouchMachine(ctx context.Context, uuid string) error

func (*Queries) UpdateMachine

func (q *Queries) UpdateMachine(ctx context.Context, uuid string) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type RemoveRoomMemberParams

type RemoveRoomMemberParams struct {
	ConnectionUuid string
	RoomUuid       string
}

type Room

type Room struct {
	Uuid            string
	MachineUuid     string
	Name            string
	Script          string
	DestroyOnOrphan bool
	CreatedAt       pgtype.Timestamp
	LastUpdated     pgtype.Timestamp
}

type RoomDatum

type RoomDatum struct {
	RoomUuid pgtype.Text
	Key      string
	Value    pgtype.Text
}

type RoomMembership

type RoomMembership struct {
	ConnectionUuid string
	RoomUuid       string
}

type SetRoomOwnerParams

type SetRoomOwnerParams struct {
	Uuid          string
	MachineUuid   string
	MachineUuid_2 string
}

Jump to

Keyboard shortcuts

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