本文整理汇总了Golang中github.com/youtube/vitess/go/vt/vtgate/proto.QueryResultList.Session方法的典型用法代码示例。如果您正苦于以下问题:Golang QueryResultList.Session方法的具体用法?Golang QueryResultList.Session怎么用?Golang QueryResultList.Session使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/youtube/vitess/go/vt/vtgate/proto.QueryResultList
的用法示例。
在下文中一共展示了QueryResultList.Session方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ExecuteBatchKeyspaceIds
// ExecuteBatchKeyspaceIds executes a group of queries based on the specified keyspace ids.
func (vtg *VTGate) ExecuteBatchKeyspaceIds(ctx context.Context, query *proto.KeyspaceIdBatchQuery, reply *proto.QueryResultList) error {
startTime := time.Now()
statsKey := []string{"ExecuteBatchKeyspaceIds", "", ""}
defer vtg.timings.Record(statsKey, startTime)
x := vtg.inFlight.Add(1)
defer vtg.inFlight.Add(-1)
if 0 < vtg.maxInFlight && vtg.maxInFlight < x {
return errTooManyInFlight
}
qrs, err := vtg.resolver.ExecuteBatchKeyspaceIds(
ctx,
query)
if err == nil {
reply.List = qrs.List
var rowCount int64
for _, qr := range qrs.List {
rowCount += int64(len(qr.Rows))
}
vtg.rowsReturned.Add(statsKey, rowCount)
} else {
reply.Error = handleExecuteError(err, statsKey, query, vtg.logExecuteBatchKeyspaceIds)
}
reply.Session = query.Session
return nil
}
示例2: ExecuteBatchKeyspaceIds
// ExecuteBatchKeyspaceIds executes a group of queries based on the specified keyspace ids.
func (vtg *VTGate) ExecuteBatchKeyspaceIds(context interface{}, query *proto.KeyspaceIdBatchQuery, reply *proto.QueryResultList) error {
shards, err := mapKeyspaceIdsToShards(
vtg.scatterConn.toposerv,
vtg.scatterConn.cell,
query.Keyspace,
query.TabletType,
query.KeyspaceIds)
if err != nil {
return err
}
qrs, err := vtg.scatterConn.ExecuteBatch(
context,
query.Queries,
query.Keyspace,
shards,
query.TabletType,
NewSafeSession(query.Session))
if err == nil {
reply.List = qrs.List
} else {
reply.Error = err.Error()
log.Errorf("ExecuteBatchKeyspaceIds: %v, query: %+v", err, query)
}
reply.Session = query.Session
return nil
}
示例3: ExecuteBatchShard
// ExecuteBatchShard executes a group of queries on the specified shards.
func (vtg *VTGate) ExecuteBatchShard(ctx context.Context, batchQuery *proto.BatchQueryShard, reply *proto.QueryResultList) error {
startTime := time.Now()
statsKey := []string{"ExecuteBatchShard", "", ""}
defer vtg.timings.Record(statsKey, startTime)
x := vtg.inFlight.Add(1)
defer vtg.inFlight.Add(-1)
if 0 < vtg.maxInFlight && vtg.maxInFlight < x {
return errTooManyInFlight
}
qrs, err := vtg.resolver.ExecuteBatch(
ctx,
batchQuery.TabletType,
batchQuery.AsTransaction,
batchQuery.Session,
func() (*scatterBatchRequest, error) {
return boundShardQueriesToScatterBatchRequest(batchQuery.Queries), nil
})
if err == nil {
reply.List = qrs.List
var rowCount int64
for _, qr := range qrs.List {
rowCount += int64(len(qr.Rows))
}
vtg.rowsReturned.Add(statsKey, rowCount)
} else {
reply.Error = handleExecuteError(err, statsKey, batchQuery, vtg.logExecuteBatchShard)
}
reply.Session = batchQuery.Session
return nil
}
示例4: ExecuteBatchKeyspaceIds
// ExecuteBatchKeyspaceIds executes a group of queries based on the specified keyspace ids.
func (vtg *VTGate) ExecuteBatchKeyspaceIds(context context.Context, query *proto.KeyspaceIdBatchQuery, reply *proto.QueryResultList) (err error) {
defer handlePanic(&err)
startTime := time.Now()
statsKey := []string{"ExecuteBatchKeyspaceIds", query.Keyspace, string(query.TabletType)}
defer vtg.timings.Record(statsKey, startTime)
x := vtg.inFlight.Add(1)
defer vtg.inFlight.Add(-1)
if 0 < vtg.maxInFlight && vtg.maxInFlight < x {
return ErrTooManyInFlight
}
qrs, err := vtg.resolver.ExecuteBatchKeyspaceIds(
context,
query)
if err == nil {
reply.List = qrs.List
} else {
reply.Error = err.Error()
if strings.Contains(reply.Error, errDupKey) {
infoErrors.Add("DupKey", 1)
} else {
normalErrors.Add(statsKey, 1)
vtg.logExecuteBatchKeyspaceIds.Errorf("%v, query: %+v", err, query)
}
}
reply.Session = query.Session
return nil
}
示例5: ExecuteBatchShard
// ExecuteBatchShard executes a group of queries on the specified shards.
func (vtg *VTGate) ExecuteBatchShard(context interface{}, batchQuery *proto.BatchQueryShard, reply *proto.QueryResultList) error {
startTime := time.Now()
statsKey := []string{"ExecuteBatchShard", batchQuery.Keyspace, string(batchQuery.TabletType)}
defer vtg.timings.Record(statsKey, startTime)
qrs, err := vtg.resolver.ExecuteBatch(
context,
batchQuery.Queries,
batchQuery.Keyspace,
batchQuery.TabletType,
batchQuery.Session,
func(keyspace string) (string, []string, error) {
return batchQuery.Keyspace, batchQuery.Shards, nil
},
)
if err == nil {
reply.List = qrs.List
} else {
reply.Error = err.Error()
vtg.errors.Add(statsKey, 1)
// FIXME(alainjobart): throttle this log entry
log.Errorf("ExecuteBatchShard: %v, queries: %+v", err, batchQuery)
}
reply.Session = batchQuery.Session
return nil
}
示例6: ExecuteBatchShard
// ExecuteBatchShard executes a group of queries on the specified shards.
func (vtg *VTGate) ExecuteBatchShard(ctx context.Context, batchQuery *proto.BatchQueryShard, reply *proto.QueryResultList) error {
startTime := time.Now()
statsKey := []string{"ExecuteBatchShard", "", ""}
defer vtg.timings.Record(statsKey, startTime)
x := vtg.inFlight.Add(1)
defer vtg.inFlight.Add(-1)
if 0 < vtg.maxInFlight && vtg.maxInFlight < x {
return errTooManyInFlight
}
// TODO(sougou): implement functionality
qrs, err := &proto.QueryResultList{}, error(nil)
if err == nil {
reply.List = qrs.List
var rowCount int64
for _, qr := range qrs.List {
rowCount += int64(len(qr.Rows))
}
vtg.rowsReturned.Add(statsKey, rowCount)
} else {
reply.Error = handleExecuteError(err, statsKey, batchQuery, vtg.logExecuteBatchShard)
}
reply.Session = batchQuery.Session
return nil
}
示例7: ExecuteBatchShard
// ExecuteBatchShard executes a group of queries on the specified shards.
func (vtg *VTGate) ExecuteBatchShard(context context.Context, batchQuery *proto.BatchQueryShard, reply *proto.QueryResultList) error {
startTime := time.Now()
statsKey := []string{"ExecuteBatchShard", batchQuery.Keyspace, string(batchQuery.TabletType)}
defer vtg.timings.Record(statsKey, startTime)
qrs, err := vtg.resolver.ExecuteBatch(
context,
batchQuery.Queries,
batchQuery.Keyspace,
batchQuery.TabletType,
batchQuery.Session,
func(keyspace string) (string, []string, error) {
return batchQuery.Keyspace, batchQuery.Shards, nil
},
)
if err == nil {
reply.List = qrs.List
} else {
reply.Error = err.Error()
if strings.Contains(reply.Error, errDupKey) {
vtg.infoErrors.Add("DupKey", 1)
} else {
vtg.errors.Add(statsKey, 1)
vtg.logExecuteBatchShard.Errorf("%v, queries: %+v", err, batchQuery)
}
}
reply.Session = batchQuery.Session
return nil
}
示例8: ExecuteBatchKeyspaceIds
// ExecuteBatchKeyspaceIds executes a group of queries based on the specified keyspace ids.
func (vtg *VTGate) ExecuteBatchKeyspaceIds(context interface{}, query *proto.KeyspaceIdBatchQuery, reply *proto.QueryResultList) error {
qrs, err := vtg.resolver.ExecuteBatchKeyspaceIds(
context,
query)
if err == nil {
reply.List = qrs.List
} else {
reply.Error = err.Error()
log.Errorf("ExecuteBatchKeyspaceIds: %v, query: %+v", err, query)
}
reply.Session = query.Session
return nil
}
示例9: ExecuteBatchKeyspaceIds
func (c *errorClient) ExecuteBatchKeyspaceIds(ctx context.Context, queries []*vtgatepb.BoundKeyspaceIdQuery, tabletType topodatapb.TabletType, asTransaction bool, session *vtgatepb.Session, reply *proto.QueryResultList) error {
if len(queries) == 1 {
var partialReply proto.QueryResult
if requestToPartialError(queries[0].Query.Sql, session, &partialReply) {
reply.Err = partialReply.Err
reply.Session = partialReply.Session
return nil
}
if err := requestToError(queries[0].Query.Sql); err != nil {
return err
}
}
return c.fallbackClient.ExecuteBatchKeyspaceIds(ctx, queries, tabletType, asTransaction, session, reply)
}
示例10: ExecuteBatchShard
// ExecuteBatchShard executes a group of queries on the specified shards.
func (vtg *VTGate) ExecuteBatchShard(context *rpcproto.Context, batchQuery *proto.BatchQueryShard, reply *proto.QueryResultList) error {
qrs, err := vtg.scatterConn.ExecuteBatch(
batchQuery.Queries,
batchQuery.Keyspace,
batchQuery.Shards,
batchQuery.TabletType,
NewSafeSession(batchQuery.Session))
if err == nil {
reply.List = qrs.List
} else {
reply.Error = err.Error()
log.Errorf("ExecuteBatchShard: %v, queries: %#v", err, batchQuery)
}
reply.Session = batchQuery.Session
return nil
}
示例11: ExecuteBatchKeyspaceIds
// ExecuteBatchKeyspaceIds is the RPC version of
// vtgateservice.VTGateService method
func (vtg *VTGate) ExecuteBatchKeyspaceIds(ctx context.Context, request *proto.KeyspaceIdBatchQuery, reply *proto.QueryResultList) (err error) {
defer vtg.server.HandlePanic(&err)
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(*rpcTimeout))
defer cancel()
ctx = callerid.NewContext(ctx,
callerid.GoRPCEffectiveCallerID(request.CallerID),
callerid.NewImmediateCallerID("gorpc client"))
sessionFromRPC(request.Session)
vtgErr := vtg.server.ExecuteBatchKeyspaceIds(ctx,
request.Queries,
request.TabletType,
request.AsTransaction,
request.Session,
reply)
reply.Session = sessionToRPC(reply.Session)
vtgate.AddVtGateError(vtgErr, &reply.Err)
return nil
}
示例12: ExecuteBatchKeyspaceIds
// ExecuteBatchKeyspaceIds executes a group of queries based on the specified keyspace ids.
func (vtg *VTGate) ExecuteBatchKeyspaceIds(context interface{}, query *proto.KeyspaceIdBatchQuery, reply *proto.QueryResultList) error {
startTime := time.Now()
statsKey := []string{"ExecuteBatchKeyspaceIds", query.Keyspace, string(query.TabletType)}
defer vtg.timings.Record(statsKey, startTime)
qrs, err := vtg.resolver.ExecuteBatchKeyspaceIds(
context,
query)
if err == nil {
reply.List = qrs.List
} else {
reply.Error = err.Error()
vtg.errors.Add(statsKey, 1)
vtg.logExecuteBatchKeyspaceIds.Errorf("%v, query: %+v", err, query)
}
reply.Session = query.Session
return nil
}
示例13: ExecuteBatchKeyspaceIds
func (c *echoClient) ExecuteBatchKeyspaceIds(ctx context.Context, queries []proto.BoundKeyspaceIdQuery, tabletType pb.TabletType, asTransaction bool, session *proto.Session, reply *proto.QueryResultList) error {
if len(queries) > 0 && strings.HasPrefix(queries[0].Sql, EchoPrefix) {
for _, query := range queries {
reply.List = append(reply.List, *echoQueryResult(map[string]interface{}{
"callerId": callerid.EffectiveCallerIDFromContext(ctx),
"query": query.Sql,
"bindVars": query.BindVariables,
"keyspace": query.Keyspace,
"keyspaceIds": query.KeyspaceIds,
"tabletType": tabletType,
"session": session,
"asTransaction": asTransaction,
}))
}
reply.Session = session
return nil
}
return c.fallbackClient.ExecuteBatchKeyspaceIds(ctx, queries, tabletType, asTransaction, session, reply)
}
示例14: ExecuteBatchKeyspaceIds
// ExecuteBatchKeyspaceIds is part of the VTGateService interface
func (f *fakeVTGateService) ExecuteBatchKeyspaceIds(ctx context.Context, batchQuery *proto.KeyspaceIdBatchQuery, reply *proto.QueryResultList) error {
if f.panics {
panic(fmt.Errorf("test forced panic"))
}
execCase, ok := execMap[batchQuery.Queries[0].Sql]
if !ok {
return fmt.Errorf("no match for: %s", batchQuery.Queries[0].Sql)
}
if !reflect.DeepEqual(batchQuery, execCase.keyspaceIdBatchQuery) {
f.t.Errorf("Execute: %+v, want %+v", batchQuery, execCase.keyspaceIdBatchQuery)
return nil
}
reply.Error = execCase.reply.Error
if reply.Error == "" && execCase.reply.Result != nil {
reply.List = []mproto.QueryResult{*execCase.reply.Result}
}
reply.Session = execCase.reply.Session
return nil
}
示例15: ExecuteBatchShard
// ExecuteBatchShard executes a group of queries on the specified shards.
func (vtg *VTGate) ExecuteBatchShard(context interface{}, batchQuery *proto.BatchQueryShard, reply *proto.QueryResultList) error {
qrs, err := vtg.resolver.ExecuteBatch(
context,
batchQuery.Queries,
batchQuery.Keyspace,
batchQuery.TabletType,
batchQuery.Session,
func(keyspace string) ([]string, error) {
return batchQuery.Shards, nil
},
)
if err == nil {
reply.List = qrs.List
} else {
reply.Error = err.Error()
log.Errorf("ExecuteBatchShard: %v, queries: %+v", err, batchQuery)
}
reply.Session = batchQuery.Session
return nil
}