cockroachdb

package
v0.0.0-...-8bf0aa5 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAgentNotFound        = errors.New("agent not found")
	ErrPreSharedKeyNotFound = errors.New("pre-shared key not found")
	ErrAgentDeactivated     = errors.New("agent deactivated")
)

Functions

This section is empty.

Types

type Database

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

func New

func New(config *config.Config, logger *zap.Logger) (*Database, error)

func (*Database) AgentShutdown

func (d *Database) AgentShutdown(ctx context.Context, agentID string) error

func (*Database) AgentStartup

func (d *Database) AgentStartup(ctx context.Context, agentID string) error

func (*Database) AuthenticateAgent

func (d *Database) AuthenticateAgent(ctx context.Context, key string, metadata *rpc.SystemMetadata) (agentID string, err error)

func (*Database) CanAccessProject

func (d *Database) CanAccessProject(ctx context.Context, subject, projectId string) (bool, error)

CanAccessProject returns true if a user can access a given project ID.

func (*Database) CreateHostGroup

func (d *Database) CreateHostGroup(ctx context.Context, projectId, name, description string) (string, error)

func (*Database) CreateProject

func (d *Database) CreateProject(ctx context.Context, subject, name, description string) (types.Project, error)

CreateProject creates a new project with the given name and description.

func (*Database) GeneratePreSharedKey

func (d *Database) GeneratePreSharedKey(ctx context.Context, projectId string, exp time.Time) (key string, err error)

func (*Database) GetEventLogsByHost

func (d *Database) GetEventLogsByHost(ctx context.Context, hostId string, limit int) (out []types.AgentEventLog, err error)

func (*Database) GetHost

func (d *Database) GetHost(ctx context.Context, hostId, projectId string) (out types.Host, err error)

func (*Database) GetProjectMetrics

func (d *Database) GetProjectMetrics(ctx context.Context, projectId string) (*types.ProjectMetrics, error)

func (*Database) GetUserProjects

func (d *Database) GetUserProjects(ctx context.Context, subject string) ([]types.Project, error)

func (*Database) Heartbeat

func (d *Database) Heartbeat(ctx context.Context, agentID string) error

func (*Database) ListProjectHosts

func (d *Database) ListProjectHosts(ctx context.Context, projectId string) (out []types.Host, err error)

ListProjectHosts returns all the hosts in a project. todo: pagination, sorting, etc...

func (*Database) Migrate

func (d *Database) Migrate(ctx context.Context) error

func (*Database) UpsertUser

func (d *Database) UpsertUser(ctx context.Context, subject string) ([]types.Project, error)

UpsertUser creates a new user if one doesn't exist and returns all the user's projects.

Jump to

Keyboard shortcuts

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