当前位置: 首页>>代码示例>>Golang>>正文


Golang proto.QueryResultList类代码示例

本文整理汇总了Golang中github.com/youtube/vitess/go/vt/vtgate/proto.QueryResultList的典型用法代码示例。如果您正苦于以下问题:Golang QueryResultList类的具体用法?Golang QueryResultList怎么用?Golang QueryResultList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QueryResultList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: 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
}
开发者ID:anusornc,项目名称:vitess,代码行数:33,代码来源:vtgate.go

示例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
}
开发者ID:krast,项目名称:vitess,代码行数:27,代码来源:vtgate.go

示例3: 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
}
开发者ID:nettedfish,项目名称:vitess,代码行数:27,代码来源:vtgate.go

示例4: 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
}
开发者ID:zhzhy917,项目名称:vitess,代码行数:27,代码来源:vtgate.go

示例5: 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
}
开发者ID:ninqing,项目名称:vitess,代码行数:30,代码来源:vtgate.go

示例6: 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
}
开发者ID:chinna1986,项目名称:vitess,代码行数:31,代码来源:vtgate.go

示例7: 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
}
开发者ID:anusornc,项目名称:vitess,代码行数:28,代码来源:vtgate.go

示例8: ExecuteBatchKeyspaceIds

func (c *errorClient) ExecuteBatchKeyspaceIds(ctx context.Context, queries []proto.BoundKeyspaceIdQuery, tabletType pb.TabletType, asTransaction bool, session *proto.Session, reply *proto.QueryResultList) error {
	if len(queries) == 1 {
		if rpcErr := requestToPartialError(queries[0].Sql); rpcErr != nil {
			reply.Err = rpcErr
			reply.Error = rpcErr.Message
			return nil
		}
		if err := requestToError(queries[0].Sql); err != nil {
			return err
		}
	}
	return c.fallbackClient.ExecuteBatchKeyspaceIds(ctx, queries, tabletType, asTransaction, session, reply)
}
开发者ID:e4x,项目名称:vitess,代码行数:13,代码来源:errors.go

示例9: 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
}
开发者ID:nosix-me,项目名称:vitess,代码行数:14,代码来源:vtgate.go

示例10: 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)
}
开发者ID:zhangzzl,项目名称:vitess,代码行数:14,代码来源:errors.go

示例11: 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
}
开发者ID:rjammala,项目名称:vitess,代码行数:17,代码来源:vtgate.go

示例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
}
开发者ID:kingpro,项目名称:vitess,代码行数:19,代码来源:vtgate.go

示例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)
}
开发者ID:yinyousong,项目名称:vitess,代码行数:19,代码来源:echo.go

示例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
}
开发者ID:pranjal5215,项目名称:vitess,代码行数:20,代码来源:client.go

示例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
}
开发者ID:nosix-me,项目名称:vitess,代码行数:21,代码来源:vtgate.go


注:本文中的github.com/youtube/vitess/go/vt/vtgate/proto.QueryResultList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。