orb

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

README ¶

go-orb Logo License Go.Dev reference Go Report Card Discord Matrix

Go Orb is a framework for distributed systems development, it can be seen as the successor of go-micro.dev/v4.

The core of go-orb has been completely refactored, to support the removal of reflect and introduction of wire.

In active Development

While its possible to try out go-orb currently, it is in active development and not ready for production use. Please have a look at our roadmap for more details.

Overview

Go Orb provides the core requirements for distributed systems development including RPC and Event driven communication. The Go Orb philosophy is sane defaults with a pluggable architecture. We provide defaults to get you started quickly but everything can be easily swapped out.

Features

Go Orb abstracts away the details of distributed systems. Here are the main features.

  • Config - Load dynamic config from anywhere. The config interface provides a way to load application level config from any source such as env vars, file and http. You can merge the sources and even define fallbacks.

  • Service Discovery - Automatic service registration and name resolution. Service discovery is at the core of Go Orb service development. When service A needs to speak to service B it needs the location of that service. The default discovery mechanism is multicast DNS (mdns), a zeroconf system.

  • Message Encoding - Dynamic message encoding based on content-type. The client and server will use codecs along with content-type to seamlessly encode and decode Go types for you. Any variety of messages could be encoded and sent from different clients. The client and server handle this by default. This includes protobuf and json by default.

  • RPC Client/Server - RPC based request/response with support for bidirectional streaming. We provide an abstraction for synchronous communication. A request made to a service will be automatically resolved, load balanced, dialled and streamed.

  • RPC over event topics - RPC over event topics, makes RPC even easier.

  • Pluggable Interfaces - Go Orb makes use of Go interfaces for each distributed system abstraction. Because of this these interfaces are pluggable and allows Go Orb to be runtime agnostic. You can plugin any underlying technology.

  • Strongly tested and linted - We use golangci-lint to ensure code quality and we have a comprehensive test suite, all lints and tests are run on CI.

Examples

Please see the examples repo.

🚀 What's new since forking from go-micro v4

Use of wire

With wire we gain:

  • compile-time safety
  • no more globals

It was the main reason for starting orb, wire allows us to decouple the components and plugins.

No more reflect

we have been working hard on removing all usage of reflect.

Multiple Entrypoints

Orb allows you to listen on multiple port's with different protocols: gRPC, HTTP, HTTPS, DRPC, HTTP2, H2C, HTTP3. See the config system entry on howto configure it.

Advanced config system

With orb you can configure your plugins with a config file or environment options.

service1:
  server:
    handlers:
      - UserInfo
    middlewares:
      - middleware-1
    entrypoints:
      - name: grpc
        plugin: grpc
        insecure: true
        reflection: false
  client:
    middlewares:
      - name: log
      - name: retry
  registry:
    enabled: true
    plugin: mdns
    timeout: 350
    domain: svc.orb
service1:
  server:
    handlers:
      - UserInfo
    middlewares:
      - middleware-1
      - middleware-2
    entrypoints:
      - name: hertzhttp
        plugin: hertz
        http2: false
        insecure: true

      - name: grpc
        plugin: grpc
        insecure: true
        reflection: false
        handlers:
          - ImOnlyOnGRPC
        middlewares:
          - ImAGRPCSpecificMiddlware

      - name: http
        plugin: http
        insecure: true

      - name: drpc
        plugin: drpc
  client:
    middlewares:
      - name: log
      - name: retry
  registry:
    plugin: consul
    address: consul:8500

These 2 config's with different options will both work, we first parse the config, get the "plugin" from it and pass a map[any]any with all config data to the plugin.

Both work with a single binary. :)

Proto conform handlers

Return types as a result instead of HTTP req format.

New:

req := HelloRequest{Name: "test"}

// Look at resp, it's now returned as a result.
resp , err := client.Call[HelloResponse](context.Background(), clientDi, "org.orb.svc.hello", "Say.Hello", &req)

Old:

req := c.c.NewRequest(c.serviceName, "Greeter.Hello", in)
out := new(HelloResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
  return nil, err
}
return out, nil
Send json

