Help us shape the future of Go! Take the 2026 Go Developer Survey

grpcproxy

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package grpcproxy carries the data spine over gRPC: a Server that serves any data.Proxy, and a Client (itself a data.Proxy) that reaches it. The transport is grpc-transports/websocket, so the exact same query pipeline runs whether a Store talks to a MemoryProxy in-process or to this Client from a browser/wasm build — and the Views come back byte-identical.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterServer

func RegisterServer(gs *grpc.Server, proxy data.Proxy)

RegisterServer registers a DataService backed by proxy onto an existing grpc.Server — use it when mounting the service alongside others.

func Serve

func Serve(addr string, proxy data.Proxy) (url string, stop func(), err error)

Serve starts a DataService for proxy over a WebSocket-carried gRPC listener bound to addr (use ":0" for an ephemeral port). It returns the ws:// URL a Client dials and a stop function that shuts the server down. The WebSocket carrier is what lets a browser/wasm Client speak this same gRPC service.

Types

type Client

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

Client is a data.Proxy backed by a remote DataService reached over a WebSocket-carried gRPC connection. It satisfies the same interface a MemoryProxy does, so a Store cannot tell whether its data is local or remote — and because the WebSocket transport compiles to js/wasm, this exact Client runs in a browser talking to the native Server.

func Dial

func Dial(url string) (*Client, error)

Dial connects to a DataService at the given ws:// (or wss://) URL. Close the returned Client when done.

func (*Client) Close

func (c *Client) Close() error

Close releases the underlying connection.

func (*Client) List

func (c *Client) List(ctx context.Context) ([]data.Record, error)

List returns every record from the remote service.

func (*Client) Mutate

func (c *Client) Mutate(ctx context.Context, m data.Mutation) error

Mutate applies one write remotely.

func (*Client) Query

func (c *Client) Query(ctx context.Context, q data.Query) (data.View, error)

Query runs the query remotely and returns the View the server computed — the same View a MemoryProxy would have produced for the same rows.

type Server

type Server struct {
	datapb.UnimplementedDataServiceServer
	// contains filtered or unexported fields
}

Server adapts any data.Proxy to the DataService gRPC contract: each RPC simply delegates to the wrapped proxy (a MemoryProxy in practice), so the query pipeline that produces a View runs server-side and the client receives exactly that View. It is native-only — a browser is the client, never the server.

func NewServer

func NewServer(proxy data.Proxy) *Server

NewServer wraps proxy as a DataService implementation.

func (*Server) List

List returns every record.

func (*Server) Mutate

Mutate applies one write.

func (*Server) Query

func (s *Server) Query(ctx context.Context, q *datapb.Query) (*datapb.View, error)

Query applies the query on the proxy and returns the resulting View.

Jump to

Keyboard shortcuts

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