本文整理汇总了Golang中github.com/golang/protobuf/proto.Message.String方法的典型用法代码示例。如果您正苦于以下问题:Golang Message.String方法的具体用法?Golang Message.String怎么用?Golang Message.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/golang/protobuf/proto.Message
的用法示例。
在下文中一共展示了Message.String方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: event
func event(serviceName string, methodName string, request proto.Message, response proto.Message, err error, duration time.Duration) *Call {
call := &Call{
Service: serviceName,
Method: methodName,
Duration: prototime.DurationToProto(duration),
}
if request != nil {
call.Request = request.String()
}
if response != nil {
call.Response = response.String()
}
if err != nil {
call.Error = err.Error()
}
return call
}
示例2: override
func override(ctx context.Context, service, method string, in, out proto.Message) error {
stats := ctx.Value(statsKey).(*requestStats)
stats.wg.Add(1)
defer stats.wg.Done()
if service == "__go__" {
return appengine.APICall(ctx, service, method, in, out)
}
// NOTE: This limits size of stack traces to 65KiB.
b := make([]byte, 65536)
i := runtime.Stack(b, false)
stat := rpcStat{
Service: service,
Method: method,
Start: time.Now(),
Offset: time.Since(stats.Start),
StackData: string(b[0:i]),
}
err := appengine.APICall(ctx, service, method, in, out)
stat.Duration = time.Since(stat.Start)
stat.In = in.String()
stat.Out = out.String()
stat.Cost = getCost(out)
if len(stat.In) > ProtoMaxBytes {
stat.In = stat.In[:ProtoMaxBytes] + "..."
}
if len(stat.Out) > ProtoMaxBytes {
stat.Out = stat.Out[:ProtoMaxBytes] + "..."
}
stats.lock.Lock()
stats.RPCStats = append(stats.RPCStats, stat)
stats.Cost += stat.Cost
stats.lock.Unlock()
return err
}
示例3: override
func override(ctx context.Context, service, method string, in, out proto.Message) error {
stats := stats(ctx)
stats.wg.Add(1)
defer stats.wg.Done()
if service == "__go__" {
return appengine.APICall(ctx, service, method, in, out)
}
stat := rpcStat{
Service: service,
Method: method,
Start: time.Now(),
Offset: time.Since(stats.Start),
StackData: string(debug.Stack()),
}
err := appengine.APICall(ctx, service, method, in, out)
stat.Duration = time.Since(stat.Start)
stat.In = in.String()
stat.Out = out.String()
stat.Cost = getCost(out)
if len(stat.In) > ProtoMaxBytes {
stat.In = stat.In[:ProtoMaxBytes] + "..."
}
if len(stat.Out) > ProtoMaxBytes {
stat.Out = stat.Out[:ProtoMaxBytes] + "..."
}
stats.lock.Lock()
stats.RPCStats = append(stats.RPCStats, stat)
stats.Cost += stat.Cost
stats.lock.Unlock()
return err
}