sqliterpc

package module
v0.0.0-...-79ce2c3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const DatabaseServicePathPrefix = "/twirp/sqlite.rpc.v0.DatabaseService/"

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

Variables

View Source
var (
	TypeCode_name = map[int32]string{
		0: "TYPE_CODE_UNSPECIFIED",
		1: "TYPE_CODE_INTEGER",
		2: "TYPE_CODE_TEXT",
		3: "TYPE_CODE_BLOB",
		4: "TYPE_CODE_REAL",
		5: "TYPE_CODE_NUMERIC",
		6: "TYPE_CODE_BOOL",
		7: "TYPE_CODE_TIME",
		8: "TYPE_CODE_NULL",
	}
	TypeCode_value = map[string]int32{
		"TYPE_CODE_UNSPECIFIED": 0,
		"TYPE_CODE_INTEGER":     1,
		"TYPE_CODE_TEXT":        2,
		"TYPE_CODE_BLOB":        3,
		"TYPE_CODE_REAL":        4,
		"TYPE_CODE_NUMERIC":     5,
		"TYPE_CODE_BOOL":        6,
		"TYPE_CODE_TIME":        7,
		"TYPE_CODE_NULL":        8,
	}
)

Enum value maps for TypeCode.

View Source
var File_sqlite_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 BlobValue

type BlobValue struct {
	Value []byte `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	Valid bool   `protobuf:"varint,2,opt,name=valid,proto3" json:"valid,omitempty"`
	// contains filtered or unexported fields
}

func (*BlobValue) Descriptor deprecated

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

Deprecated: Use BlobValue.ProtoReflect.Descriptor instead.

func (*BlobValue) GetValid

func (x *BlobValue) GetValid() bool

func (*BlobValue) GetValue

func (x *BlobValue) GetValue() []byte

func (*BlobValue) ProtoMessage

func (*BlobValue) ProtoMessage()

func (*BlobValue) ProtoReflect

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

func (*BlobValue) Reset

func (x *BlobValue) Reset()

func (*BlobValue) String

func (x *BlobValue) String() string

type BoolValue

type BoolValue struct {
	Value bool `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
	Valid bool `protobuf:"varint,2,opt,name=valid,proto3" json:"valid,omitempty"`
	// contains filtered or unexported fields
}

func (*BoolValue) Descriptor deprecated

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

Deprecated: Use BoolValue.ProtoReflect.Descriptor instead.

func (*BoolValue) GetValid

func (x *BoolValue) GetValid() bool

func (*BoolValue) GetValue

func (x *BoolValue) GetValue() bool

func (*BoolValue) ProtoMessage

func (*BoolValue) ProtoMessage()

func (*BoolValue) ProtoReflect

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

func (*BoolValue) Reset

func (x *BoolValue) Reset()

func (*BoolValue) String

func (x *BoolValue) String() string

type Column

