api

package
v0.45.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 19 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureRouter

func ConfigureRouter() *http.ServeMux

func RegisterHealthChecker added in v0.37.0

func RegisterHealthChecker(hc HealthChecker)

RegisterHealthChecker adds a health checker to be queried during health checks

func ResetHealthCheckers added in v0.37.0

func ResetHealthCheckers()

ResetHealthCheckers clears all registered health checkers. This is intended for use in tests to prevent state leakage between tests.

func WriteJSON added in v0.43.0

func WriteJSON(w http.ResponseWriter, status int, v any)

WriteJSON writes v as a JSON response with the given status code.

Types

type API

type API interface {
	Start() error
	Shutdown(context.Context) error
	AddRoute(method, path string, handler http.HandlerFunc)
}

type APIOption

type APIOption func(*APIv1)

func WithGroup

func WithGroup(group string) APIOption

func WithHost

func WithHost(host string) APIOption

func WithPort

func WithPort(port uint) APIOption

type APIRouteRegistrar

type APIRouteRegistrar interface {
	RegisterRoutes()
}

type APIv1

type APIv1 struct {
	Host string
	Port uint
	// contains filtered or unexported fields
}

func GetInstance

func GetInstance() *APIv1

func New

func New(debug bool, options ...APIOption) *APIv1

New initializes the singleton API instance. The debug parameter is retained for backward compatibility; access-log verbosity is now governed by the configured logging level (LOGGING_LEVEL), not by this flag.

func (*APIv1) AddRoute

func (a *APIv1) AddRoute(method, path string, handler http.HandlerFunc)

AddRoute registers handler for method+path under the configured group base path. Note: net/http's ServeMux panics if the same method+pattern is registered twice, so callers must register each route only once (the push plugin guards this with a routesRegistered flag). A path that already ends in "/" is registered as a ServeMux subtree (prefix match) with no exact-match variant, matching all sub-paths; avoid trailing slashes unless that is intended.

func (*APIv1) BasePath added in v0.43.0

func (a *APIv1) BasePath() string

BasePath returns the configured route group prefix (e.g. "/v1"), or "".

func (*APIv1) Engine

func (a *APIv1) Engine() http.Handler

Engine returns the middleware-wrapped HTTP handler. Routes added via AddRoute after this call remain reachable because the handler wraps the underlying mux by reference.

func (*APIv1) HandleFunc added in v0.43.0

func (a *APIv1) HandleFunc(pattern string, handler http.HandlerFunc)

HandleFunc registers a handler on the underlying mux without the group prefix. The pattern must include the method, e.g. "GET /events".

func (*APIv1) Shutdown added in v0.43.0

func (a *APIv1) Shutdown(ctx context.Context) error

func (*APIv1) Start

func (a *APIv1) Start() error

@license.name Apache 2.0 @license.url http://www.apache.org/licenses/LICENSE-2.0.html

type EventHub added in v0.38.0

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

EventHub manages event broadcasting to connected WebSocket/SSE clients. Call Close() to shut down the hub and release resources.

func NewEventHub added in v0.38.0

func NewEventHub(ringSize uint) *EventHub

NewEventHub creates a hub with the given ring buffer size.

func (*EventHub) Broadcast added in v0.38.0

func (h *EventHub) Broadcast(evt event.Event)

Broadcast sends an event to all connected clients. Called from the pipeline observer goroutine. Non-blocking per client.

The lock is held for the entire client iteration because the cleanup path closes client.send under the same lock. Releasing the lock before sending would allow a concurrent close, causing a send-to-closed-channel panic. The sends are non-blocking (select with default) so lock duration is bounded.

func (*EventHub) Close added in v0.38.0

func (h *EventHub) Close()

Close shuts down the hub, terminating the InputChan goroutine and allowing client handlers to exit cleanly. Blocks until background goroutines have exited.

func (*EventHub) HandleEvents added in v0.38.0

func (h *EventHub) HandleEvents(w http.ResponseWriter, r *http.Request)

HandleEvents is the net/http handler for GET /events. It upgrades to WebSocket if possible, otherwise falls back to SSE.

@Summary		Stream Blockchain Events
@Description	Real-time pipeline event streaming. Automatically upgrades to WebSocket if requested by the client, otherwise falls back to Server-Sent Events (SSE). Supports filtering on event types.
@Param			types	query	string	false	"Comma-separated list of event types to filter (e.g., input.block,input.transaction)"
@Param			replay	query	boolean	false	"Whether to replay recent events from the ring buffer on connection"	default(true)
@Produce		text/event-stream,application/json
@Success		200	{string}	string	"Event Stream (SSE) or WebSocket Session"
@Router			/events [get]

func (*EventHub) InputChan added in v0.38.0

func (h *EventHub) InputChan() chan<- event.Event

InputChan returns a channel that feeds the hub. The hub reads events from this channel and broadcasts them. Used as the pipeline observer target. The goroutine exits when Close() is called or the channel is closed.

type HealthChecker added in v0.37.0

type HealthChecker interface {
	IsRunning() bool
}

HealthChecker is an interface for components that can report their health status

Jump to

Keyboard shortcuts

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