direct

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package direct implements a backend wrapper which allows to connect clients to a backend directly bypassing grpc servers. This is intended either for testing, use at own risk!

Example
package main

import (
	"context"

	"github.com/bsm/accord"
	"github.com/bsm/accord/backend/direct"
	"github.com/bsm/accord/backend/postgres"
)

func main() {
	ctx := context.Background()

	// Open a backend connection.
	backend, err := postgres.Open(ctx, "postgres", "postgres://127.0.0.1:5432/accord")
	if err != nil {
		panic(err)
	}
	defer backend.Close()

	// Bypass gRPC servers and connect a client directly to a backend (not recommended).
	client, err := accord.RPCClient(ctx, direct.Connect(backend), nil)
	if err != nil {
		panic(err)
	}
	defer client.Close()

	// ... use client
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(b backend.Backend) rpc.V1Client

Connect allows to connect clients directly to backend, bypassing the servers. This is not recommended!

Types

This section is empty.

Jump to

Keyboard shortcuts

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