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

waterway

command module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

README ΒΆ

🚰 Waterway

A high-performance JSON-RPC 2.0 proxy for Sei blockchain nodes with WebSocket pooling, automatic HTTP fallback, and response caching.

Features

  • Dual transport support β€” Routes requests via WebSocket or HTTP based on method compatibility
  • WebSocket connection pooling β€” Maintains a pool of persistent connections for low-latency requests
  • Automatic fallback β€” Falls back to HTTP when WebSocket calls fail or return incompatible errors
  • Response caching β€” Memcached integration for cacheable RPC methods
  • Batch requests β€” Handles JSON-RPC batch requests with configurable concurrency limits
  • Method filtering β€” Allowlist/blocklist support for controlling exposed RPC methods
  • Metrics & health checks β€” Prometheus metrics endpoint and health status reporting
  • TLS support β€” Optional HTTPS/WSS termination

Quick Start

waterway, err := NewWaterway(ctx,
    WithListenAddr(":8545"),
    WithSeiWSEndpoint("ws://localhost:26657/websocket"),
    WithSeiHTTPEndpoint("http://localhost:26657"),
)
if err != nil {
    log.Fatal(err)
}
waterway.Start(ctx)

Endpoints

Path Description
/ JSON-RPC endpoint (HTTP POST or WebSocket upgrade)
/health Health check with pool status
/metrics Prometheus metrics

Configuration Options

Configure via Option functions passed to NewWaterway():

  • WithListenAddr β€” Server bind address
  • WithSeiWSEndpoint β€” Upstream WebSocket URL
  • WithSeiHTTPEndpoint β€” Upstream HTTP URL
  • WithAllowedMethods / WithBlockedMethods β€” Method filtering
  • WithHTTPOnlyMethods β€” Force specific methods to use HTTP
  • WithCacheableMethods β€” Enable caching for specific methods
  • WithMemcachedServers β€” Memcached server addresses
  • WithMaxWSConnections β€” WebSocket pool size
  • WithTLS β€” TLS certificate and key paths

How It Works

  1. Incoming requests are validated against JSON-RPC 2.0 spec and method filters
  2. Cacheable methods check Memcached first
  3. Subscription methods (eth_subscribe/eth_unsubscribe) always use WebSocket
  4. Other methods try WebSocket first, falling back to HTTP on failure
  5. Methods that consistently fail over WebSocket are automatically routed to HTTP

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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