type Column struct {
	Type TypeCode `protobuf:"varint,1,opt,name=type,proto3,enum=sqlite.rpc.v0.TypeCode" json:"type,omitempty"`
	Name string   `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	// contains filtered or unexported fields
}

func (*Column) Descriptor deprecated

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

Deprecated: Use Column.ProtoReflect.Descriptor instead.

func (*Column) GetName

func (x *Column) GetName() string

func (*Column) GetType

func (x *Column) GetType() TypeCode

func (*Column) ProtoMessage

func (*Column) ProtoMessage()

func (*Column) ProtoReflect

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

func (*Column) Reset

func (x *Column) Reset()

func (*Column) String

func (x *Column) String() string

type DatabaseService

type DatabaseService interface {
	Exec(context.Context, *ExecRequest) (*ExecResponse, error)

	Query(context.Context, *QueryRequest) (*QueryResponse, error)
}

func NewDatabaseServiceJSONClient

func NewDatabaseServiceJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) DatabaseService

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

func NewDatabaseServiceProtobufClient

func NewDatabaseServiceProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) DatabaseService

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

type ExecRequest

type ExecRequest struct {
	Sql        string   `protobuf:"bytes,1,opt,name=sql,proto3" json:"sql,omitempty"`
	Parameters []*Value `protobuf:"bytes,2,rep,name=parameters,proto3" json:"parameters,omitempty"`
	// contains filtered or unexported fields
}

func (*ExecRequest) Descriptor deprecated

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

Deprecated: Use ExecRequest.ProtoReflect.Descriptor instead.

func (*ExecRequest) GetParameters

func (x *ExecRequest) GetParameters() []*Value

func (*ExecRequest) GetSql

func (x *ExecRequest) GetSql() string

func (*ExecRequest) ProtoMessage

func (*ExecRequest) ProtoMessage()

func (*ExecRequest) ProtoReflect

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

func (*ExecRequest) Reset

func (x *ExecRequest) Reset()

func (*ExecRequest) String

func (x *ExecRequest) String() string

type ExecResponse

type ExecResponse struct {
	LastInsertId int64 `protobuf:"varint,1,opt,name=last_insert_id,json=lastInsertId,proto3" json:"last_insert_id,omitempty"`
	RowsAffected int64 `protobuf:"varint,2,opt,name=rows_affected,json=rowsAffected,proto3" json:"rows_affected,omitempty"`
	// contains filtered or unexported fields
}

func (*ExecResponse) Descriptor deprecated

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

Deprecated: Use ExecResponse.ProtoReflect.Descriptor instead.

func (*ExecResponse) GetLastInsertId

func (x *ExecResponse) GetLastInsertId() int64

func (*ExecResponse) GetRowsAffected

func (x *ExecResponse) GetRowsAffected() int64

func (*ExecResponse) ProtoMessage

func (*ExecResponse) ProtoMessage()

func (*ExecResponse) ProtoReflect

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

func (*ExecResponse) Reset

func (x *ExecResponse) Reset()

func (*ExecResponse) String

func (x *ExecResponse) 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 IntergerValue

type IntergerValue struct {
	Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
	Valid bool  `protobuf:"varint,2,opt,name=valid,proto3" json:"valid,omitempty"`
	// contains filtered or unexported fields
}

func (*IntergerValue) Descriptor deprecated

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

Deprecated: Use IntergerValue.ProtoReflect.Descriptor instead.

func (*IntergerValue) GetValid

func (x *IntergerValue) GetValid() bool

func (*IntergerValue) GetValue

func (x *IntergerValue) GetValue() int64

func (*IntergerValue) ProtoMessage

func (*IntergerValue) ProtoMessage()

func (*IntergerValue) ProtoReflect

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

func (*IntergerValue) Reset

func (x *IntergerValue) Reset()

func (*IntergerValue) String

func (x *IntergerValue) String() string

type ListValue

type ListValue struct {

	// Repeated field of dynamically typed values.
	Values []*Value `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"`
	// contains filtered or unexported fields
}

func (*ListValue) Descriptor deprecated

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

Deprecated: Use ListValue.ProtoReflect.Descriptor instead.

func (*ListValue) GetValues

func (x *ListValue) GetValues() []*Value

func (*ListValue) ProtoMessage

func (*ListValue) ProtoMessage()

func (*ListValue) ProtoReflect

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

func (*ListValue) Reset

func (x *ListValue) Reset()

func (*ListValue) String

func (x *ListValue) String() string

type NullValue

