oracle

package
v0.0.0-...-403735f Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: BSD-3-Clause Imports: 35 Imported by: 0

Documentation

Overview

Package oracle defines a simple system for http middleware built around functions with the following signature:

func Wrap(h http.Handler) http.Handler

The middleware are chained together using the middlewareChain type which can wrap the grpc-gateway to augment how it serves the API.

Index

Constants

View Source
const (
	// TimestampFormat uses RFC3339 for all timestamps.
	TimestampFormat = time.RFC3339

	// DefaultRegion is the AWS default region.
	DefaultRegion = "eu-west-2"

	// HeaderReqID is the HTTP header used to (uniquely) identify requests and
	// associate log entries with individual requests for diagnosing errors.
	HeaderReqID = "X-Request-ID"
)

Variables

This section is empty.

Functions

func Run

func Run(config *Config) error

Run starts the oracle.

Types

type Config

type Config struct {
	// Verbose increases logging.
	Verbose bool `yaml:"verbose"`
	// EmulateCC emulates chaincode in memory (for testing).
	EmulateCC bool `yaml:"emulate-cc"`
	// ListenAddress is an address the oracle HTTP listens on.
	ListenAddress string `yaml:"listen-address"`
	// PhylumVersion is the version of the phylum.
	PhylumVersion string `yaml:"phylum-version"`
	// PhylumPath is the the path for the business logic.
	PhylumPath string `yaml:"phylum-path"`
	// GatewayEndpoint is an address to the shiroclient gateway.
	GatewayEndpoint string `yaml:"gateway-endpoint"`
	// OTLPEndpoint optionally configures OTLP tracing and sends traces to
	// the supplied OTLP endpoint
	OTLPEndpoint string `yaml:"otlp-endpoint"`
}

Config configures an oracle.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a default config.

func (*Config) Valid

func (c *Config) Valid() error

Valid validates an oracle configuration.

type Option

type Option func(*Oracle) error

Option provides additional configuration to the oracle. Primarily for testing.

func WithLogBase

func WithLogBase(logBase *logrus.Entry) Option

WithLogBase allows setting a custom base logger.

func WithMockPhylum

func WithMockPhylum(path string) Option

WithMockPhylum runs the phylum in memory.

func WithMockPhylumFrom

func WithMockPhylumFrom(path string, r io.Reader) Option

WithMockPhylumFrom runs the phylum in memory from a snapshot.

func WithPhylum

func WithPhylum(gatewayEndpoint string) Option

WithPhylum connects to shiroclient gateway.

type Oracle

type Oracle struct {
	srv.UnimplementedLedgerServiceServer
	// contains filtered or unexported fields
}

Oracle provides services.

func New

func New(config *Config, opts ...Option) (*Oracle, error)

New constructs a new oracle.

func (*Oracle) Close

func (orc *Oracle) Close() error

Close blocks the caller until all spawned go routines complete, then closes the phylum

func (*Oracle) CreateAccount

func (orc *Oracle) CreateAccount(ctx context.Context, in *pb.CreateAccountRequest) (*pb.CreateAccountResponse, error)

CreateAccount is an example resource creation endpoint.

func (*Oracle) DeleteAccount

func (orc *Oracle) DeleteAccount(ctx context.Context, in *pb.DeleteAccountRequest) (*pb.DeleteAccountResponse, error)

func (*Oracle) GetAccount

func (orc *Oracle) GetAccount(ctx context.Context, in *pb.GetAccountRequest) (*pb.GetAccountResponse, error)

GetAccount is an example query endpoint.

func (*Oracle) GetUserAccounts

func (orc *Oracle) GetUserAccounts(ctx context.Context, in *pb.GetUserAccountsRequest) (*pb.GetUserAccountsResponse, error)

func (*Oracle) HealthCheck

func (orc *Oracle) HealthCheck(ctx context.Context, req *pb.HealthCheckRequest) (*pb.HealthCheckResponse, error)

HealthCheck checks this service and all dependent services to construct a health report. Returns a grpc error code if a service is down.

func (*Oracle) Transfer

func (orc *Oracle) Transfer(ctx context.Context, in *pb.TransferRequest) (*pb.TransferResponse, error)

Transfer is an example write operation.

func (*Oracle) UpdateAccount

func (orc *Oracle) UpdateAccount(ctx context.Context, in *pb.UpdateAccountRequest) (*pb.UpdateAccountResponse, error)

UpdateAccount is an example resource update endpoint.

Jump to

Keyboard shortcuts

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