Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) AttachSession(ctx context.Context, req *bridgev1.AttachSessionRequest) (*OutputStream, error)
- func (c *Client) ClaimWriter(ctx context.Context, req *bridgev1.ClaimWriterRequest) (*bridgev1.ClaimWriterResponse, error)
- func (c *Client) Close() error
- func (c *Client) DiagnoseSession(ctx context.Context, req *bridgev1.DiagnoseSessionRequest) (*bridgev1.DiagnoseSessionResponse, error)
- func (c *Client) GetSession(ctx context.Context, req *bridgev1.GetSessionRequest) (*bridgev1.GetSessionResponse, error)
- func (c *Client) Health(ctx context.Context) (*bridgev1.HealthResponse, error)
- func (c *Client) ListProviders(ctx context.Context) (*bridgev1.ListProvidersResponse, error)
- func (c *Client) ListSessions(ctx context.Context, req *bridgev1.ListSessionsRequest) (*bridgev1.ListSessionsResponse, error)
- func (c *Client) RegisterJWTKey(ctx context.Context, req *bridgev1.RegisterJWTKeyRequest) (*bridgev1.RegisterJWTKeyResponse, error)
- func (c *Client) ReleaseWriter(ctx context.Context, req *bridgev1.ReleaseWriterRequest) (*bridgev1.ReleaseWriterResponse, error)
- func (c *Client) ResizeSession(ctx context.Context, req *bridgev1.ResizeSessionRequest) (*bridgev1.ResizeSessionResponse, error)
- func (c *Client) SetProject(projectID string)
- func (c *Client) StartSession(ctx context.Context, req *bridgev1.StartSessionRequest) (*bridgev1.StartSessionResponse, error)
- func (c *Client) StopSession(ctx context.Context, req *bridgev1.StopSessionRequest) (*bridgev1.StopSessionResponse, error)
- func (c *Client) WriteInput(ctx context.Context, req *bridgev1.WriteInputRequest) (*bridgev1.WriteInputResponse, error)
- type CursorStore
- type FileCursorStore
- type JWTConfig
- type MTLSConfig
- type MemoryCursorStore
- type Option
- type OutputStream
- type RetryConfig
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrSessionNotFound = errors.New("session not found") ErrSessionAlreadyExists = errors.New("session already exists") 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 ¶
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()),
)
}
Output:
func (*Client) AttachSession ¶
func (c *Client) AttachSession(ctx context.Context, req *bridgev1.AttachSessionRequest) (*OutputStream, error)
func (*Client) ClaimWriter ¶
func (c *Client) ClaimWriter(ctx context.Context, req *bridgev1.ClaimWriterRequest) (*bridgev1.ClaimWriterResponse, error)
func (*Client) DiagnoseSession ¶ added in v1.4.4
func (c *Client) DiagnoseSession(ctx context.Context, req *bridgev1.DiagnoseSessionRequest) (*bridgev1.DiagnoseSessionResponse, error)
DiagnoseSession returns the daemon-built, schema-versioned diagnostic snapshot of a session as a single JSON document.
func (*Client) GetSession ¶
func (c *Client) GetSession(ctx context.Context, req *bridgev1.GetSessionRequest) (*bridgev1.GetSessionResponse, error)
func (*Client) ListProviders ¶
func (*Client) ListSessions ¶
func (c *Client) ListSessions(ctx context.Context, req *bridgev1.ListSessionsRequest) (*bridgev1.ListSessionsResponse, error)
func (*Client) RegisterJWTKey ¶
func (c *Client) RegisterJWTKey(ctx context.Context, req *bridgev1.RegisterJWTKeyRequest) (*bridgev1.RegisterJWTKeyResponse, error)
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 (c *Client) ReleaseWriter(ctx context.Context, req *bridgev1.ReleaseWriterRequest) (*bridgev1.ReleaseWriterResponse, error)
func (*Client) ResizeSession ¶
func (c *Client) ResizeSession(ctx context.Context, req *bridgev1.ResizeSessionRequest) (*bridgev1.ResizeSessionResponse, error)
func (*Client) SetProject ¶
SetProject configures the project_id for auto-minted JWTs.
func (*Client) StartSession ¶
func (c *Client) StartSession(ctx context.Context, req *bridgev1.StartSessionRequest) (*bridgev1.StartSessionResponse, error)
func (*Client) StopSession ¶
func (c *Client) StopSession(ctx context.Context, req *bridgev1.StopSessionRequest) (*bridgev1.StopSessionResponse, error)
func (*Client) WriteInput ¶
func (c *Client) WriteInput(ctx context.Context, req *bridgev1.WriteInputRequest) (*bridgev1.WriteInputResponse, error)
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 (*FileCursorStore) SaveCursor ¶
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 (*MemoryCursorStore) SaveCursor ¶
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 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 ¶
WithTarget sets the bridge daemon address (host:port).
func WithTimeout ¶
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