Documentation ¶
Index ¶
- Constants
- Variables
- type BatchGetRowItem
- type BatchGetRowResponse
- type BatchWriteRowResponse
- type CapacityUnit
- type Client
- func (c *Client) BatchGetRow(items map[string]BatchGetRowItem) (*BatchGetRowResponse, error)
- func (c *Client) CreateTable(name string, primaryKey []*ColumnSchema, rt *ReservedThroughput) (*CreateTableResponse, error)
- func (c *Client) DeleteRow(name string, condition *Condition, primaryKey map[string]interface{}) (*DeleteRowResponse, error)
- func (c *Client) DeleteTable(name string) (*DeleteTableResponse, error)
- func (c *Client) DescribeTable(name string) (*TableMeta, *ReservedThoughputDetails, error)
- func (c *Client) GetRow(name string, primaryKey map[string]interface{}, columnNames []string) (*GetRowResponse, error)
- func (c *Client) Init() error
- func (c *Client) ListTable() (names []string, err error)
- func (c *Client) PutRow(name string, condition *Condition, primaryKey map[string]interface{}, ...) (response *PutRowResponse, err error)
- func (c *Client) UpdateRow(name string, condition *Condition, primaryKey map[string]interface{}, ...) (*UpdateRowResponse, error)
- func (c *Client) UpdateTable(name string, reservedThroughput *ReservedThroughput) (*UpdateTableResponse, error)
- type Column
- type ColumnSchema
- type ColumnType
- type ColumnUpdate
- type ColumnValue
- type Condition
- type ConsumedCapacity
- type CreateTableResponse
- type Decoder
- func (d *Decoder) DecodeBatchGetRow(data []byte) (*BatchGetRowResponse, error)
- func (d *Decoder) DecodeCreateTable(data []byte) (*CreateTableResponse, error)
- func (d *Decoder) DecodeDeleteRow(data []byte) (*DeleteRowResponse, error)
- func (d *Decoder) DecodeDeleteTable(data []byte) (*DeleteTableResponse, error)
- func (d *Decoder) DecodeDescribeTable(data []byte) (*TableMeta, *ReservedThoughputDetails, error)
- func (d *Decoder) DecodeGetRow(data []byte) (*GetRowResponse, error)
- func (d *Decoder) DecodeListTable(data []byte) ([]string, error)
- func (d *Decoder) DecodePutRow(data []byte) (*PutRowResponse, error)
- func (d *Decoder) DecodeUpdateRow(data []byte) (*UpdateRowResponse, error)
- func (d *Decoder) DecodeUpdateTable(data []byte) (*UpdateTableResponse, error)
- type DeleteRowResponse
- type DeleteTableResponse
- type DescribeTableResponse
- type Direction
- type Encoder
- func (e *Encoder) EncodeBatchGetRow(items map[string]BatchGetRowItem) (proto.Message, error)
- func (e *Encoder) EncodeCreateTable(name string, primaryKey []*ColumnSchema, rt *ReservedThroughput) (proto.Message, error)
- func (e *Encoder) EncodeDeleteRow(name string, condition *Condition, primaryKey map[string]interface{}) (proto.Message, error)
- func (e *Encoder) EncodeDeleteTable(name string) (proto.Message, error)
- func (e *Encoder) EncodeDescribeTable(name string) (proto.Message, error)
- func (e *Encoder) EncodeGetRow(name string, primaryKey map[string]interface{}, columnNames []string) (proto.Message, error)
- func (e *Encoder) EncodeListTable() (proto.Message, error)
- func (e *Encoder) EncodePutRow(name string, condition *Condition, primaryKey map[string]interface{}, ...) (proto.Message, error)
- func (e *Encoder) EncodeUpdateRow(name string, condition *Condition, primaryKey map[string]interface{}, ...) (proto.Message, error)
- func (e *Encoder) EncodeUpdateTable(name string, rt *ReservedThroughput) (proto.Message, error)
- type Error
- type GetRangeResponse
- type GetRowResponse
- type ListTableResponse
- type OTSClientError
- type OTSServiceError
- type OperationType
- type Protocol
- type PutRowResponse
- type ReservedThoughputDetails
- type ReservedThroughput
- type Row
- type RowExistenceExpectation
- type RowInBatchGetRowResponse
- type RowInBatchWriteRowResponse
- type TableInBatchGetRowResponse
- type TableInBatchWriteRowResponse
- type TableMeta
- type UpdateRowResponse
- type UpdateTableResponse
Constants ¶
View Source
const ( // DefaultEncoding 默认编码 DefaultEncoding = "utf8" // DefaultSocketTimeout 默认socket链接过期时间 DefaultSocketTimeout = 50 // DefaultMaxConnection 默认链接池最大链接数 DefaultMaxConnection = 50 )
View Source
const ( HeaderOTSDate = "x-ots-date" HeaderOTSAPIVersion = "x-ots-apiversion" HeaderOTSAccessKeyID = "x-ots-accesskeyid" HeaderOTSInstanceName = "x-ots-instancename" HeaderOTSContentMd5 = "x-ots-contentmd5" HeaderOTSSignature = "x-ots-signature" HeaderOTSRequestID = "x-ots-requestid" HeaderOTSContentType = "x-ots-contenttype" DefaultAPIVersion = "2014-08-08" TimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT" )
Variables ¶
View Source
var AllowedAPI = map[string]bool{ "CreateTable": true, "ListTable": true, "DeleteTable": true, "DescribeTable": true, "UpdateTable": true, "GetRow": true, "PutRow": true, "UpdateRow": true, "DeleteRow": true, "BatchGetRow": true, "BatchWriteRow": true, "GetRange": true, }
View Source
var ColumnTypeName = map[ColumnType]string{ ColumnTypeINFMin: "INF_MIN", ColumnTypeINFMax: "INF_MAX", ColumnTypeInteger: "INTEGER", ColumnTypeString: "STRING", ColumnTypeBoolean: "BOOLEAN", ColumnTypeDouble: "DOUBLE", ColumnTypeBinary: "BINARY", }
View Source
var ColumnTypeValue = map[string]ColumnType{ "INF_MIN": ColumnTypeINFMin, "INF_MAX": ColumnTypeINFMax, "INTEGER": ColumnTypeInteger, "STRING": ColumnTypeString, "BOOLEAN": ColumnTypeBoolean, "DOUBLE": ColumnTypeDouble, "BINARY": ColumnTypeBinary, }
View Source
var DirectionName = map[Direction]string{ DirectionForward: "FORWARD", DirectionBackward: "BACKWARD", }
View Source
var DirectionValue = map[string]Direction{ "FORWARD": DirectionForward, "BACKWARD": DirectionBackward, }
View Source
var OperationTypeName = map[OperationType]string{ OperationTypePut: "PUT", OperationTypeDelete: "DELETE", }
View Source
var OperationTypeValue = map[string]OperationType{ "PUT": OperationTypePut, "DELETE": OperationTypeDelete, }
View Source
var RowExistenceExpectationName = map[RowExistenceExpectation]string{ RowExistenceExpectationIgnore: "IGNORE", RowExistenceExpectationExpectExist: "EXPECT_EXIST", RowExistenceExpectationExpectNotExist: "EXPECT_NOT_EXIST", }
View Source
var RowExistenceExpectationValue = map[string]RowExistenceExpectation{ "IGNORE": RowExistenceExpectationIgnore, "EXPECT_EXIST": RowExistenceExpectationExpectExist, "EXPECT_NOT_EXIST": RowExistenceExpectationExpectNotExist, }
Functions ¶
This section is empty.
Types ¶
type BatchGetRowItem ¶
type BatchGetRowResponse ¶
type BatchGetRowResponse struct {
Tables []*TableInBatchGetRowResponse
}
func (*BatchGetRowResponse) Parse ¶
func (bgrr *BatchGetRowResponse) Parse(pbBGRR *protobuf.BatchGetRowResponse) *BatchGetRowResponse
type BatchWriteRowResponse ¶
type BatchWriteRowResponse struct {
Tables []*TableInBatchWriteRowResponse
}
type CapacityUnit ¶
func (*CapacityUnit) Parse ¶
func (cu *CapacityUnit) Parse(pbCU *protobuf.CapacityUnit) *CapacityUnit
func (*CapacityUnit) Unparse ¶
func (cu *CapacityUnit) Unparse() *protobuf.CapacityUnit
type Client ¶
type Client struct { EndPoint string AccessID string AccessKey string InstanceName string Encoding string SocketTimeout float32 MaxConnection int Debug bool Logger *log.Logger // contains filtered or unexported fields }
Client 实现了OTS服务的所有接口。用户可以通过NewClient方法创建Client实例
func NewClient ¶
NewClient 方法返回一个Client实例 示例:
import "github.com/Xuyuanp/gots client := ots.NewClient("your_instance_endpoint", "your_user_id", "your_user_key", "your_instance_name") client.Init()
func (*Client) BatchGetRow ¶
func (c *Client) BatchGetRow(items map[string]BatchGetRowItem) (*BatchGetRowResponse, error)
func (*Client) CreateTable ¶
func (c *Client) CreateTable(name string, primaryKey []*ColumnSchema, rt *ReservedThroughput) (*CreateTableResponse, error)
CreateTable 方法用于创建新表。 name: 表名 primaryKey: 主键列表 rt: 预留读写吞吐量 示例:
primaryKey := []*gots.ColumnSchema{ &gots.ColumnSchema{ Name: "gid", Type: gots.ColumnTypeInteger, }, &gots.ColumnSchema{ Name: "uid", Type: gots.ColumnTypeInteger, }, }
rt := &gots.ReservedThroughput{ CapacityUnit: &gots.CapacityUnit{ Read: 100, Write: 100, }, }
resp, err := client.CreateTable("sample_table", primaryKey, rt)
func (*Client) DeleteTable ¶
func (c *Client) DeleteTable(name string) (*DeleteTableResponse, error)
DeleteTable 方法用于删除表 name: 表名 示例:
resp, err := client.DeleteTable("sample_table")
func (*Client) DescribeTable ¶
func (c *Client) DescribeTable(name string) (*TableMeta, *ReservedThoughputDetails, error)
DescribeTable 方法用于获取表描述信息 name: 表名 示例:
resp, err := client.DescribeTable("sample_table")
func (*Client) UpdateTable ¶
func (c *Client) UpdateTable(name string, reservedThroughput *ReservedThroughput) (*UpdateTableResponse, error)
UpdateTable 跟新表属性,目前只支持修改预留读写吞吐量 name: 表名 reservedThroughput: 预留读写吞吐量 示例:
rt := &gots.ReservedThroughput{ CapacityUnit: &gots.CapacityUnit{ Read: 150, Write: 150, }, }
resp, err := client.UpdateTable("sample_table", rt)
type ColumnSchema ¶
type ColumnSchema struct { Name string Type ColumnType }
func (*ColumnSchema) Parse ¶
func (cs *ColumnSchema) Parse(pbCS *protobuf.ColumnSchema) *ColumnSchema
func (*ColumnSchema) Unparse ¶
func (cs *ColumnSchema) Unparse() *protobuf.ColumnSchema
type ColumnType ¶
type ColumnType int32
const ( ColumnTypeINFMin ColumnType = iota ColumnTypeINFMax ColumnTypeInteger ColumnTypeString ColumnTypeBoolean ColumnTypeDouble ColumnTypeBinary )
func (ColumnType) String ¶
func (t ColumnType) String() string
func (ColumnType) Unparse ¶
func (t ColumnType) Unparse() *protobuf.ColumnType
type ColumnUpdate ¶
type ColumnUpdate struct { Type OperationType Name string Value ColumnValue }
type ColumnValue ¶
type ColumnValue struct { Type ColumnType VInt int64 VString string VBool bool VDouble float64 VBinary []byte }
func NewColumnValue ¶
func NewColumnValue(v interface{}) *ColumnValue
func (*ColumnValue) Parse ¶
func (cv *ColumnValue) Parse(pbCV *protobuf.ColumnValue) *ColumnValue
func (*ColumnValue) Unparse ¶
func (cv *ColumnValue) Unparse() *protobuf.ColumnValue
func (*ColumnValue) Value ¶
func (cv *ColumnValue) Value() interface{}
type Condition ¶
type Condition struct {
RowExistence RowExistenceExpectation
}
type ConsumedCapacity ¶
type ConsumedCapacity struct {
CapacityUnit *CapacityUnit
}
func (*ConsumedCapacity) Parse ¶
func (cc *ConsumedCapacity) Parse(pbCC *protobuf.ConsumedCapacity) *ConsumedCapacity
type CreateTableResponse ¶
type CreateTableResponse struct { }
func (*CreateTableResponse) Parse ¶
func (ctr *CreateTableResponse) Parse(pbCTR *protobuf.CreateTableResponse) *CreateTableResponse
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
func (*Decoder) DecodeBatchGetRow ¶
func (d *Decoder) DecodeBatchGetRow(data []byte) (*BatchGetRowResponse, error)
func (*Decoder) DecodeCreateTable ¶
func (d *Decoder) DecodeCreateTable(data []byte) (*CreateTableResponse, error)
func (*Decoder) DecodeDeleteRow ¶
func (d *Decoder) DecodeDeleteRow(data []byte) (*DeleteRowResponse, error)
func (*Decoder) DecodeDeleteTable ¶
func (d *Decoder) DecodeDeleteTable(data []byte) (*DeleteTableResponse, error)
func (*Decoder) DecodeDescribeTable ¶
func (d *Decoder) DecodeDescribeTable(data []byte) (*TableMeta, *ReservedThoughputDetails, error)
func (*Decoder) DecodeGetRow ¶
func (d *Decoder) DecodeGetRow(data []byte) (*GetRowResponse, error)
func (*Decoder) DecodePutRow ¶
func (d *Decoder) DecodePutRow(data []byte) (*PutRowResponse, error)
func (*Decoder) DecodeUpdateRow ¶
func (d *Decoder) DecodeUpdateRow(data []byte) (*UpdateRowResponse, error)
func (*Decoder) DecodeUpdateTable ¶
func (d *Decoder) DecodeUpdateTable(data []byte) (*UpdateTableResponse, error)
type DeleteRowResponse ¶
type DeleteRowResponse struct {
Consumed *ConsumedCapacity
}
func (*DeleteRowResponse) Parse ¶
func (drr *DeleteRowResponse) Parse(pbDRR *protobuf.DeleteRowResponse) *DeleteRowResponse
type DeleteTableResponse ¶
type DeleteTableResponse struct { }
func (*DeleteTableResponse) Parse ¶
func (dtr *DeleteTableResponse) Parse(pbDTR *protobuf.DeleteTableResponse) *DeleteTableResponse
type DescribeTableResponse ¶
type DescribeTableResponse struct { TableMeta *TableMeta ReservedThoughputDetails *ReservedThoughputDetails }
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
func (*Encoder) EncodeBatchGetRow ¶
func (*Encoder) EncodeCreateTable ¶
func (e *Encoder) EncodeCreateTable(name string, primaryKey []*ColumnSchema, rt *ReservedThroughput) (proto.Message, error)
func (*Encoder) EncodeDeleteRow ¶
func (*Encoder) EncodeDeleteTable ¶
func (*Encoder) EncodeDescribeTable ¶
func (*Encoder) EncodeGetRow ¶
func (*Encoder) EncodePutRow ¶
func (*Encoder) EncodeUpdateRow ¶
func (*Encoder) EncodeUpdateTable ¶
type GetRangeResponse ¶
type GetRangeResponse struct { Consumed *ConsumedCapacity NextStartPrimaryKey []*Column Rows []*Row }
type GetRowResponse ¶
type GetRowResponse struct { Consumed *ConsumedCapacity Row *Row }
func (*GetRowResponse) Parse ¶
func (grr *GetRowResponse) Parse(pbGRR *protobuf.GetRowResponse) *GetRowResponse
type ListTableResponse ¶
type ListTableResponse struct {
TableNames []string
}
type OTSClientError ¶
func (*OTSClientError) Error ¶
func (e *OTSClientError) Error() string
type OTSServiceError ¶
func (*OTSServiceError) Error ¶
func (e *OTSServiceError) Error() string
type OperationType ¶
type OperationType int32
const ( OperationTypePut OperationType = 1 OperationTypeDelete OperationType = 2 )
type Protocol ¶
func (*Protocol) MakeRequest ¶
type PutRowResponse ¶
type PutRowResponse struct {
Consumed *ConsumedCapacity
}
func (*PutRowResponse) Parse ¶
func (prr *PutRowResponse) Parse(pbPRR *protobuf.PutRowResponse) *PutRowResponse
type ReservedThoughputDetails ¶
type ReservedThoughputDetails struct { CapacityUnit *CapacityUnit LastIncreaseTime int64 LastDescreaseTime int64 NumOfDescreasesToday int32 }
func (*ReservedThoughputDetails) Parse ¶
func (rtd *ReservedThoughputDetails) Parse(pbRTD *protobuf.ReservedThroughputDetails) *ReservedThoughputDetails
type ReservedThroughput ¶
type ReservedThroughput struct {
CapacityUnit *CapacityUnit
}
func (*ReservedThroughput) Unparse ¶
func (rt *ReservedThroughput) Unparse() *protobuf.ReservedThroughput
type RowExistenceExpectation ¶
type RowExistenceExpectation int32
const ( RowExistenceExpectationIgnore RowExistenceExpectation = iota RowExistenceExpectationExpectExist RowExistenceExpectationExpectNotExist )
type RowInBatchGetRowResponse ¶
type RowInBatchGetRowResponse struct { IsOk bool Error *Error Consumed *ConsumedCapacity Row *Row }
func (*RowInBatchGetRowResponse) Parse ¶
func (rgrr *RowInBatchGetRowResponse) Parse(pbRGRR *protobuf.RowInBatchGetRowResponse) *RowInBatchGetRowResponse
type RowInBatchWriteRowResponse ¶
type RowInBatchWriteRowResponse struct { IsOk bool Error *Error Consumed *ConsumedCapacity }
type TableInBatchGetRowResponse ¶
type TableInBatchGetRowResponse struct { TableName string Rows []*RowInBatchGetRowResponse }
func (*TableInBatchGetRowResponse) Parse ¶
func (tgrr *TableInBatchGetRowResponse) Parse(pbTGRR *protobuf.TableInBatchGetRowResponse) *TableInBatchGetRowResponse
type TableInBatchWriteRowResponse ¶
type TableInBatchWriteRowResponse struct { TableName string PutRows []*RowInBatchWriteRowResponse UpdateRows []*RowInBatchWriteRowResponse DeleteRows []*RowInBatchWriteRowResponse }
type TableMeta ¶
type TableMeta struct { TableName string PrimaryKey []*ColumnSchema }
type UpdateRowResponse ¶
type UpdateRowResponse struct {
Consumed *ConsumedCapacity
}
func (*UpdateRowResponse) Parse ¶
func (urr *UpdateRowResponse) Parse(pbURR *protobuf.UpdateRowResponse) *UpdateRowResponse
type UpdateTableResponse ¶
type UpdateTableResponse struct {
ReservedThoughputDetails *ReservedThoughputDetails
}
func (*UpdateTableResponse) Parse ¶
func (utr *UpdateTableResponse) Parse(pbUTR *protobuf.UpdateTableResponse) *UpdateTableResponse
Source Files ¶
Click to show internal directories.
Click to hide internal directories.