bridgeclient

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT 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

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrSessionNotFound      = errors.New("session not found")
	ErrSessionAlreadyExists = errors.New("session already exists")
	ErrProviderUnavailable  = errors.New("provider unavailable")
	ErrUnauthorized         = errors.New("unauthorized")
	ErrPermissionDenied     = errors.New("permission denied")
	ErrInputTooLarge        = errors.New("input too large")
	ErrSessionLimitReached  = errors.New("session limit reached")
	ErrRateLimited          = errors.New("rate limited")
)

Functions

This section is empty.

Types

type Client

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

Client is a typed wrapper around the BridgeService gRPC client.

func New

func New(opts ...Option) (*Client, error)

New creates a new bridge client with the given options.

Example
package main

import (
	"time"

	"github.com/orchael/bridgectl/pkg/bridgeclient"
)

func main() {
	_, _ = bridgeclient.New(
		bridgeclient.WithTarget("127.0.0.1:9445"),
		bridgeclient.WithTimeout(10*time.Second),
		bridgeclient.WithRetry(bridgeclient.RetryConfig{
			MaxAttempts:    3,
			InitialBackoff: 100 * time.Millisecond,
			MaxBackoff:     2 * time.Second,
		}),
		bridgeclient.WithCursorStore(bridgeclient.NewMemoryCursorStore()),
	)
}

func (*Client) AttachSession

func (c *Client) AttachSession(ctx context.Context, req *bridgev1.AttachSessionRequest) (*OutputStream, error)

func (*Client) ClaimWriter

func (*Client) Close

func (c *Client) Close() error

Close releases the gRPC connection.

func (*Client) DiagnoseSession added in v1.4.4

DiagnoseSession returns the daemon-built, schema-versioned diagnostic snapshot of a session as a single JSON document.

func (*Client) GetSession

func (*Client) Health

func (c *Client) Health(ctx context.Context) (*bridgev1.HealthResponse, error)

func (*Client) ListProviders

func (c *Client) ListProviders(ctx context.Context) (*bridgev1.ListProvidersResponse, error)

func (*Client) ListSessions

func (*Client) RegisterJWTKey

RegisterJWTKey enrolls a client's Ed25519 public key for JWT authentication. Requires mTLS; JWT auth is not needed for this call.

func (*Client) ReleaseWriter

func (*Client) ResizeSession

func (*Client) SetProject

func (c *Client) SetProject(projectID string)

SetProject configures the project_id for auto-minted JWTs.

func (*Client) StartSession

func (*Client) StopSession

func (*Client) WriteInput

type CursorStore

type CursorStore interface {
	LoadCursor(ctx context.Context, sessionID, subscriberID string) (uint64, error)
	SaveCursor(ctx context.Context, sessionID, subscriberID string, seq uint64) error
}

CursorStore persists last acknowledged sequence numbers by session/subscriber.

type FileCursorStore

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

FileCursorStore stores cursors in a JSON file for cross-process resume.

func NewFileCursorStore

func NewFileCursorStore(path string) *FileCursorStore

NewFileCursorStore creates a file-backed cursor store.

func (*FileCursorStore) LoadCursor

func (s *FileCursorStore) LoadCursor(ctx context.Context, sessionID, subscriberID string) (uint64, error)

func (*FileCursorStore) SaveCursor

func (s *FileCursorStore) SaveCursor(ctx context.Context, sessionID, subscriberID string, seq uint64) error

type JWTConfig

type JWTConfig struct {
	PrivateKeyPath string // Ed25519 private key for signing
	Issuer         string // JWT issuer claim
	Audience       string // JWT audience claim
	TTL            time.Duration
}

JWTConfig holds configuration for automatic JWT minting.

type MTLSConfig

type MTLSConfig struct {
	CABundlePath string // Trust bundle (own CA + cross-signed CAs)
	CertPath     string // Client certificate
	KeyPath      string // Client private key
	ServerName   string // Expected server name for verification
}

MTLSConfig holds paths for mTLS client credentials.

type MemoryCursorStore

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

MemoryCursorStore stores cursors in-memory.

func NewMemoryCursorStore

func NewMemoryCursorStore() *MemoryCursorStore

NewMemoryCursorStore creates an in-memory cursor store.

func (*MemoryCursorStore) LoadCursor

func (s *MemoryCursorStore) LoadCursor(ctx context.Context, sessionID, subscriberID string) (uint64, error)

func (*MemoryCursorStore) SaveCursor

func (s *MemoryCursorStore) SaveCursor(ctx context.Context, sessionID, subscriberID string, seq uint64) error

type Option

type Option func(*clientConfig)

Option configures a Client.

func WithCursorStore

func WithCursorStore(store CursorStore) Option

WithCursorStore sets persistent storage for stream cursor checkpoints.

func WithJWT

func WithJWT(cfg JWTConfig) Option

WithJWT configures automatic JWT minting for each RPC call.

func WithMTLS

func WithMTLS(cfg MTLSConfig) Option

WithMTLS configures mTLS credentials for the connection.

func WithRetry

func WithRetry(cfg RetryConfig) Option

WithRetry sets retry behavior for unary operations.

func WithTarget

func WithTarget(addr string) Option

WithTarget sets the bridge daemon address (host:port).

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout sets the default per-call timeout.

type OutputStream

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

OutputStream wraps the PTY output stream for one attached client.

func (*OutputStream) ClientID

func (s *OutputStream) ClientID() string

func (*OutputStream) RecvAll

func (s *OutputStream) RecvAll(ctx context.Context, callback func(*bridgev1.AttachSessionEvent) error) error

type RetryConfig

type RetryConfig struct {
	MaxAttempts    int
	InitialBackoff time.Duration
	MaxBackoff     time.Duration
}

RetryConfig controls retry behavior for unary RPC methods.

Jump to

Keyboard shortcuts

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