type NullValue struct {

	// value and valid are ignored - they are always treated as false
	Value bool `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
	Valid bool `protobuf:"varint,2,opt,name=valid,proto3" json:"valid,omitempty"`
	// contains filtered or unexported fields
}

func (*NullValue) Descriptor deprecated

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

Deprecated: Use NullValue.ProtoReflect.Descriptor instead.

func (*NullValue) GetValid

func (x *NullValue) GetValid() bool

func (*NullValue) GetValue

func (x *NullValue) GetValue() bool

func (*NullValue) ProtoMessage

func (*NullValue) ProtoMessage()

func (*NullValue) ProtoReflect

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

func (*NullValue) Reset

func (x *NullValue) Reset()

func (*NullValue) String

func (x *NullValue) String() string

type NumericValue

type NumericValue struct {
	Value float64 `protobuf:"fixed64,1,opt,name=value,proto3" json:"value,omitempty"`
	Valid bool    `protobuf:"varint,2,opt,name=valid,proto3" json:"valid,omitempty"`
	// contains filtered or unexported fields
}

func (*NumericValue) Descriptor deprecated

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

Deprecated: Use NumericValue.ProtoReflect.Descriptor instead.

func (*NumericValue) GetValid

func (x *NumericValue) GetValid() bool

func (*NumericValue) GetValue

func (x *NumericValue) GetValue() float64

func (*NumericValue) ProtoMessage

func (*NumericValue) ProtoMessage()

func (*NumericValue) ProtoReflect

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

func (*NumericValue) Reset

func (x *NumericValue) Reset()

func (*NumericValue) String

func (x *NumericValue) String() string

type QueryRequest

type QueryRequest struct {
	Sql        string   `protobuf:"bytes,1,opt,name=sql,proto3" json:"sql,omitempty"`
	Parameters []*Value `protobuf:"bytes,2,rep,name=parameters,proto3" json:"parameters,omitempty"`
	// contains filtered or unexported fields
}

func (*QueryRequest) Descriptor deprecated

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

Deprecated: Use QueryRequest.ProtoReflect.Descriptor instead.

func (*QueryRequest) GetParameters

func (x *QueryRequest) GetParameters() []*Value

func (*QueryRequest) GetSql

func (x *QueryRequest) GetSql() string

func (*QueryRequest) ProtoMessage

func (*QueryRequest) ProtoMessage()

func (*QueryRequest) ProtoReflect

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

func (*QueryRequest) Reset

func (x *QueryRequest) Reset()

func (*QueryRequest) String

func (x *QueryRequest) String() string

type QueryResponse

type QueryResponse struct {

	// column types
	Columns []*Column `protobuf:"bytes,1,rep,name=columns,proto3" json:"columns,omitempty"`
	// returned values
	Rows []*ListValue `protobuf:"bytes,2,rep,name=rows,proto3" json:"rows,omitempty"`
	// contains filtered or unexported fields
}

func (*QueryResponse) Descriptor deprecated

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

Deprecated: Use QueryResponse.ProtoReflect.Descriptor instead.

func (*QueryResponse) GetColumns

func (x *QueryResponse) GetColumns() []*Column

func (*QueryResponse) GetRows

func (x *QueryResponse) GetRows() []*ListValue

func (*QueryResponse) ProtoMessage

func (*QueryResponse) ProtoMessage()

func (*QueryResponse) ProtoReflect

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

func (*QueryResponse) Reset

func (x *QueryResponse) Reset()

func (*QueryResponse) String

func (x *QueryResponse) String() string

type RealValue

type RealValue struct {
	Value float64 `protobuf:"fixed64,1,opt,name=value,proto3" json:"value,omitempty"`
	Valid bool    `protobuf:"varint,2,opt,name=valid,proto3" json:"valid,omitempty"`
	// contains filtered or unexported fields
}

func (*RealValue) Descriptor deprecated

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

Deprecated: Use RealValue.ProtoReflect.Descriptor instead.

func (*RealValue) GetValid

func (x *RealValue) GetValid() bool

func (*RealValue) GetValue

func (x *RealValue) GetValue() float64

func (*RealValue) ProtoMessage

func (*RealValue) ProtoMessage()

func (*RealValue) ProtoReflect

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

func (*RealValue) Reset

func (x *RealValue) Reset()

func (*RealValue) String

func (x *RealValue) String() string

type TextValue

type TextValue struct {
	Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	Valid bool   `protobuf:"varint,2,opt,name=valid,proto3" json:"valid,omitempty"`
	// contains filtered or unexported fields
}

func (*TextValue) Descriptor deprecated

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

Deprecated: Use TextValue.ProtoReflect.Descriptor instead.

func (*TextValue) GetValid

func (x *TextValue) GetValid() bool

func (*TextValue) GetValue

func (x *TextValue) GetValue() string

func (*TextValue) ProtoMessage

func (*TextValue) ProtoMessage()

func (*TextValue) ProtoReflect

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

func (*TextValue) Reset

func (x *TextValue) Reset()

func (*TextValue) String

func (x *TextValue) String() string

type TimeValue

type TimeValue struct {
	Value *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	Valid bool                   `protobuf:"varint,2,opt,name=valid,proto3" json:"valid,omitempty"`
	// contains filtered or unexported fields
}

func (*TimeValue) Descriptor deprecated

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

Deprecated: Use TimeValue.ProtoReflect.Descriptor instead.

func (*TimeValue) GetValid

func (x *TimeValue) GetValid() bool

func (*TimeValue) GetValue

func (x *TimeValue) GetValue() *timestamppb.Timestamp

func (*TimeValue) ProtoMessage

func (*TimeValue) ProtoMessage()

func (*TimeValue) ProtoReflect

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

func (*TimeValue) Reset

func (x *TimeValue) Reset()

func (*TimeValue) String

func (x *TimeValue) 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 NewDatabaseServiceServer

func NewDatabaseServiceServer(svc DatabaseService, opts ...interface{}) TwirpServer

NewDatabaseServiceServer 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).

type Type

type Type struct {

	// code is the sqlite type
	Code TypeCode `protobuf:"varint,1,opt,name=code,proto3,enum=sqlite.rpc.v0.TypeCode" json:"code,omitempty"`
	// contains filtered or unexported fields
}

`Type` indicates the type of a sqlite value.

func (*Type) Descriptor deprecated

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

Deprecated: Use Type.ProtoReflect.Descriptor instead.

func (*Type) GetCode

func (x *Type) GetCode() TypeCode

func (*Type) ProtoMessage

func (*Type) ProtoMessage()

func (*Type) ProtoReflect

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

func (*Type) Reset

func (x *Type) Reset()

func (*Type) String

func (x *Type) String() string

type TypeCode

type TypeCode int32

`TypeCode` indicates the type of a sqlite value.

const (
	TypeCode_TYPE_CODE_UNSPECIFIED TypeCode = 0
	TypeCode_TYPE_CODE_INTEGER     TypeCode = 1
	TypeCode_TYPE_CODE_TEXT        TypeCode = 2
	TypeCode_TYPE_CODE_BLOB        TypeCode = 3
	TypeCode_TYPE_CODE_REAL        TypeCode = 4
	TypeCode_TYPE_CODE_NUMERIC     TypeCode = 5
	TypeCode_TYPE_CODE_BOOL        TypeCode = 6
	TypeCode_TYPE_CODE_TIME        TypeCode = 7
	TypeCode_TYPE_CODE_NULL        TypeCode = 8
)

func (TypeCode) Descriptor

func (TypeCode) Descriptor() protoreflect.EnumDescriptor

func (TypeCode) Enum

func (x TypeCode) Enum() *TypeCode

func (TypeCode) EnumDescriptor deprecated

func (TypeCode) EnumDescriptor() ([]byte, []int)

Deprecated: Use TypeCode.Descriptor instead.

func (TypeCode) Number

func (x TypeCode) Number() protoreflect.EnumNumber

func (TypeCode) String

func (x TypeCode) String() string

func (TypeCode) Type

type Value

type Value struct {

	// Types that are assignable to Kind:
	//	*Value_IntegerValue
	//	*Value_TextValue
	//	*Value_BlobValue
	//	*Value_RealValue
	//	*Value_NumericValue
	//	*Value_BoolValue
	//	*Value_TimeValue
	//	*Value_NullValue
	Kind isValue_Kind `protobuf_oneof:"kind"`
	// contains filtered or unexported fields
}

`Value` indicates the value of a parameter or returned column.

func (*Value) Descriptor deprecated

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

Deprecated: Use Value.ProtoReflect.Descriptor instead.

func (*Value) GetBlobValue

func (x *Value) GetBlobValue() *BlobValue

func (*Value) GetBoolValue

func (x *Value) GetBoolValue() *BoolValue

func (*Value) GetIntegerValue

func (x *Value) GetIntegerValue() *IntergerValue

func (*Value) GetKind

func (m *Value) GetKind() isValue_Kind

func (*Value) GetNullValue

func (x *Value) GetNullValue() *NullValue

func (*Value) GetNumericValue

func (x *Value) GetNumericValue() *NumericValue

func (*Value) GetRealValue

func (x *Value) GetRealValue() *RealValue

func (*Value) GetTextValue

func (x *Value) GetTextValue() *TextValue

func (*Value) GetTimeValue

func (x *Value) GetTimeValue() *TimeValue

func (*Value) ProtoMessage

func (*Value) ProtoMessage()

func (*Value) ProtoReflect

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

func (*Value) Reset

func (x *Value) Reset()

func (*Value) String

func (x *Value) String() string

type Value_BlobValue

type Value_BlobValue struct {
	BlobValue *BlobValue `protobuf:"bytes,3,opt,name=blob_value,json=blobValue,proto3,oneof"`
}

type Value_BoolValue

type Value_BoolValue struct {
	BoolValue *BoolValue `protobuf:"bytes,6,opt,name=bool_value,json=boolValue,proto3,oneof"`
}

type Value_IntegerValue

type Value_IntegerValue struct {
	IntegerValue *IntergerValue `protobuf:"bytes,1,opt,name=integer_value,json=integerValue,proto3,oneof"`
}

type Value_NullValue

type Value_NullValue struct {
	NullValue *NullValue `protobuf:"bytes,8,opt,name=null_value,json=nullValue,proto3,oneof"`
}

type Value_NumericValue

type Value_NumericValue struct {
	NumericValue *NumericValue `protobuf:"bytes,5,opt,name=numeric_value,json=numericValue,proto3,oneof"`
}

type Value_RealValue

type Value_RealValue struct {
	RealValue *RealValue `protobuf:"bytes,4,opt,name=real_value,json=realValue,proto3,oneof"`
}

type Value_TextValue

type Value_TextValue struct {
	TextValue *TextValue `protobuf:"bytes,2,opt,name=text_value,json=textValue,proto3,oneof"`
}

type Value_TimeValue

type Value_TimeValue struct {
	TimeValue *TimeValue `protobuf:"bytes,7,opt,name=time_value,json=timeValue,proto3,oneof"`
}

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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