rankedb

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package rankedb provides a worker-friendly wrapper around the generated RankeDB API client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ptr

func Ptr(s string) *string

Ptr returns a pointer to the given string.

func PtrF

func PtrF(f float64) *float64

PtrF returns a pointer to the given float64.

Types

type Client

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

Client wraps the generated API client with worker convenience methods.

func NewClient

func NewClient(server string) (*Client, error)

NewClient creates a RankeDB worker client for the given server URL.

func (*Client) CreateNode

func (c *Client) CreateNode(ctx context.Context, req CreateNodeRequest) (*apiclient.NodeResponse, error)

CreateNode creates a node with edges in a single atomic transaction. This uses a manual POST because the generated client doesn't support a request body for this endpoint (it's a RawRoute in schemaf).

func (*Client) CreateRun

func (c *Client) CreateRun(ctx context.Context, workerConfigID string) (string, error)

CreateRun registers a new worker run and returns the run_id.

func (*Client) EnsureWorkerConfig

func (c *Client) EnsureWorkerConfig(ctx context.Context, cfg WorkerConfig) (string, error)

EnsureWorkerConfig creates a worker/config node if it doesn't already exist, and returns its node ID. Idempotent by content hash.

func (*Client) GetNode

func (c *Client) GetNode(ctx context.Context, id string) (*apiclient.NodeResponse, error)

GetNode fetches a node by ID.

func (*Client) StartRun

func (c *Client) StartRun(ctx context.Context, cfg WorkerConfig) (configID string, runID string, err error)

StartRun registers a worker config and starts a new run, returning both IDs.

type CreateNodeRequest

type CreateNodeRequest struct {
	Level                 int        `json:"level"`
	ContentClass          string     `json:"content_class"`
	ContentType           string     `json:"content_type"`
	EncodingClass         string     `json:"encoding_class"`
	EncodingFormat        string     `json:"encoding_format"`
	Content               *string    `json:"content,omitempty"`
	ArtifactCreatedAt     *string    `json:"artifact_created_at,omitempty"`
	ArtifactCreatedAtBlur *string    `json:"artifact_created_at_blur,omitempty"`
	Origin                *string    `json:"origin,omitempty"`
	OriginalName          *string    `json:"original_name,omitempty"`
	ValidFrom             *string    `json:"valid_from,omitempty"`
	ValidFromBlur         *string    `json:"valid_from_blur,omitempty"`
	ValidUntil            *string    `json:"valid_until,omitempty"`
	ValidUntilBlur        *string    `json:"valid_until_blur,omitempty"`
	Confidence            *float64   `json:"confidence,omitempty"`
	Edges                 []EdgeSpec `json:"edges,omitempty"`
}

CreateNodeRequest is the JSON body for POST /api/nodes. This is defined here because the generated client doesn't include a request body type for the RawRoute endpoint.

type EdgeSpec

type EdgeSpec struct {
	SourceNodeID string   `json:"source_node_id,omitempty"`
	TargetNodeID string   `json:"target_node_id,omitempty"`
	Type         string   `json:"type"`
	Confidence   *float64 `json:"confidence,omitempty"`
	RunID        *string  `json:"run_id,omitempty"`
}

EdgeSpec defines an edge to create alongside a node.

type WorkerConfig

type WorkerConfig struct {
	Name    string            `json:"name"`
	Version string            `json:"version"`
	Params  map[string]string `json:"params,omitempty"`
}

WorkerConfig holds the identity of a worker for registration with RankeDB.

Jump to

Keyboard shortcuts

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