Ejemplo n.º 1
0
func (c Context) Call(service, method string, in, out appengine_internal.ProtoMessage, opts *appengine_internal.CallOptions) error {
	c.Stats.wg.Add(1)
	defer c.Stats.wg.Done()

	if service == "__go__" {
		return c.Context.Call(service, method, in, out, opts)
	}

	stat := RPCStat{
		Service:   service,
		Method:    method,
		Start:     time.Now(),
		Offset:    time.Since(c.Stats.Start),
		StackData: string(debug.Stack()),
	}
	err := c.Context.Call(service, method, in, out, opts)
	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] + "..."
	}

	c.Stats.lock.Lock()
	c.Stats.RPCStats = append(c.Stats.RPCStats, stat)
	c.Stats.Cost += stat.Cost
	c.Stats.lock.Unlock()
	return err
}
Ejemplo n.º 2
0
func (c Context) Call(service, method string, in, out appengine_internal.ProtoMessage, opts *appengine_internal.CallOptions) (err error) {
	if c.Timer != nil && service != "__go__" {
		c.StepCustomTiming(service, method, fmt.Sprintf("%v\n\n%v", method, in.String()), func() {
			err = c.Context.Call(service, method, in, out, opts)
		})
	} else {
		err = c.Context.Call(service, method, in, out, opts)
	}
	return
}
Ejemplo n.º 3
0
func namespaceMod(m appengine_internal.ProtoMessage, namespace string) {
	// pb.Query is the only type that has a name_space field.
	// All other namespace support in datastore is in the keys.
	switch m := m.(type) {
	case *pb.Query:
		if m.NameSpace == nil {
			m.NameSpace = &namespace
		}
	}
}
Ejemplo n.º 4
0
func namespaceMod(m appengine_internal.ProtoMessage, namespace string) {
	switch m := m.(type) {
	case *pb.MemcacheDeleteRequest:
		if m.NameSpace == nil {
			m.NameSpace = &namespace
		}
	case *pb.MemcacheGetRequest:
		if m.NameSpace == nil {
			m.NameSpace = &namespace
		}
	case *pb.MemcacheIncrementRequest:
		if m.NameSpace == nil {
			m.NameSpace = &namespace
		}
	case *pb.MemcacheSetRequest:
		if m.NameSpace == nil {
			m.NameSpace = &namespace
		}
		// MemcacheFlushRequest, MemcacheStatsRequest do not apply namespace.
	}
}