rpc

package
v0.0.0-...-0955589 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package rpc is a generated twirp stub package. This code was generated with github.com/twitchtv/twirp/protoc-gen-twirp v8.0.0.

It is generated from these files:

api/billing.proto

Index

Constants

View Source
const BillingPathPrefix = "/twirp/com.cirrusmd.billing.Billing/"

BillingPathPrefix is a convenience constant that could used to identify URL paths. Should be used with caution, it only matches routes generated by Twirp Go clients, that add a "/twirp" prefix by default, and use CamelCase service and method names. More info: https://twitchtv.github.io/twirp/docs/routing.html

Variables

View Source
var File_api_billing_proto protoreflect.FileDescriptor

Functions

func WriteError

func WriteError(resp http.ResponseWriter, err error)

WriteError writes an HTTP response with a valid Twirp error format (code, msg, meta). Useful outside of the Twirp server (e.g. http middleware), but does not trigger hooks. If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err)

Types

type Billing

type Billing interface {
	AddIOMetrics(context.Context, *IOMetricsReq) (*CustomerBilledResp, error)
}

func NewBillingJSONClient

func NewBillingJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Billing

NewBillingJSONClient creates a JSON client that implements the Billing interface. It communicates using JSON and can be configured with a custom HTTPClient.

func NewBillingProtobufClient

func NewBillingProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Billing

NewBillingProtobufClient creates a Protobuf client that implements the Billing interface. It communicates using Protobuf and can be configured with a custom HTTPClient.

type CustomerBilledResp

type CustomerBilledResp struct {
	Name                string  `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // UUID for Customer to charge (bill)
	UnitsBilled         int64   `protobuf:"varint,2,opt,name=unitsBilled,proto3" json:"unitsBilled,omitempty"`
	PerUnitCost         float64 `protobuf:"fixed64,3,opt,name=perUnitCost,proto3" json:"perUnitCost,omitempty"`
	TotalMonthlyCharged float64 `protobuf:"fixed64,4,opt,name=totalMonthlyCharged,proto3" json:"totalMonthlyCharged,omitempty"`
	// contains filtered or unexported fields
}

func (*CustomerBilledResp) Descriptor deprecated

func (*CustomerBilledResp) Descriptor() ([]byte, []int)

Deprecated: Use CustomerBilledResp.ProtoReflect.Descriptor instead.

func (*CustomerBilledResp) GetName

func (x *CustomerBilledResp) GetName() string

func (*CustomerBilledResp) GetPerUnitCost

func (x *CustomerBilledResp) GetPerUnitCost() float64

func (*CustomerBilledResp) GetTotalMonthlyCharged

func (x *CustomerBilledResp) GetTotalMonthlyCharged() float64

func (*CustomerBilledResp) GetUnitsBilled

func (x *CustomerBilledResp) GetUnitsBilled() int64

func (*CustomerBilledResp) ProtoMessage

func (*CustomerBilledResp) ProtoMessage()

func (*CustomerBilledResp) ProtoReflect

func (x *CustomerBilledResp) ProtoReflect() protoreflect.Message

func (*CustomerBilledResp) Reset

func (x *CustomerBilledResp) Reset()

func (*CustomerBilledResp) String

func (x *CustomerBilledResp) String() string

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is the interface used by generated clients to send HTTP requests. It is fulfilled by *(net/http).Client, which is sufficient for most users. Users can provide their own implementation for special retry policies.

HTTPClient implementations should not follow redirects. Redirects are automatically disabled if *(net/http).Client is passed to client constructors. See the withoutRedirects function in this file for more details.

type IOMetricsReq

type IOMetricsReq struct {
	Name       string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`              // UUID for Customer to charge (bill)
	Reads      int64  `protobuf:"varint,4,opt,name=reads,proto3" json:"reads,omitempty"`           // Reads is a counter of number of reads
	Writes     int64  `protobuf:"varint,5,opt,name=writes,proto3" json:"writes,omitempty"`         // Writes is a counter of number of writes
	ReadBytes  int64  `protobuf:"varint,6,opt,name=readBytes,proto3" json:"readBytes,omitempty"`   // readBytes is total number of bytes read
	WriteBytes int64  `protobuf:"varint,7,opt,name=writeBytes,proto3" json:"writeBytes,omitempty"` // writeBytes is total number of bytes written
	// contains filtered or unexported fields
}

func (*IOMetricsReq) Descriptor deprecated

func (*IOMetricsReq) Descriptor() ([]byte, []int)

Deprecated: Use IOMetricsReq.ProtoReflect.Descriptor instead.

func (*IOMetricsReq) GetName

func (x *IOMetricsReq) GetName() string

func (*IOMetricsReq) GetReadBytes

func (x *IOMetricsReq) GetReadBytes() int64

func (*IOMetricsReq) GetReads

func (x *IOMetricsReq) GetReads() int64

func (*IOMetricsReq) GetWriteBytes

func (x *IOMetricsReq) GetWriteBytes() int64

func (*IOMetricsReq) GetWrites

func (x *IOMetricsReq) GetWrites() int64

func (*IOMetricsReq) ProtoMessage

func (*IOMetricsReq) ProtoMessage()

func (*IOMetricsReq) ProtoReflect

func (x *IOMetricsReq) ProtoReflect() protoreflect.Message

func (*IOMetricsReq) Reset

func (x *IOMetricsReq) Reset()

func (*IOMetricsReq) String

func (x *IOMetricsReq) String() string

type TwirpServer

type TwirpServer interface {
	http.Handler

	// ServiceDescriptor returns gzipped bytes describing the .proto file that
	// this service was generated from. Once unzipped, the bytes can be
	// unmarshalled as a
	// google.golang.org/protobuf/types/descriptorpb.FileDescriptorProto.
	//
	// The returned integer is the index of this particular service within that
	// FileDescriptorProto's 'Service' slice of ServiceDescriptorProtos. This is a
	// low-level field, expected to be used for reflection.
	ServiceDescriptor() ([]byte, int)

	// ProtocGenTwirpVersion is the semantic version string of the version of
	// twirp used to generate this file.
	ProtocGenTwirpVersion() string

	// PathPrefix returns the HTTP URL path prefix for all methods handled by this
	// service. This can be used with an HTTP mux to route Twirp requests.
	// The path prefix is in the form: "/<prefix>/<package>.<Service>/"
	// that is, everything in a Twirp route except for the <Method> at the end.
	PathPrefix() string
}

TwirpServer is the interface generated server structs will support: they're HTTP handlers with additional methods for accessing metadata about the service. Those accessors are a low-level API for building reflection tools. Most people can think of TwirpServers as just http.Handlers.

func NewBillingServer

func NewBillingServer(svc Billing, opts ...interface{}) TwirpServer

NewBillingServer builds a TwirpServer that can be used as an http.Handler to handle HTTP requests that are routed to the right method in the provided svc implementation. The opts are twirp.ServerOption modifiers, for example twirp.WithServerHooks(hooks).

Jump to

Keyboard shortcuts

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