pgstore

package
v0.0.0-...-520c4d9 Latest Latest
Warning

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

Go to latest
Published: May 13, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package pgstore implements the userstore.Store interface using PostgreSQL

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PGDataStore

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

Package pgstore implements the userstore.Store interface using PostgreSQL PGDataStore is a struct that represents a PostgreSQL data store It contains a pointer to the sql.DB object for database operations

func NewPGDataStore

func NewPGDataStore(db *sql.DB) *PGDataStore

New creates a new PGDataStore instance

func (*PGDataStore) Close

func (s *PGDataStore) Close() error

Close closes the database connection It checks if the db is not nil before attempting to close it

func (*PGDataStore) DeleteTag

func (s *PGDataStore) DeleteTag(ctx context.Context, endpointID, key string) error

DeleteTag removes a specific tag for a given endpoint ID.

func (*PGDataStore) GetAgentByHostname

func (s *PGDataStore) GetAgentByHostname(ctx context.Context, hostname string) (*model.Agent, error)

GetAgentByHostname retrieves an agent by its hostname

func (*PGDataStore) GetAgentByID

func (s *PGDataStore) GetAgentByID(ctx context.Context, id string) (*model.Agent, error)

GetAgentByAgentID retrieves an agent by its agent_id This is used for the agent to check in with the server

func (*PGDataStore) GetAllTags

func (s *PGDataStore) GetAllTags(ctx context.Context) ([]model.Tag, error)

func (*PGDataStore) GetContainerByID

func (s *PGDataStore) GetContainerByID(ctx context.Context, id string) (*model.Container, error)

GetContainerByID retrieves a container by its container_id

func (*PGDataStore) GetTags

func (s *PGDataStore) GetTags(ctx context.Context, endpointID string) (map[string]string, error)

GetTags retrieves all tags for a given endpoint ID.

func (*PGDataStore) InsertFullProcessPayload

func (s *PGDataStore) InsertFullProcessPayload(ctx context.Context, payload *model.ProcessPayload) error

InsertFullProcessPayload inserts a complete process payload into the database,

func (*PGDataStore) InsertProcessInfos

func (s *PGDataStore) InsertProcessInfos(ctx context.Context, snapshotID int64, payload *model.ProcessPayload) error

InsertProcessInfos inserts multiple process information records associated with a snapshot.

func (*PGDataStore) InsertProcessSnapshot

func (s *PGDataStore) InsertProcessSnapshot(ctx context.Context, snap *model.ProcessPayload) (int64, error)

InsertProcessSnapshot inserts a new process snapshot into the database.

func (*PGDataStore) ListAgents

func (s *PGDataStore) ListAgents(ctx context.Context) ([]*model.Agent, error)

ListAgents retrieves all agents from the database This is used for the web UI to display all agents and for the agent to check in with the server

func (*PGDataStore) ListContainers

func (s *PGDataStore) ListContainers(ctx context.Context) ([]*model.Container, error)

ListContainers retrieves all containers from the database This is used for the web UI to display all containers and for the agent to check in with the server

func (*PGDataStore) ListKeys

func (s *PGDataStore) ListKeys(ctx context.Context) ([]string, error)

ListKeys returns all unique tag keys

func (*PGDataStore) ListTags

func (s *PGDataStore) ListTags(ctx context.Context, endpointID string) (map[string]string, error)

ListTags retrieves all tags for a given endpoint ID.

func (*PGDataStore) ListValues

func (s *PGDataStore) ListValues(ctx context.Context, key string) ([]string, error)

ListValues returns all values for a given key

func (*PGDataStore) QueryProcessInfos

func (s *PGDataStore) QueryProcessInfos(ctx context.Context, filter *model.ProcessQueryFilter) ([]model.ProcessInfo, error)

func (*PGDataStore) SetTags

func (s *PGDataStore) SetTags(ctx context.Context, endpointID string, tags map[string]string) error

SetTags replaces all tags for a given endpoint ID with the provided tags.

func (*PGDataStore) UpsertAgent

func (s *PGDataStore) UpsertAgent(ctx context.Context, agent *model.Agent) error

func (*PGDataStore) UpsertContainer

func (s *PGDataStore) UpsertContainer(ctx context.Context, c *model.Container) error

UpsertContainer inserts or updates a container in the database This is used for the agent to check in with the server It also updates the last_seen field to the current time and the status field to "Running" if the container is running or "Stopped" if the container is stopped UpsertContainer inserts or updates a container in the database

func (*PGDataStore) Write

func (s *PGDataStore) Write(ctx context.Context, batches []*model.ProcessPayload) error

Write fullfills the interface in BufferedDataStore

Jump to

Keyboard shortcuts

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