Documentation ¶
Index ¶
- Constants
- type AggregateParam
- type Amplifier
- type AmplifyOptions
- type Client
- func (client *Client) Aggregate(ctx context.Context, query *AggregateParam) (documents []interface{}, err error)
- func (client *Client) Close() (err error)
- func (client *Client) Count(ctx context.Context, query *QueryParam) (count uint64, err error)
- func (client *Client) Distinct(ctx context.Context, query *QueryParam) (distinctKeys []interface{}, err error)
- func (client *Client) Explain(ctx context.Context, query *QueryParam) (explainFields bson.M, err error)
- func (client *Client) Find(ctx context.Context, query *QueryParam) (docs []interface{}, err error)
- func (client *Client) FindAndModify(ctx context.Context, param *FindModifyParam) (singleDoc interface{}, err error)
- func (client *Client) FindIter(ctx context.Context, query *QueryParam) (stream mprpc.MongoProxy_FindIterClient, err error)
- func (client *Client) HealthCheck() (err error)
- func (client *Client) Insert(ctx context.Context, param *InsertParam) (err error)
- func (client *Client) Remove(ctx context.Context, param *RemoveParam) (changeInfo *mprpc.ChangeInfo, err error)
- func (client *Client) Update(ctx context.Context, param *UpdateParam) (changeInfo *mprpc.ChangeInfo, err error)
- type Config
- type Empty
- type FindAndModifyMode
- type FindModifyParam
- type InsertParam
- type QueryParam
- type RemoveParam
- type UpdateParam
Constants ¶
const ( Find = "mprpc.MongoProxy.Find" FindIter = "mprpc.MongoProxy.FindIter" Count = "mprpc.MongoProxy.Count" Explain = "mprpc.MongoProxy.Explain" Aggregate = "mprpc.MongoProxy.Aggregate" Bulk = "mprpc.MongoProxy.Bulk" Update = "mprpc.MongoProxy.Update" Remove = "mprpc.MongoProxy.Remove" Insert = "mprpc.MongoProxy.Insert" FindAndModify = "mprpc.MongoProxy.FindAndModify" Distinct = "mprpc.MongoProxy.Distinct" Healthcheck = "mprpc.MongoProxy.Healthcheck" )
Function List in Proxy
const ( Database = "ebenchmark" Collection = "default" )
Database used for ebenchmark
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AggregateParam ¶
Aggregate param for upper services
type AmplifyOptions ¶
type AmplifyOptions struct { Connections uint `long:"connections" default:"1" description:"storage server address"` Concurrency uint `long:"concurrency" default:"5" description:"storage server address"` TotalRequest uint `long:"requests" default:"20" description:"storage server address"` QPS uint `long:"qps" description:"storage server address"` Timeout time.Duration `long:"timeout" description:"storage server address"` CPUs uint `long:"cpu" default:"1" description:"storage server address"` }
AmplifyOptions for ghz
func Amplifer ¶
func Amplifer(options AmplifyOptions) *AmplifyOptions
Get AmplifyOptions based on given param
func MicroAmplifier ¶
func MicroAmplifier() (amplifier *AmplifyOptions)
MicroAmplifier generate AmplifyOptions for light weight workload
func StressAmplifier ¶
func StressAmplifier() (amplifier *AmplifyOptions)
StressAmplifier generate AmplifyOptions for stress workload
type Client ¶
type Client struct { Host string Collection *mprpc.Collection Turbo bool Healthy int32 ProtoFile string // contains filtered or unexported fields }
Client represents a middleware with the actual database driver
Currently client will use ebenchmark database as defined in const to avoid interfere with production workload. client support multi api. See the documentation on const for more details.
func NewClient ¶
func NewClient(config *Config, namespace string, cancel context.CancelFunc) (client *Client, err error)
NewClient Creates a new proxy client based on provided config This method is generally called just once for con establish, does health check in the background task, and check for env: PROTOSET_FILE, this env represent grpc interface with driver
Once Client is not useful anymore, Close must be called to release the resources appropriately
func (*Client) Aggregate ¶
func (client *Client) Aggregate(ctx context.Context, query *AggregateParam) (documents []interface{}, err error)
Aggregate processes data records and return computed results. Aggregation operations group values from multiple documents together, and can perform a variety of operations on the grouped data to return a single result.
See proxy.AggregateParam for customizing aggregate param ¶
Relevant documentation:
http://docs.mongodb.org/manual/reference/aggregation http://docs.mongodb.org/manual/applications/aggregation http://docs.mongodb.org/manual/tutorial/aggregation-examples
func (*Client) Close ¶
Close will release the resources in a proxy client, and call cancelFunc if specified
Call Close after NewClient, See NewClient for more details
func (*Client) Count ¶
Count returns the total number of documents in the collection.
See proxy.QueryParam for customizing query param
func (*Client) Distinct ¶
func (client *Client) Distinct(ctx context.Context, query *QueryParam) (distinctKeys []interface{}, err error)
Distinct unmarshals into result the list of distinct values for the given key.
See proxy.QueryParam for customizing distinct param ¶
Relevant documentation:
http://www.mongodb.org/display/DOCS/Aggregation
func (*Client) Explain ¶
func (client *Client) Explain(ctx context.Context, query *QueryParam) (explainFields bson.M, err error)
Explain returns a number of details about how the MongoDB server would execute the requested query, such as the number of objects examined, the number of times the read lock was yielded to allow writes to go in, and so on.
See proxy.QueryParam for customizing query param ¶
Relevant documentation:
http://www.mongodb.org/display/DOCS/Optimization http://www.mongodb.org/display/DOCS/Query+Optimizer
func (*Client) Find ¶
func (client *Client) Find(ctx context.Context, query *QueryParam) (docs []interface{}, err error)
Find prepares a query using the provided document
See proxy.QueryParam for customizing query param ¶
Relevant documentation:
http://www.mongodb.org/display/DOCS/Querying http://www.mongodb.org/display/DOCS/Advanced+Queries
func (*Client) FindAndModify ¶
func (client *Client) FindAndModify(ctx context.Context, param *FindModifyParam) (singleDoc interface{}, err error)
FindAndModify allows updating, upserting or removing a document matching a query and atomically returning either the old version (the default) or the new version of the document (when ReturnNew is true). If no objects are found Apply returns ErrNotFound.
See proxy.FindModifyParam for customizing findAndModify param ¶
Relevant documentation:
http://www.mongodb.org/display/DOCS/findAndModify+Command http://www.mongodb.org/display/DOCS/Updating http://www.mongodb.org/display/DOCS/Atomic+Operations
func (*Client) FindIter ¶
func (client *Client) FindIter(ctx context.Context, query *QueryParam) (stream mprpc.MongoProxy_FindIterClient, err error)
FindIter works like Find, but uses iterClient as stream function
See proxy.QueryParam for customizing query param ¶
Relevant documentation:
http://www.mongodb.org/display/DOCS/Querying http://www.mongodb.org/display/DOCS/Advanced+Queries
func (*Client) HealthCheck ¶
HealthCheck checks database driver, and atomically update client
func (*Client) Insert ¶
func (client *Client) Insert(ctx context.Context, param *InsertParam) (err error)
Insert inserts one or more documents in the respective collection.
See proxy.InsertParam for customizing insert param ¶
Relevant documentation:
func (*Client) Remove ¶
func (client *Client) Remove(ctx context.Context, param *RemoveParam) (changeInfo *mprpc.ChangeInfo, err error)
Remove finds documents matching the provided selector document and removes it from the database.
See proxy.RemoveParam for customizing remove param ¶
Relevant documentation:
http://www.mongodb.org/display/DOCS/Removing
func (*Client) Update ¶
func (client *Client) Update(ctx context.Context, param *UpdateParam) (changeInfo *mprpc.ChangeInfo, err error)
Update finds a single document matching the provided selector document and modifies it according to the update document.
See proxy.QueryParam for customizing query param ¶
Relevant documentation:
http://www.mongodb.org/display/DOCS/Updating http://www.mongodb.org/display/DOCS/Atomic+Operations
type Config ¶
type Config struct { ServerIp string `short:"s" long:"storage" default:"127.0.0.1" description:"storage server address"` Port int `short:"p" long:"port" default:"50051" description:"storage server port"` Insecure bool `long:"insecure" description:"storage server connection secure"` RpcTimeout int64 `short:"t" long:"timeout" default:"25000" description:"request timeout"` BatchSize int64 `short:"b" long:"batch" default:"10000" description:"batch size"` ReadPref int32 `short:"r" long:"readpref" default:"2" description:"read preference"` AllowPartial bool `long:"partial" description:"allow partial"` }
Proxy client config
type FindAndModifyMode ¶
type FindAndModifyMode int
const ( FindAndDelete FindAndModifyMode = 0 FindAndUpdate FindAndModifyMode = 1 FindAndUpsert FindAndModifyMode = 2 )
Mode for FindAndModify
type FindModifyParam ¶
type FindModifyParam struct { Filter bson.M Desired bson.M Mode FindAndModifyMode SortRule []string Fields bson.M Amp Amplifier }
FindAndModify param for upper services
type InsertParam ¶
type InsertParam struct { Docs []interface{} Amp Amplifier }
Insert param for upper services
type QueryParam ¶
type QueryParam struct { Filter bson.M Fields bson.M Limit int64 Skip int64 Sort []string Distinctkey string FindOne bool UsingIndex []string Amp Amplifier }
Query param for upper services
type RemoveParam ¶
Remove param for upper services
func UndoInsert ¶
func UndoInsert(param *InsertParam) (params []*RemoveParam)
UndoInsert generate removeParam based on given insert param Currently nested struct is not supported
Please refer proxy.InsertParam, proxy.RemoveParam for more details