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
- func Run(config *Config) error
- type Config
- type Option
- type Oracle
- func (orc *Oracle) Close() error
- func (orc *Oracle) CreateAccount(ctx context.Context, in *pb.CreateAccountRequest) (*pb.CreateAccountResponse, error)
- func (orc *Oracle) DeleteAccount(ctx context.Context, in *pb.DeleteAccountRequest) (*pb.DeleteAccountResponse, error)
- func (orc *Oracle) GetAccount(ctx context.Context, in *pb.GetAccountRequest) (*pb.GetAccountResponse, error)
- func (orc *Oracle) GetUserAccounts(ctx context.Context, in *pb.GetUserAccountsRequest) (*pb.GetUserAccountsResponse, error)
- func (orc *Oracle) HealthCheck(ctx context.Context, req *pb.HealthCheckRequest) (*pb.HealthCheckResponse, error)
- func (orc *Oracle) Transfer(ctx context.Context, in *pb.TransferRequest) (*pb.TransferResponse, error)
- func (orc *Oracle) UpdateAccount(ctx context.Context, in *pb.UpdateAccountRequest) (*pb.UpdateAccountResponse, error)
Constants ¶
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 ¶
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.
type Option ¶
Option provides additional configuration to the oracle. Primarily for testing.
func WithLogBase ¶
WithLogBase allows setting a custom base logger.
func WithMockPhylum ¶
WithMockPhylum runs the phylum in memory.
func WithMockPhylumFrom ¶
WithMockPhylumFrom runs the phylum in memory from a snapshot.
func WithPhylum ¶
WithPhylum connects to shiroclient gateway.
type Oracle ¶
type Oracle struct { srv.UnimplementedLedgerServiceServer // contains filtered or unexported fields }
Oracle provides services.
func (*Oracle) Close ¶
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.