Skip to content
EducentrPublic

About

Go implementation of the iproto binary protocol client and server

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

go-iproto

Go Reference CI License: MIT

Go implementation of the iproto binary protocol — a lightweight, high-performance client/server framework for binary RPC communication.

Documentation: English | Русский

Features

  • Channel — single connection with request-response correlation, ping/keepalive, graceful shutdown
  • Pool — connection pool with load balancing, automatic reconnect, and rate limiting
  • Server / ServeMux — accept incoming connections with handler routing by message code
  • Pack / Unpack — binary serialization for integers, strings, structs with BER encoding support
  • netutil — Dialer with retry/backoff and background dial
  • syncutil — concurrency primitives: TaskGroup, TaskRunner, Throttle, Multitask

Installation

go get github.com/Educentr/go-iproto

Requires Go 1.24+.

Quick Start

Server:

package main

import (
    "context"
    "log"

    "github.com/Educentr/go-iproto/iproto"
)

func main() {
    handler := iproto.HandlerFunc(func(ctx context.Context, c iproto.Conn, p iproto.Packet) {
        // Echo: respond with the same data.
        _ = c.Send(ctx, iproto.ResponseTo(p, p.Data))
    })

    log.Fatal(iproto.ListenAndServe(context.Background(), "tcp", ":3301", handler))
}

Client:

package main

import (
    "context"
    "fmt"
    "log"

    "github.com/Educentr/go-iproto/iproto"
)

func main() {
    pool, err := iproto.Dial(context.Background(), "tcp", "127.0.0.1:3301", nil)
    if err != nil {
        log.Fatal(err)
    }
    defer pool.Close()

    resp, err := pool.Call(context.Background(), 1, []byte("hello"))
    if err != nil {
        log.Fatal(err)
    }

    fmt.Printf("response: %s\n", resp)
}

Packages

Package Description
iproto Core protocol: Channel, Pool, Server, ServeMux, Pack/Unpack, stream reader/writer
netutil Dialer with retry/backoff and BackgroundDialer
syncutil TaskGroup, TaskRunner, Throttle, Multitask, Every, Each

Examples

See examples/ for runnable programs:

  • echo — basic echo server and client
  • pool — connection pool with concurrent workers
  • packing — binary serialization with Pack/Unpack
  • mux — ServeMux request routing

Contributing

See CONTRIBUTING.md for guidelines.

License

MIT — see LICENSE for details.


На русском

Go-реализация бинарного протокола iproto — легковесный высокопроизводительный фреймворк для бинарного RPC.

Документация: English | Русский

Возможности

  • Channel — одно соединение с корреляцией запрос-ответ, ping/keepalive, graceful shutdown
  • Pool — пул соединений с балансировкой, автоматическим переподключением и rate limiting
  • Server / ServeMux — приём входящих соединений с маршрутизацией по коду сообщения
  • Pack / Unpack — бинарная сериализация целых чисел, строк, структур с поддержкой BER
  • netutil — Dialer с retry/backoff и фоновым подключением
  • syncutil — примитивы конкурентности: TaskGroup, TaskRunner, Throttle, Multitask

Установка

go get github.com/Educentr/go-iproto

Требуется Go 1.24+.

About

Go implementation of the iproto binary protocol client and server

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages