當前位置: 首頁>>代碼示例>>Golang>>正文


Golang QueryResultList.Err方法代碼示例

本文整理匯總了Golang中github.com/youtube/vitess/go/vt/vtgate/proto.QueryResultList.Err方法的典型用法代碼示例。如果您正苦於以下問題:Golang QueryResultList.Err方法的具體用法?Golang QueryResultList.Err怎麽用?Golang QueryResultList.Err使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/youtube/vitess/go/vt/vtgate/proto.QueryResultList的用法示例。


在下文中一共展示了QueryResultList.Err方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: 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

示例2: 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

示例3: ExecuteBatchShards

// ExecuteBatchShards executes a group of queries on the specified shards.
func (vtg *VTGate) ExecuteBatchShards(ctx context.Context, queries []proto.BoundShardQuery, tabletType pb.TabletType, asTransaction bool, session *proto.Session, reply *proto.QueryResultList) error {
	startTime := time.Now()
	statsKey := []string{"ExecuteBatchShards", "", ""}
	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
	}

	annotateBoundShardQueriesAsUnfriendly(queries)

	qrs, err := vtg.resolver.ExecuteBatch(
		ctx,
		tabletType,
		asTransaction,
		session,
		func() (*scatterBatchRequest, error) {
			return boundShardQueriesToScatterBatchRequest(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 {
		query := map[string]interface{}{
			"Queries":       queries,
			"TabletType":    strings.ToLower(tabletType.String()),
			"AsTransaction": asTransaction,
			"Session":       session,
		}
		reply.Error = handleExecuteError(err, statsKey, query, vtg.logExecuteBatchShards).Error()
		reply.Err = vterrors.RPCErrFromVtError(err)
	}
	reply.Session = session
	return nil
}
開發者ID:hadoop835,項目名稱:vitess,代碼行數:42,代碼來源:vtgate.go

示例4: AddVtGateErrorToQueryResultList

// AddVtGateErrorToQueryResultList will mutate a QueryResultList struct to fill in the Err
// field with details from the VTGate error.
func AddVtGateErrorToQueryResultList(err error, reply *proto.QueryResultList) {
	if err == nil {
		return
	}
	reply.Err = rpcErrFromVtGateError(err)
}
開發者ID:afrolovskiy,項目名稱:vitess,代碼行數:8,代碼來源:vtgate_error.go


注:本文中的github.com/youtube/vitess/go/vt/vtgate/proto.QueryResultList.Err方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。