Skip to content

High-performance client-server library for Go, built around the Command pattern

License

Notifications You must be signed in to change notification settings

cmd-stream/cmd-stream-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cmd-stream-go

Go Reference GoReportCard Follow on X

cmd-stream-go is a high-performance, modular client–server library for Go, based on the Command Pattern. It's designed for efficient, low-latency communication over TCP/TLS, with support for streaming and observability.

Want to learn how the Command Pattern applies to network communication? Check out this series of posts.

Contents

Why cmd-stream-go?

It delivers high-performance and resource efficiency, helping reduce infrastructure costs and scale more effectively.

Overview

  • Works over TCP, TLS or mutual TLS.
  • Has an asynchronous client that uses only one connection for both sending Commands and receiving Results.
  • Supports the server streaming, i.e. a Command can send back multiple Results.
  • Provides reconnect and keepalive features.
  • Supports the Circuit Breaker pattern.
  • Has OpenTelemetry integration.
  • Can work with various serialization formats.
  • Follows a modular design.

Tests

The main cmd-stream-go module contains basic integration tests, while each submodule (see Architecture) has approximately 90% code coverage.

Benchmarks

See go-client-server-benchmarks for performance comparisons.

How To

Getting started is easy:

  1. Implement the Command Pattern.
  2. Generate the serialization code.

For more details, explore the following resources:

Network Protocols Support

Built on Go’s standard net package, cmd-stream-go supports connection-oriented protocols, such as TCP, TLS, and mutual TLS (for client authentication).

Client & Server

The client operates asynchronously, sending Commands to the server. On the server side, the Invoker executes the Commands, while the Receiver provides the underlying server functionality.

High-performance Communication Channel

To maximize performance between services:

  1. Use N parallel connections. More connections typically improve throughput, until a saturation point.
  2. Pre-establish all connections instead of opening them on-demand.
  3. Keep connections alive to avoid the overhead from reconnections.

These practices, implemented via the ClientGroup, can significantly enhance throughput and reduce latency between your services.

cmd-stream-go and RPC

Already using RPC? You can use cmd-stream-go as a faster transport layer. See the RPC example.

Architecture

cmd-stream-go is split into the following submodules:

  • core-go: The core module that includes client and server definitions.
  • delegate-go: The client delegates all communication-related tasks to its delegate, the server follows the same approach. The connection is also initialized at this level.
  • handler-go: The server delegate uses a handler to receive and process Commands.
  • transport-go: Responsible for Commands/Results delivery.

cmd-stream-go was designed in such a way that you can easily replace any part of it.

About

High-performance client-server library for Go, built around the Command pattern

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages