Documentation
¶
Overview ¶
Copyright 2022 The Gidari Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0\n
Copyright 2022 The Gidari Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0\n
Copyright 2022 The Gidari Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0\n
Copyright 2022 The Gidari Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0\n
Index ¶
- Constants
- Variables
- func DNSNotSupportedError(dns string) error
- func DecodeUpsertRecords(req *UpsertRequest) ([]*structpb.Struct, error)
- func PartitionStructs(size int, slice []*structpb.Struct) [][]*structpb.Struct
- func SchemeFromConnectionString(dns string) string
- func SchemeFromStorageType(t uint8) string
- type Columns
- type Constructor
- type ListColumnsResponse
- func (*ListColumnsResponse) Descriptor() ([]byte, []int)deprecated
- func (x *ListColumnsResponse) GetColSet() map[string]*Columns
- func (*ListColumnsResponse) ProtoMessage()
- func (x *ListColumnsResponse) ProtoReflect() protoreflect.Message
- func (x *ListColumnsResponse) Reset()
- func (x *ListColumnsResponse) String() string
- type ListPrimaryKeysResponse
- func (*ListPrimaryKeysResponse) Descriptor() ([]byte, []int)deprecated
- func (x *ListPrimaryKeysResponse) GetPKSet() map[string]*PrimaryKeys
- func (*ListPrimaryKeysResponse) ProtoMessage()
- func (x *ListPrimaryKeysResponse) ProtoReflect() protoreflect.Message
- func (x *ListPrimaryKeysResponse) Reset()
- func (x *ListPrimaryKeysResponse) String() string
- type ListTablesResponse
- func (*ListTablesResponse) Descriptor() ([]byte, []int)deprecated
- func (x *ListTablesResponse) GetTableSet() map[string]*Table
- func (*ListTablesResponse) ProtoMessage()
- func (x *ListTablesResponse) ProtoReflect() protoreflect.Message
- func (x *ListTablesResponse) Reset()
- func (x *ListTablesResponse) String() string
- type PrimaryKeys
- type ReadRequest
- func (*ReadRequest) Descriptor() ([]byte, []int)deprecated
- func (x *ReadRequest) GetOptions() *structpb.Struct
- func (x *ReadRequest) GetReaderBuilder() []byte
- func (x *ReadRequest) GetRequired() *structpb.Struct
- func (x *ReadRequest) GetTable() string
- func (*ReadRequest) ProtoMessage()
- func (x *ReadRequest) ProtoReflect() protoreflect.Message
- func (x *ReadRequest) Reset()
- func (x *ReadRequest) String() string
- type ReadResponse
- type Service
- type Storage
- type Table
- type Transactor
- type TruncateRequest
- type TruncateResponse
- type Txn
- type TxnChanFn
- type UpsertDataType
- type UpsertRequest
- func (*UpsertRequest) Descriptor() ([]byte, []int)deprecated
- func (x *UpsertRequest) GetData() []byte
- func (x *UpsertRequest) GetDataType() int32
- func (x *UpsertRequest) GetTable() string
- func (*UpsertRequest) ProtoMessage()
- func (x *UpsertRequest) ProtoReflect() protoreflect.Message
- func (x *UpsertRequest) Reset()
- func (x *UpsertRequest) String() string
- type UpsertResponse
- func (*UpsertResponse) Descriptor() ([]byte, []int)deprecated
- func (x *UpsertResponse) GetMatchedCount() int64
- func (x *UpsertResponse) GetUpsertedCount() int64
- func (*UpsertResponse) ProtoMessage()
- func (x *UpsertResponse) ProtoReflect() protoreflect.Message
- func (x *UpsertResponse) Reset()
- func (x *UpsertResponse) String() string
Constants ¶
const ( // PostgresType is the byte representation of a postgres database. PostgresType = 0x01 // MongoType is the byte representation of a mongo database. MongoType = 0x02 )
const Version = "v0.0.0-alpha"
Variables ¶
var ( ErrUnsupportedDataType = fmt.Errorf("unsupported data type") ErrFailedToAssertInterface = fmt.Errorf("failed to assert interface") ErrFailedToMarshalJSON = fmt.Errorf("failed to marshal json") ErrFailedToUnmarshalJSON = fmt.Errorf("failed to unmarshal json") ErrFailedToCreateStruct = fmt.Errorf("failed to create struct") ErrFailedToScanRow = fmt.Errorf("failed to scan row") ErrFailedToParseFloat = fmt.Errorf("failed to parse float") ErrFailedToDecodeRecords = fmt.Errorf("failed to decode records") ErrFailedToGetColumns = fmt.Errorf("failed to get columns") )
var ErrDNSNotSupported = fmt.Errorf("dns is not supported")
var File_db_proto protoreflect.FileDescriptor
Functions ¶
func DNSNotSupportedError ¶
DNSNotSupported wraps an error with ErrDNSNotSupported.
func DecodeUpsertRecords ¶
func DecodeUpsertRecords(req *UpsertRequest) ([]*structpb.Struct, error)
DecodeUpsertRecords will decode the records from the upsert request into a slice of structs.
func PartitionStructs ¶
PartitionStructs ensures that the request structures are partitioned into size n or less-sized chunks of data, to comply with insert requirements.
func SchemeFromConnectionString ¶
SchemeFromConnectionString will return the scheme of a DNS.
func SchemeFromStorageType ¶
SchemeFromStorageType takes a byte and returns the associated DNS root database resource.
Types ¶
type Columns ¶
type Columns struct { List []string `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"` // contains filtered or unexported fields }
func (*Columns) Descriptor
deprecated
func (*Columns) ProtoMessage ¶
func (*Columns) ProtoMessage()
func (*Columns) ProtoReflect ¶
func (x *Columns) ProtoReflect() protoreflect.Message
type Constructor ¶
Constructor is a constructor method for a storage package.
type ListColumnsResponse ¶
type ListColumnsResponse struct { ColSet map[string]*Columns `` /* 153-byte string literal not displayed */ // contains filtered or unexported fields }
func (*ListColumnsResponse) Descriptor
deprecated
func (*ListColumnsResponse) Descriptor() ([]byte, []int)
Deprecated: Use ListColumnsResponse.ProtoReflect.Descriptor instead.
func (*ListColumnsResponse) GetColSet ¶
func (x *ListColumnsResponse) GetColSet() map[string]*Columns
func (*ListColumnsResponse) ProtoMessage ¶
func (*ListColumnsResponse) ProtoMessage()
func (*ListColumnsResponse) ProtoReflect ¶
func (x *ListColumnsResponse) ProtoReflect() protoreflect.Message
func (*ListColumnsResponse) Reset ¶
func (x *ListColumnsResponse) Reset()
func (*ListColumnsResponse) String ¶
func (x *ListColumnsResponse) String() string
type ListPrimaryKeysResponse ¶
type ListPrimaryKeysResponse struct { PKSet map[string]*PrimaryKeys `` /* 151-byte string literal not displayed */ // contains filtered or unexported fields }
func (*ListPrimaryKeysResponse) Descriptor
deprecated
func (*ListPrimaryKeysResponse) Descriptor() ([]byte, []int)
Deprecated: Use ListPrimaryKeysResponse.ProtoReflect.Descriptor instead.
func (*ListPrimaryKeysResponse) GetPKSet ¶
func (x *ListPrimaryKeysResponse) GetPKSet() map[string]*PrimaryKeys
func (*ListPrimaryKeysResponse) ProtoMessage ¶
func (*ListPrimaryKeysResponse) ProtoMessage()
func (*ListPrimaryKeysResponse) ProtoReflect ¶
func (x *ListPrimaryKeysResponse) ProtoReflect() protoreflect.Message
func (*ListPrimaryKeysResponse) Reset ¶
func (x *ListPrimaryKeysResponse) Reset()
func (*ListPrimaryKeysResponse) String ¶
func (x *ListPrimaryKeysResponse) String() string
type ListTablesResponse ¶
type ListTablesResponse struct { TableSet map[string]*Table `` /* 157-byte string literal not displayed */ // contains filtered or unexported fields }
func (*ListTablesResponse) Descriptor
deprecated
func (*ListTablesResponse) Descriptor() ([]byte, []int)
Deprecated: Use ListTablesResponse.ProtoReflect.Descriptor instead.
func (*ListTablesResponse) GetTableSet ¶
func (x *ListTablesResponse) GetTableSet() map[string]*Table
func (*ListTablesResponse) ProtoMessage ¶
func (*ListTablesResponse) ProtoMessage()
func (*ListTablesResponse) ProtoReflect ¶
func (x *ListTablesResponse) ProtoReflect() protoreflect.Message
func (*ListTablesResponse) Reset ¶
func (x *ListTablesResponse) Reset()
func (*ListTablesResponse) String ¶
func (x *ListTablesResponse) String() string
type PrimaryKeys ¶
type PrimaryKeys struct { List []string `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"` // contains filtered or unexported fields }
func (*PrimaryKeys) Descriptor
deprecated
func (*PrimaryKeys) Descriptor() ([]byte, []int)
Deprecated: Use PrimaryKeys.ProtoReflect.Descriptor instead.
func (*PrimaryKeys) GetList ¶
func (x *PrimaryKeys) GetList() []string
func (*PrimaryKeys) ProtoMessage ¶
func (*PrimaryKeys) ProtoMessage()
func (*PrimaryKeys) ProtoReflect ¶
func (x *PrimaryKeys) ProtoReflect() protoreflect.Message
func (*PrimaryKeys) Reset ¶
func (x *PrimaryKeys) Reset()
func (*PrimaryKeys) String ¶
func (x *PrimaryKeys) String() string
type ReadRequest ¶
type ReadRequest struct { // Optional table name. Defaults to 'default' ReaderBuilder []byte `protobuf:"bytes,1,opt,name=readerBuilder,proto3" json:"readerBuilder,omitempty"` Required *structpb.Struct `protobuf:"bytes,2,opt,name=required,proto3" json:"required,omitempty"` Options *structpb.Struct `protobuf:"bytes,3,opt,name=options,proto3" json:"options,omitempty"` Table string `protobuf:"bytes,4,opt,name=table,proto3" json:"table,omitempty"` // contains filtered or unexported fields }
Read data from a table. Lookup can be by ID or via querying any field in the record.
func (*ReadRequest) Descriptor
deprecated
func (*ReadRequest) Descriptor() ([]byte, []int)
Deprecated: Use ReadRequest.ProtoReflect.Descriptor instead.
func (*ReadRequest) GetOptions ¶
func (x *ReadRequest) GetOptions() *structpb.Struct
func (*ReadRequest) GetReaderBuilder ¶
func (x *ReadRequest) GetReaderBuilder() []byte
func (*ReadRequest) GetRequired ¶
func (x *ReadRequest) GetRequired() *structpb.Struct
func (*ReadRequest) GetTable ¶
func (x *ReadRequest) GetTable() string
func (*ReadRequest) ProtoMessage ¶
func (*ReadRequest) ProtoMessage()
func (*ReadRequest) ProtoReflect ¶
func (x *ReadRequest) ProtoReflect() protoreflect.Message
func (*ReadRequest) Reset ¶
func (x *ReadRequest) Reset()
func (*ReadRequest) String ¶
func (x *ReadRequest) String() string
type ReadResponse ¶
type ReadResponse struct { // JSON encoded records Records []*structpb.Struct `protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"` // contains filtered or unexported fields }
func (*ReadResponse) Descriptor
deprecated
func (*ReadResponse) Descriptor() ([]byte, []int)
Deprecated: Use ReadResponse.ProtoReflect.Descriptor instead.
func (*ReadResponse) GetRecords ¶
func (x *ReadResponse) GetRecords() []*structpb.Struct
func (*ReadResponse) ProtoMessage ¶
func (*ReadResponse) ProtoMessage()
func (*ReadResponse) ProtoReflect ¶
func (x *ReadResponse) ProtoReflect() protoreflect.Message
func (*ReadResponse) Reset ¶
func (x *ReadResponse) Reset()
func (*ReadResponse) String ¶
func (x *ReadResponse) String() string
type Storage ¶
type Storage interface { // Close will disconnect the storage device. Close() // ListPrimaryKeys will return a list of primary keys for all tables in the database. ListPrimaryKeys(ctx context.Context) (*ListPrimaryKeysResponse, error) // ListTables will return a list of all tables in the database. ListTables(ctx context.Context) (*ListTablesResponse, error) // IsNoSQL will return true if the storage device is a NoSQL database. IsNoSQL() bool // StartTx will start a transaction and return a "Tx" object that can be used to put operations on a channel, // commit the result of all operations sent to the transaction, or rollback the result of all operations sent // to the transaction. StartTx(context.Context) (*Txn, error) // Truncate will delete all data from the storage device for ast list of tables. Truncate(context.Context, *TruncateRequest) (*TruncateResponse, error) // Type returns the type of storage device. Type() uint8 // Upsert will insert or update a batch of records in the storage device. Upsert(context.Context, *UpsertRequest) (*UpsertResponse, error) }
Storage is an interface that defines the methods that a storage device should implement.
type Table ¶
type Table struct { Size int64 `protobuf:"varint,1,opt,name=size,proto3" json:"size,omitempty"` // contains filtered or unexported fields }
func (*Table) Descriptor
deprecated
func (*Table) ProtoMessage ¶
func (*Table) ProtoMessage()
func (*Table) ProtoReflect ¶
func (x *Table) ProtoReflect() protoreflect.Message
type Transactor ¶
Transactor is an interface that can be used to perform CRUD operations within the context of a database transaction.
type TruncateRequest ¶
type TruncateRequest struct { // Optional table name. Defaults to 'default' Tables []string `protobuf:"bytes,1,rep,name=tables,proto3" json:"tables,omitempty"` // contains filtered or unexported fields }
func (*TruncateRequest) Descriptor
deprecated
func (*TruncateRequest) Descriptor() ([]byte, []int)
Deprecated: Use TruncateRequest.ProtoReflect.Descriptor instead.
func (*TruncateRequest) GetTables ¶
func (x *TruncateRequest) GetTables() []string
func (*TruncateRequest) ProtoMessage ¶
func (*TruncateRequest) ProtoMessage()
func (*TruncateRequest) ProtoReflect ¶
func (x *TruncateRequest) ProtoReflect() protoreflect.Message
func (*TruncateRequest) Reset ¶
func (x *TruncateRequest) Reset()
func (*TruncateRequest) String ¶
func (x *TruncateRequest) String() string
type TruncateResponse ¶
type TruncateResponse struct { // Number of records deleted DeletedCount int32 `protobuf:"varint,1,opt,name=deletedCount,proto3" json:"deletedCount,omitempty"` // contains filtered or unexported fields }
func (*TruncateResponse) Descriptor
deprecated
func (*TruncateResponse) Descriptor() ([]byte, []int)
Deprecated: Use TruncateResponse.ProtoReflect.Descriptor instead.
func (*TruncateResponse) GetDeletedCount ¶
func (x *TruncateResponse) GetDeletedCount() int32
func (*TruncateResponse) ProtoMessage ¶
func (*TruncateResponse) ProtoMessage()
func (*TruncateResponse) ProtoReflect ¶
func (x *TruncateResponse) ProtoReflect() protoreflect.Message
func (*TruncateResponse) Reset ¶
func (x *TruncateResponse) Reset()
func (*TruncateResponse) String ¶
func (x *TruncateResponse) String() string
type Txn ¶
Txn is a wrapper for a mongo session that can be used to perform CRUD operations on a mongo DB instance.
type UpsertDataType ¶
type UpsertDataType uint8
UpsertDataType are the supported types for decoding upsert records.
const ( // UpsertDataJSON is the default upsert data type. UpsertDataJSON UpsertDataType = iota )
type UpsertRequest ¶
type UpsertRequest struct { Table string `protobuf:"bytes,1,opt,name=table,proto3" json:"table,omitempty"` DataType int32 `protobuf:"varint,3,opt,name=dataType,proto3" json:"dataType,omitempty"` Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"` // contains filtered or unexported fields }
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
func (*UpsertRequest) Descriptor
deprecated
func (*UpsertRequest) Descriptor() ([]byte, []int)
Deprecated: Use UpsertRequest.ProtoReflect.Descriptor instead.
func (*UpsertRequest) GetData ¶
func (x *UpsertRequest) GetData() []byte
func (*UpsertRequest) GetDataType ¶
func (x *UpsertRequest) GetDataType() int32
func (*UpsertRequest) GetTable ¶
func (x *UpsertRequest) GetTable() string
func (*UpsertRequest) ProtoMessage ¶
func (*UpsertRequest) ProtoMessage()
func (*UpsertRequest) ProtoReflect ¶
func (x *UpsertRequest) ProtoReflect() protoreflect.Message
func (*UpsertRequest) Reset ¶
func (x *UpsertRequest) Reset()
func (*UpsertRequest) String ¶
func (x *UpsertRequest) String() string
type UpsertResponse ¶
type UpsertResponse struct { // Number of records upserted UpsertedCount int64 `protobuf:"varint,1,opt,name=upsertedCount,proto3" json:"upsertedCount,omitempty"` // Number of records matched MatchedCount int64 `protobuf:"varint,2,opt,name=matchedCount,proto3" json:"matchedCount,omitempty"` // contains filtered or unexported fields }
func (*UpsertResponse) Descriptor
deprecated
func (*UpsertResponse) Descriptor() ([]byte, []int)
Deprecated: Use UpsertResponse.ProtoReflect.Descriptor instead.
func (*UpsertResponse) GetMatchedCount ¶
func (x *UpsertResponse) GetMatchedCount() int64
func (*UpsertResponse) GetUpsertedCount ¶
func (x *UpsertResponse) GetUpsertedCount() int64
func (*UpsertResponse) ProtoMessage ¶
func (*UpsertResponse) ProtoMessage()
func (*UpsertResponse) ProtoReflect ¶
func (x *UpsertResponse) ProtoReflect() protoreflect.Message
func (*UpsertResponse) Reset ¶
func (x *UpsertResponse) Reset()
func (*UpsertResponse) String ¶
func (x *UpsertResponse) String() string