go-orb has support for sending nearly anything you throw in as application/json to the Server.

pre encoded / proxy
resp , err := client.Call[map[string]any](context.Background(), clientDi, "org.orb.svc.hello", "Say.Hello", `{"name": "Alex"}`, client.WithContentType(codecs.MimeJSON))
map[string]any{}
req := make(map[string]any)
req["name"] = "Alex"

resp , err := client.Call[map[string]any](context.Background(), clientDi, "org.orb.svc.hello", "Say.Hello", req, client.WithContentType(codecs.MimeJSON))
Structured logging

We like structured logging, this is why we replaced all logging with one based on slog.

go-orb/go-orb is just interfaces

We made sure that go-orb/go-orb (the core) is just a bunch of interfaces as well as some glue code, the most real code lives in go-orb/plugins.

Linted and analyzed

Everything is linted and staticaly analyzed by golangci-lint, enforced with CI pipelines on github.

Community

Chat with us on Discord or Matrix.

Development

golangci-lint

We use version v1.64.5 of golangci-lint.

curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.64.5
golangci-lint run --config .golangci.yaml
Quirks
No go-orb/plugins imports here

To prevent import cycles it's not allowed to import go-orb/plugins here.

Lint

We do not accept commits that fail to lint, use ./scripts/test.sh lint all.

Authors

go-orb
go-micro

A lot of this is copy&pasted from go-micro, top contributors have been:

License

go-orb is Apache 2.0 licensed and is based on go-micro.

Documentation ¶

Overview ¶

Package orb provides nothing and is just here for lint errors.

Directories ¶

Path Synopsis
Package cli provides the cli for go-orb.
Package cli provides the cli for go-orb.
Package client provides an interface and helpers for go-orb clients.
Package client provides an interface and helpers for go-orb clients.
Package codecs is provides an interface to encode and decode content types to and from byte sequences.
Package codecs is provides an interface to encode and decode content types to and from byte sequences.
Package config provides config handling for go-micro.
Package config provides config handling for go-micro.
source
Package source provides a base for all config sources.
Package source provides a base for all config sources.
Package event contains an interface as well as helpers for go-orb events.
Package event contains an interface as well as helpers for go-orb events.
Package kvstore is an interface for distributed key-value data storage.
Package kvstore is an interface for distributed key-value data storage.
Package log contains a golang.org/x/exp/slog compatible logger.
Package log contains a golang.org/x/exp/slog compatible logger.
Package metrics provides a Wrapper around hashicorp/go-metrics.
Package metrics provides a Wrapper around hashicorp/go-metrics.
Package registry is a component for service discovery
Package registry is a component for service discovery
Package server provides the go-orb server.
Package server provides the go-orb server.
Package types provides marker's, these are here against dependency cycles.
Package types provides marker's, these are here against dependency cycles.
util
addr
Package addr provides functions to retrieve local IP addresses from device interfaces.
Package addr provides functions to retrieve local IP addresses from device interfaces.
container
Package container contains generic containers.
Package container contains generic containers.
metadata
Package metadata is a way of defining message headers
Package metadata is a way of defining message headers
net
Package net provides net utilities.
Package net provides net utilities.
orberrors
Package orberrors provides an error that must be transported on client<->server operations.
Package orberrors provides an error that must be transported on client<->server operations.
slicemap
Package slicemap provides simple slice & map utility functions.
Package slicemap provides simple slice & map utility functions.
tls
Package tls provides TLS utilities.
Package tls provides TLS utilities.
ultrapool
Package ultrapool implements a blazing fast worker pool with adaptive spawning of new workers and cleanup of idle workers It was modeled after valyala/fasthttp's worker pool which is one of the best worker pools I've seen in the Go world.
Package ultrapool implements a blazing fast worker pool with adaptive spawning of new workers and cleanup of idle workers It was modeled after valyala/fasthttp's worker pool which is one of the best worker pools I've seen in the Go world.

Jump to

Keyboard shortcuts

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