Documentation
¶
Overview ¶
Package client provides an IPC client for the Hugr query engine. It communicates via the Hugr IPC multipart/mixed protocol.
Index ¶
- func AsUser(ctx context.Context, userId, userName, role string) context.Context
- type ApplicationOptions
- func WithAllocator(alloc memory.Allocator) ApplicationOptions
- func WithLogLevel(level *slog.Level) ApplicationOptions
- func WithLogger(logger *slog.Logger) ApplicationOptions
- func WithMaxMessageSize(size int) ApplicationOptions
- func WithSecretKey(key string) ApplicationOptions
- func WithStartupTimeout(timeout time.Duration) ApplicationOptions
- type Client
- func (c *Client) CloseSubscriptions()
- func (c *Client) DataSourceStatus(ctx context.Context, name string) (string, error)
- func (c *Client) DescribeDataSource(ctx context.Context, name string, self bool) (string, error)
- func (c *Client) LoadDataSource(ctx context.Context, name string) error
- func (c *Client) NewSubscriptionConn(ctx context.Context) (*SubscriptionConn, error)
- func (c *Client) Ping(ctx context.Context) (string, error)
- func (c *Client) Query(ctx context.Context, query string, vars map[string]any) (*types.Response, error)
- func (c *Client) QueryJSON(ctx context.Context, req types.JQRequest) (*types.JsonValue, error)
- func (c *Client) RegisterDataSource(ctx context.Context, ds types.DataSource) error
- func (c *Client) RunApplication(ctx context.Context, application app.Application, opts ...ApplicationOptions) error
- func (c *Client) Subscribe(ctx context.Context, query string, vars map[string]any) (*types.Subscription, error)
- func (c *Client) UnloadDataSource(ctx context.Context, name string, opts ...types.UnloadOpt) error
- func (c *Client) ValidateQuery(ctx context.Context, query string, vars map[string]any) error
- func (c *Client) ValidateQueryJSON(ctx context.Context, req types.JQRequest) error
- func (c *Client) VerifyAdmin(ctx context.Context) error
- type ClientConfig
- type Option
- func WithApiKey(apiKey string) Option
- func WithApiKeyCustomHeader(apiKey, header string) Option
- func WithArrowStructFlatten() Option
- func WithHttpUrl(httpUrl string) Option
- func WithJQQueryUrl(jq string) Option
- func WithSecretKeyAuth(key string) Option
- func WithSubscriptionPool(max, idle int) Option
- func WithTimeout(timeout time.Duration) Option
- func WithTimezone(timezone string) Option
- func WithToken(token string) Option
- func WithTransport(transport http.RoundTripper) Option
- func WithUserInfo(id, name string) Option
- func WithUserInfoCustomHeader(id, name, idHeader, nameHeader string) Option
- func WithUserRole(role string) Option
- func WithUserRoleCustomHeader(role, header string) Option
- func WithoutTimezone() Option
- type SubscriptionConn
- type SubscriptionPoolConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 (*Client) CloseSubscriptions ¶ added in v0.3.20
func (c *Client) CloseSubscriptions()
CloseSubscriptions closes all pool connections.
func (*Client) DataSourceStatus ¶
func (*Client) DescribeDataSource ¶
DescribeDataSource returns the description of the data source.
func (*Client) LoadDataSource ¶
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) RegisterDataSource ¶
func (*Client) RunApplication ¶ added in v0.3.11
func (c *Client) RunApplication(ctx context.Context, application app.Application, opts ...ApplicationOptions) error
func (*Client) UnloadDataSource ¶
func (*Client) ValidateQuery ¶
func (*Client) ValidateQueryJSON ¶
func (*Client) VerifyAdmin ¶ added in v0.3.21
VerifyAdmin queries the server to verify the client has admin privileges. This is a client-side convenience check; the server enforces impersonation authorization via the can_impersonate role property in the permissions system.
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 WithApiKeyCustomHeader ¶
func WithArrowStructFlatten ¶ added in v0.3.6
func WithArrowStructFlatten() Option
func WithHttpUrl ¶
func WithJQQueryUrl ¶
func WithSecretKeyAuth ¶ added in v0.3.21
WithSecretKeyAuth sets the x-hugr-secret-key header for admin authentication. This enables impersonation via types.AsUser context.
func WithSubscriptionPool ¶ added in v0.3.20
WithSubscriptionPool sets the subscription connection pool size.
func WithTimeout ¶
func WithTimezone ¶ added in v0.3.11
func WithTransport ¶
func WithTransport(transport http.RoundTripper) Option
func WithUserInfo ¶
func WithUserRole ¶
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 gracefully shuts down the WebSocket connection. conn.Close sends the close frame; readLoop's conn.Read sees it and returns, triggering deferred cancel() + closeAllSubs().
func (*SubscriptionConn) Count ¶ added in v0.3.20
func (sc *SubscriptionConn) Count() int
Count returns the number of active subscriptions.
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.