database

package
v0.0.1-pre Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResultKeyPrefix  = "res"
	RequestKeyPrefix = "req"
)

Variables

This section is empty.

Functions

func CutGroupPrefix

func CutGroupPrefix(result string) (string, bool)

CutGroupPrefix checks if a result string represents a grouped result. Returns the grouped value (without the "grouped:" prefix) and true if it's a grouped result.

func ExtractRequestIDFromResult

func ExtractRequestIDFromResult(result string, resultID string) (string, error)

ExtractRequestIDFromResult determines the appropriate request ID for a given result. For grouped results, it uses the result ID directly. For individual results, it follows the groupID vs individual ID logic.

func GenerateRequestKey

func GenerateRequestKey(id int64) []byte

GenerateRequestKey creates a database key for storing task requests using an integer ID.

func GenerateRequestKeyFromString

func GenerateRequestKeyFromString(id string) []byte

GenerateRequestKeyFromString creates a database key for storing task requests using a string ID.

func GenerateResultKey

func GenerateResultKey(id string) []byte

GenerateResultKey creates a database key for storing task results.

func GetFirstGroupedResultID

func GetFirstGroupedResultID(groupedValue string) string

GetFirstGroupedResultID extracts the first result ID from a grouped result value.

func MarshalRequest

func MarshalRequest(req *Request) ([]byte, error)

MarshalRequest serializes a request for database storage.

func MarshalTask

func MarshalTask(agentID agent.ID, result *proto.TaskResponse) ([]byte, error)

MarshalTask serializes a task with its agent and result for database storage.

Types

type Key

type Key struct {
	Prefix string
	ID     string
}

func StringToKey

func StringToKey(key string) (Key, error)

StringToKey parses a database key string into its prefix and ID components.

type Request

type Request struct {
	Task               string
	ConnectedTarget    []string
	DisconnectedTarget []string
}

func UnmarshalRequest

func UnmarshalRequest(data []byte) (*Request, error)

UnmarshalRequest deserializes request data from the database.

type Task

type Task struct {
	Agent  agent.ID
	Result *proto.TaskResponse
}

func UnmarshalTask

func UnmarshalTask(data []byte) (*Task, error)

UnmarshalTask deserializes task data from the database.

Jump to

Keyboard shortcuts

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