api

package
v1.0.0-alpha.11 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Insert                   protoreflect.FullName = "InsertRequest"
	Replace                  protoreflect.FullName = "ReplaceRequest"
	Update                   protoreflect.FullName = "UpdateRequest"
	Delete                   protoreflect.FullName = "DeleteRequest"
	Read                     protoreflect.FullName = "ReadRequest"
	BeginTransaction         protoreflect.FullName = "BeginTransactionRequest"
	CommitTransaction        protoreflect.FullName = "CommitTransactionRequest"
	RollbackTransaction      protoreflect.FullName = "RollbackTransactionRequest"
	CreateOrUpdateCollection protoreflect.FullName = "CreateOrUpdateCollectionRequest"
	DropCollection           protoreflect.FullName = "DropCollectionRequest"
	ListCollections          protoreflect.FullName = "ListCollectionsRequest"
	ListDatabases            protoreflect.FullName = "ListDatabasesRequest"
	CreateDatabase           protoreflect.FullName = "CreateDatabaseRequest"
	DropDatabase             protoreflect.FullName = "DropDatabaseRequest"
	Stream                   protoreflect.FullName = "StreamRequest"
)

Variables

View Source
var RequestType = proto.MessageName

Functions

func IsTxSupported

func IsTxSupported(req Request) bool

func MarshalStatus

func MarshalStatus(status *spb.Status) ([]byte, error)

MarshalStatus marshal status object

Types

type CustomMarshaler

type CustomMarshaler struct {
	*runtime.JSONBuiltin
}

CustomMarshaler is a marshaler to customize the response. Currently it is only used to marshal custom error message otherwise it just use the inbuilt mux marshaller.

func (*CustomMarshaler) Marshal

func (c *CustomMarshaler) Marshal(v interface{}) ([]byte, error)

type Metadata

type Metadata struct {
	CreatedAt *time.Time `json:"created_at,omitempty"`
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func CreateMDFromResponseMD

func CreateMDFromResponseMD(x *ResponseMetadata) Metadata

type Request

type Request interface {
	proto.Message

	Validator
}

type Response

type Response interface {
	proto.Message
}

type TigrisError

type TigrisError struct {
	// The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. We don't need to marshal
	// this code for HTTP clients.
	Code codes.Code `json:"code,omitempty"`
	// A developer-facing error message.
	Message string `json:"message,omitempty"`
	// A list of messages that carry the error details. This is mainly to send our internal codes and messages.
	Details []*ErrorDetails `json:"details,omitempty"`
}

TigrisError is our Tigris HTTP counterpart of grpc status. All the APIs should use this Error to return as a user facing error. TigrisError will return grpcStatus to the muxer so that grpc client can see grpcStatus as the final output. For HTTP clients see the **MarshalStatus** method where we are returning the response by not the grpc code as that is not needed for HTTP clients.

func Error

func Error(c codes.Code, msg string) *TigrisError

Error returns an error representing c and msg. If c is OK, returns nil.

func Errorf

func Errorf(c codes.Code, format string, a ...interface{}) *TigrisError

Errorf returns Error(c, fmt.Sprintf(format, a...)).

func (*TigrisError) Error

func (e *TigrisError) Error() string

Error to return the underlying error message

func (*TigrisError) GRPCStatus

func (e *TigrisError) GRPCStatus() *status.Status

GRPCStatus converts the TigrisError and return status.Status. This is used to return grpc status to the grpc clients

func (*TigrisError) WithDetails

func (e *TigrisError) WithDetails(details ...*ErrorDetails) *TigrisError

WithDetails a helper method for adding details to the TigrisError

type Validator

type Validator interface {
	Validate() error
}

Jump to

Keyboard shortcuts

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