server

package
v0.16.5 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 59 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetaSweeper

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

MetaSweeper implements gc.Sweeper. It deletes entity_meta rows whose expires_at is in the past. Fires no events in S3; event dispatch is wired in S9 when the event subscription system lands.

func NewMetaSweeper

func NewMetaSweeper(db *sql.DB) *MetaSweeper

NewMetaSweeper creates a MetaSweeper backed by the given database.

func (*MetaSweeper) Sweep

func (m *MetaSweeper) Sweep(ctx context.Context) (gcpkg.Report, error)

Sweep deletes all expired entity_meta rows and returns a gc.Report.

type Server

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

Server represents the HTTP server

func New

func New(
	cfg *config.Config,
	store storage.Store,
	cache cache.Cache,
	g graph.Graph,
	validator validation.Validator,
	logger zerolog.Logger,
) *Server

New creates a new server instance

func (*Server) BlobSamplerFor

func (s *Server) BlobSamplerFor(tenantID uint16) *blob.UsageSampler

BlobSamplerFor returns the UsageSampler for a tenant, or nil when blobs are disabled, the tenant's store is not open, or the sampler interval is zero. Exposed for tests that need to call ForceResample() deterministically.

func (*Server) BlobStoreForTest

func (s *Server) BlobStoreForTest(tenantID uint16) (*blob.Store, error)

BlobStoreForTest opens (if needed) and returns a tenant's blob store via the manager. Exposed for tests that need to seed blobs through the same store instance the server uses, so the per-tenant sampler is created and warm.

func (*Server) CalManagerForTest

func (s *Server) CalManagerForTest() *cal.Manager

CalManagerForTest exposes the calendar manager for HTTP-level tests that need to seed calendars and bookings through the same manager the handlers use. Returns nil when the cal subsystem is disabled.

Introduced in v0.14.8 alongside the T-18 HTTP test suite. Not part of the public API — the ForTest suffix marks it as a test-only accessor.

func (*Server) HandleTSAggregate

func (s *Server) HandleTSAggregate(w http.ResponseWriter, r *http.Request)

HandleTSAggregate computes an aggregate over a numeric field.

POST /api/v1/tenant/{tenant_id}/ts/aggregate

func (*Server) HandleTSAppend

func (s *Server) HandleTSAppend(w http.ResponseWriter, r *http.Request)

HandleTSAppend appends a single event.

POST /api/v1/tenant/{tenant_id}/ts/events

func (*Server) HandleTSBatchAppend

func (s *Server) HandleTSBatchAppend(w http.ResponseWriter, r *http.Request)

HandleTSBatchAppend appends a batch of events atomically.

POST /api/v1/tenant/{tenant_id}/ts/events/batch

func (*Server) HandleTSDefineRollup

func (s *Server) HandleTSDefineRollup(w http.ResponseWriter, r *http.Request)

HandleTSDefineRollup creates a rollup definition on a source timeline.

POST /api/v1/tenant/{tenant_id}/ts/timelines/{timeline_id}/rollup/def

func (*Server) HandleTSDefineTimeline

func (s *Server) HandleTSDefineTimeline(w http.ResponseWriter, r *http.Request)

HandleTSDefineTimeline defines or updates a timeline.

POST /api/v1/tenant/{tenant_id}/ts/timelines

func (*Server) HandleTSDeleteRollup

func (s *Server) HandleTSDeleteRollup(w http.ResponseWriter, r *http.Request)

HandleTSDeleteRollup removes a rollup definition and stops its worker.

DELETE /api/v1/tenant/{tenant_id}/ts/timelines/{timeline_id}/rollup/{rollup_id}

func (*Server) HandleTSDeleteTimeline

func (s *Server) HandleTSDeleteTimeline(w http.ResponseWriter, r *http.Request)

HandleTSDeleteTimeline removes a timeline definition together with its event data and rollups (the inverse of define; distinct from DeleteTimelineData, which keeps the definition). When rollup cascade is disabled and the timeline still has rollups, the store returns ErrTSRollupDestInUse and this responds 409 so the caller knows to remove the rollups first; an unknown timeline is 404.

DELETE /api/v1/tenant/{tenant_id}/ts/tl/{timeline_id}

func (*Server) HandleTSDeleteTimelineData

func (s *Server) HandleTSDeleteTimelineData(w http.ResponseWriter, r *http.Request)

HandleTSDeleteTimelineData removes all events from a timeline.

DELETE /api/v1/tenant/{tenant_id}/ts/timelines/{timeline_id}/data

func (*Server) HandleTSFullAggregate

func (s *Server) HandleTSFullAggregate(w http.ResponseWriter, r *http.Request)

func (*Server) HandleTSGetRetention

func (s *Server) HandleTSGetRetention(w http.ResponseWriter, r *http.Request)

HandleTSGetRetention returns the retention configuration.

GET /api/v1/tenant/{tenant_id}/ts/retention

func (*Server) HandleTSGetRollup

func (s *Server) HandleTSGetRollup(w http.ResponseWriter, r *http.Request)

HandleTSGetRollup returns a specific rollup definition.

GET /api/v1/tenant/{tenant_id}/ts/timelines/{timeline_id}/rollup/{rollup_id}

func (*Server) HandleTSGetTimeline

func (s *Server) HandleTSGetTimeline(w http.ResponseWriter, r *http.Request)

HandleTSGetTimeline returns a single timeline.

GET /api/v1/tenant/{tenant_id}/ts/timelines/{timeline_id}

func (*Server) HandleTSLatest

func (s *Server) HandleTSLatest(w http.ResponseWriter, r *http.Request)

HandleTSLatest returns the N most recent events.

GET /api/v1/tenant/{tenant_id}/ts/events/latest

func (*Server) HandleTSListRollups

func (s *Server) HandleTSListRollups(w http.ResponseWriter, r *http.Request)

HandleTSListRollups lists all rollup definitions for a source timeline.

GET /api/v1/tenant/{tenant_id}/ts/timelines/{timeline_id}/rollup/list

func (*Server) HandleTSListTimelines

func (s *Server) HandleTSListTimelines(w http.ResponseWriter, r *http.Request)

HandleTSListTimelines returns all defined timelines.

GET /api/v1/tenant/{tenant_id}/ts/timelines

func (*Server) HandleTSPatchRetention

func (s *Server) HandleTSPatchRetention(w http.ResponseWriter, r *http.Request)

func (*Server) HandleTSProvision

func (s *Server) HandleTSProvision(w http.ResponseWriter, r *http.Request)

HandleTSProvision provisions timeseries for a tenant.

POST /api/v1/tenant/{tenant_id}/ts/provision

func (*Server) HandleTSPurgeTimelineRange

func (s *Server) HandleTSPurgeTimelineRange(w http.ResponseWriter, r *http.Request)

HandleTSPurgeTimelineRange removes events in a time range from a timeline.

POST /api/v1/tenant/{tenant_id}/ts/timelines/{timeline_id}/data/purge

func (*Server) HandleTSQueryRange

func (s *Server) HandleTSQueryRange(w http.ResponseWriter, r *http.Request)

HandleTSQueryRange returns events in a time range.

GET /api/v1/tenant/{tenant_id}/ts/events

func (*Server) HandleTSQueryRangePost

func (s *Server) HandleTSQueryRangePost(w http.ResponseWriter, r *http.Request)

HandleTSQueryRangePost is the POST equivalent of HandleTSQueryRange. It accepts the same parameters as a JSON body instead of query-string values, which is more ergonomic for complex queries and avoids URL-length limits.

POST /api/v1/tenant/{tenant_id}/ts/query/range

Request body:

{
  "timeline": 1,
  "dims":     [42],
  "from":     "2026-01-01T00:00:00Z",
  "to":       "2026-01-02T00:00:00Z",
  "limit":    1000,   // optional; default 1000, max TSMaxQueryEvents
  "order":    "asc"   // optional; "asc" (default) or "desc"
}

func (*Server) HandleTSRangeAggregate

func (s *Server) HandleTSRangeAggregate(w http.ResponseWriter, r *http.Request)

func (*Server) HandleTSRollupParent

func (s *Server) HandleTSRollupParent(w http.ResponseWriter, r *http.Request)

HandleTSRollupParent returns the rollup definition for which this timeline is the destination — i.e. its parent in the rollup tree.

GET /api/v1/tenant/{tenant_id}/ts/timelines/{timeline_id}/rollup/parent

func (*Server) HandleTSRollupStatus

func (s *Server) HandleTSRollupStatus(w http.ResponseWriter, r *http.Request)

HandleTSRollupStatus returns the operational status of a rollup worker.

GET /api/v1/tenant/{tenant_id}/ts/timelines/{timeline_id}/rollup/{rollup_id}/status

func (*Server) HandleTSRollupTree

func (s *Server) HandleTSRollupTree(w http.ResponseWriter, r *http.Request)

HandleTSRollupTree returns the full rollup tree for the tenant.

