client

package module
v0.3.20 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package client provides an IPC client for the Hugr query engine. It communicates via the Hugr IPC multipart/mixed protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplicationOptions added in v0.3.11

type ApplicationOptions func(*serveConfig)

func WithAllocator added in v0.3.11

func WithAllocator(alloc memory.Allocator) ApplicationOptions

func WithLogLevel added in v0.3.11

func WithLogLevel(level *slog.Level) ApplicationOptions

func WithLogger added in v0.3.11

func WithLogger(logger *slog.Logger) ApplicationOptions

func WithMaxMessageSize added in v0.3.11

func WithMaxMessageSize(size int) ApplicationOptions

func WithSecretKey added in v0.3.11

func WithSecretKey(key string) ApplicationOptions

func WithStartupTimeout added in v0.3.11

func WithStartupTimeout(timeout time.Duration) ApplicationOptions

type Client

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

func NewClient

func NewClient(url string, opts ...Option) *Client

func (*Client) CloseSubscriptions added in v0.3.20

func (c *Client) CloseSubscriptions()

CloseSubscriptions closes all pool connections.

func (*Client) DataSourceStatus

func (c *Client) DataSourceStatus(ctx context.Context, name string) (string, error)

func (*Client) DescribeDataSource

func (c *Client) DescribeDataSource(ctx context.Context, name string, self bool) (string, error)

DescribeDataSource returns the description of the data source.

func (*Client) LoadDataSource

func (c *Client) LoadDataSource(ctx context.Context, name string) error

func (*Client) NewSubscriptionConn added in v0.3.20

func (c *Client) NewSubscriptionConn(ctx context.Context) (*SubscriptionConn, error)

NewSubscriptionConn creates a dedicated WebSocket connection.

func (*Client) Ping

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

func (*Client) Query

func (c *Client) Query(ctx context.Context, query string, vars map[string]any) (*types.Response, error)

func (*Client) QueryJSON

func (c *Client) QueryJSON(ctx context.Context, req types.JQRequest) (*types.JsonValue, error)

func (*Client) RegisterDataSource

func (c *Client) RegisterDataSource(ctx context.Context, ds types.DataSource) error

func (*Client) RunApplication added in v0.3.11

func (c *Client) RunApplication(ctx context.Context, application app.Application, opts ...ApplicationOptions) error

func (*Client) Subscribe added in v0.3.20

func (c *Client) Subscribe(ctx context.Context, query string, vars map[string]any) (*types.Subscription, error)

func (*Client) UnloadDataSource

func (c *Client) UnloadDataSource(ctx context.Context, name string, opts ...types.UnloadOpt) error

func (*Client) ValidateQuery

func (c *Client) ValidateQuery(ctx context.Context, query string, vars map[string]any) error

func (*Client) ValidateQueryJSON

func (c *Client) ValidateQueryJSON(ctx context.Context, req types.JQRequest) error

type ClientConfig

type ClientConfig struct {
	Timeout            time.Duration
	HttpUrl            string
	JQQueryUrl         string
	Transport          http.RoundTripper
	ArrowStructFlatten bool
	SubPool            SubscriptionPoolConfig
}

type Option

type Option func(*ClientConfig)

func WithApiKey

func WithApiKey(apiKey string) Option

func WithApiKeyCustomHeader

func WithApiKeyCustomHeader(apiKey, header string) Option

func WithArrowStructFlatten added in v0.3.6

func WithArrowStructFlatten() Option

func WithHttpUrl

func WithHttpUrl(httpUrl string) Option

func WithJQQueryUrl

func WithJQQueryUrl(jq string) Option

func WithSubscriptionPool added in v0.3.20

func WithSubscriptionPool(max, idle int) Option

WithSubscriptionPool sets the subscription connection pool size.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

func WithTimezone added in v0.3.11

func WithTimezone(timezone string) Option

func WithToken

func WithToken(token string) Option

func WithTransport

func WithTransport(transport http.RoundTripper) Option

func WithUserInfo

func WithUserInfo(id, name string) Option

func WithUserInfoCustomHeader

func WithUserInfoCustomHeader(id, name, idHeader, nameHeader string) Option

func WithUserRole

func WithUserRole(role string) Option

func WithUserRoleCustomHeader

func WithUserRoleCustomHeader(role, header string) Option

func WithoutTimezone added in v0.3.11

func WithoutTimezone() Option

type SubscriptionConn added in v0.3.20

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

SubscriptionConn is a single WebSocket connection multiplexing subscriptions.

func (*SubscriptionConn) Close added in v0.3.20

func (sc *SubscriptionConn) Close()

Close closes the connection and all subscriptions.

func (*SubscriptionConn) Count added in v0.3.20

func (sc *SubscriptionConn) Count() int

Count returns the number of active subscriptions.

func (*SubscriptionConn) Subscribe added in v0.3.20

func (sc *SubscriptionConn) Subscribe(ctx context.Context, query string, vars map[string]any) (*types.Subscription, error)

Subscribe creates a subscription on this connection.

type SubscriptionPoolConfig added in v0.3.20

type SubscriptionPoolConfig struct {
	MaxConns int // max connections in pool (default 1)
	IdleConn int // idle connections to keep open (default 1)
}

SubscriptionPoolConfig controls how the client manages WebSocket connections for subscriptions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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