GET /api/v1/tenant/{tenant_id}/ts/rollup/tree

func (*Server) HandleTSRunRollup

func (s *Server) HandleTSRunRollup(w http.ResponseWriter, r *http.Request)

HandleTSRunRollup manually triggers a rollup execution for the given range. If cascade is true in the request body, all descendant rollup definitions are also run for the corresponding time windows, in source→destination order. Workers are started for this definition and all cascaded descendants.

POST /api/v1/tenant/{tenant_id}/ts/timelines/{timeline_id}/rollup/{rollup_id}/run

func (*Server) HandleTSStats

func (s *Server) HandleTSStats(w http.ResponseWriter, r *http.Request)

HandleTSStats returns store-level diagnostics.

GET /api/v1/tenant/{tenant_id}/ts/stats

func (*Server) HandleTSSyncGet

func (s *Server) HandleTSSyncGet(w http.ResponseWriter, r *http.Request)

HandleTSSyncGet returns the current nosync setting for a timeline.

GET /api/v1/tenant/{tenant_id}/ts/timelines/{timeline_id}/sync

func (*Server) HandleTSSyncOff

func (s *Server) HandleTSSyncOff(w http.ResponseWriter, r *http.Request)

HandleTSSyncOff enables nosync mode for a timeline (NoSync=true). AppendBatch will no longer wait for WAL fsync before returning. Data loss is possible if the process crashes before the OS flushes the WAL to disk. The loss window is bounded by the kernel dirty-page writeback interval, typically under one second.

POST /api/v1/tenant/{tenant_id}/ts/timelines/{timeline_id}/sync/off

func (*Server) HandleTSSyncOn

func (s *Server) HandleTSSyncOn(w http.ResponseWriter, r *http.Request)

HandleTSSyncOn restores synchronous write mode for a timeline (NoSync=false). AppendBatch will again wait for WAL fsync before returning. This is the default mode and provides crash durability.

POST /api/v1/tenant/{tenant_id}/ts/timelines/{timeline_id}/sync/on

func (*Server) HandleTSTimelineStats

func (s *Server) HandleTSTimelineStats(w http.ResponseWriter, r *http.Request)

HandleTSTimelineStats returns per-timeline diagnostics.

GET /api/v1/tenant/{tenant_id}/ts/stats/{timeline_id}

func (*Server) HandleTSUpdateTimeline

func (s *Server) HandleTSUpdateTimeline(w http.ResponseWriter, r *http.Request)

HandleTSUpdateTimeline updates a timeline's mutable fields.

PATCH /api/v1/tenant/{tenant_id}/ts/timelines/{timeline_id}

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the HTTP handler (useful for testing)

func (*Server) MarkReady

func (s *Server) MarkReady()

MarkReady sets the server as ready. This is called automatically by Start(), but can be called manually in test setups that use httptest.NewServer instead of Start().

func (*Server) S3Handler

func (s *Server) S3Handler() http.Handler

S3Handler returns an http.Handler for the S3-compatible API surface. Used in tests to wire the S3 router to an httptest.Server without needing a real TCP port. Returns nil when the blob store is not initialised.

func (*Server) SetGraphQueryCacheTTL

func (s *Server) SetGraphQueryCacheTTL(seconds int)

── Graph query result cache ──────────────────────────────────────────────────

SetGraphQueryCacheTTL sets the whole-query result cache TTL at runtime. Primarily used by tests that need a short TTL without rebuilding the server. A value of 0 disables query result caching.

func (*Server) SetTSManager

func (s *Server) SetTSManager(m timeseries.Manager)

SetTSManager replaces the server's timeseries Manager. Intended for testing only: it allows injecting a fake or failing manager after construction so that failure paths (e.g. XOLU-CM016) can be exercised deterministically. Must not be called concurrently with request handling.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the HTTP server, allowing in-flight requests to complete within the given context deadline.

func (*Server) Start

func (s *Server) Start() error

Start starts the HTTP server

func (*Server) Stop

func (s *Server) Stop()

Stop stops the server and cleans up resources

func (*Server) TSManager

func (s *Server) TSManager() timeseries.Manager

TSManager returns the server's timeseries Manager. Returns nil when timeseries is disabled. Exposed primarily for testing — production code should not replace the manager after the server has started serving requests.

func (*Server) TenantRegistry

func (s *Server) TenantRegistry() *tenant.Registry

TenantRegistry returns the server's tenant registry. This is primarily useful for pre-registering tenants in strict mode before starting the server.

Jump to

Keyboard shortcuts

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