本文整理汇总了Golang中github.com/pandemicsyn/oort/api/proto.TranslateError函数的典型用法代码示例。如果您正苦于以下问题:Golang TranslateError函数的具体用法?Golang TranslateError怎么用?Golang TranslateError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TranslateError函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: StreamLookupGroup
func (s *OortGroupStore) StreamLookupGroup(stream groupproto.GroupStore_StreamLookupGroupServer) error {
var resp groupproto.LookupGroupResponse
for {
req, err := stream.Recv()
if err == io.EOF {
return nil
}
if err != nil {
return err
}
resp.Reset()
resp.Rpcid = req.Rpcid
items, err := s.gs.LookupGroup(stream.Context(), req.KeyA, req.KeyB)
if err != nil {
resp.Err = proto.TranslateError(err)
} else {
for _, v := range items {
g := groupproto.LookupGroupItem{}
g.Length = v.Length
g.ChildKeyA = v.ChildKeyA
g.ChildKeyB = v.ChildKeyB
g.TimestampMicro = v.TimestampMicro
resp.Items = append(resp.Items, &g)
}
}
if err := stream.Send(&resp); err != nil {
return err
}
}
}
示例2: Delete
func (s *OortGroupStore) Delete(ctx context.Context, req *groupproto.DeleteRequest) (*groupproto.DeleteResponse, error) {
resp := groupproto.DeleteResponse{Rpcid: req.Rpcid}
var err error
resp.TimestampMicro, err = s.gs.Delete(ctx, req.KeyA, req.KeyB, req.ChildKeyA, req.ChildKeyB, req.TimestampMicro)
if err != nil {
resp.Err = proto.TranslateError(err)
}
return &resp, nil
}
示例3: Lookup
func (s *OortValueStore) Lookup(ctx context.Context, req *valueproto.LookupRequest) (*valueproto.LookupResponse, error) {
resp := valueproto.LookupResponse{Rpcid: req.Rpcid}
var err error
resp.TimestampMicro, resp.Length, err = s.vs.Lookup(ctx, req.KeyA, req.KeyB)
if err != nil {
resp.Err = proto.TranslateError(err)
}
return &resp, nil
}
示例4: LookupGroup
func (s *OortGroupStore) LookupGroup(ctx context.Context, req *groupproto.LookupGroupRequest) (*groupproto.LookupGroupResponse, error) {
resp := &groupproto.LookupGroupResponse{Rpcid: req.Rpcid}
items, err := s.gs.LookupGroup(ctx, req.KeyA, req.KeyB)
if err != nil {
resp.Err = proto.TranslateError(err)
} else {
for _, v := range items {
g := groupproto.LookupGroupItem{}
g.Length = v.Length
g.ChildKeyA = v.ChildKeyA
g.ChildKeyB = v.ChildKeyB
g.TimestampMicro = v.TimestampMicro
resp.Items = append(resp.Items, &g)
}
}
return resp, nil
}
示例5: StreamDelete
func (s *OortGroupStore) StreamDelete(stream groupproto.GroupStore_StreamDeleteServer) error {
var resp groupproto.DeleteResponse
for {
req, err := stream.Recv()
if err == io.EOF {
return nil
}
if err != nil {
return err
}
resp.Reset()
resp.Rpcid = req.Rpcid
resp.TimestampMicro, err = s.gs.Delete(stream.Context(), req.KeyA, req.KeyB, req.ChildKeyA, req.ChildKeyB, req.TimestampMicro)
if err != nil {
resp.Err = proto.TranslateError(err)
}
if err := stream.Send(&resp); err != nil {
return err
}
}
}
示例6: StreamLookup
func (s *OortValueStore) StreamLookup(stream valueproto.ValueStore_StreamLookupServer) error {
var resp valueproto.LookupResponse
for {
req, err := stream.Recv()
if err == io.EOF {
return nil
}
if err != nil {
return err
}
resp.Reset()
resp.Rpcid = req.Rpcid
resp.TimestampMicro, resp.Length, err = s.vs.Lookup(stream.Context(), req.KeyA, req.KeyB)
if err != nil {
resp.Err = proto.TranslateError(err)
}
if err := stream.Send(&resp); err != nil {
return err
}
}
}
示例7: StreamReadGroup
func (s *OortGroupStore) StreamReadGroup(stream groupproto.GroupStore_StreamReadGroupServer) error {
var resp groupproto.ReadGroupResponse
for {
req, err := stream.Recv()
if err == io.EOF {
return nil
}
if err != nil {
return err
}
resp.Reset()
resp.Rpcid = req.Rpcid
lgis, err := s.gs.LookupGroup(stream.Context(), req.KeyA, req.KeyB)
if err != nil {
resp.Err = proto.TranslateError(err)
} else {
resp.Items = make([]*groupproto.ReadGroupItem, len(lgis))
itemCount := 0
for i, lgi := range lgis {
g := groupproto.ReadGroupItem{}
g.TimestampMicro, g.Value, err = s.gs.Read(stream.Context(), req.KeyA, req.KeyB, lgi.ChildKeyA, lgi.ChildKeyB, nil)
if err != nil {
continue
}
g.ChildKeyA = lgi.ChildKeyA
g.ChildKeyB = lgi.ChildKeyB
resp.Items[i] = &g
itemCount++
}
resp.Items = resp.Items[:itemCount]
}
if err := stream.Send(&resp); err != nil {
return err
}
}
}
示例8: ReadGroup
func (s *OortGroupStore) ReadGroup(ctx context.Context, req *groupproto.ReadGroupRequest) (*groupproto.ReadGroupResponse, error) {
resp := groupproto.ReadGroupResponse{Rpcid: req.Rpcid}
lgis, err := s.gs.LookupGroup(ctx, req.KeyA, req.KeyB)
if err != nil {
resp.Err = proto.TranslateError(err)
} else {
resp.Items = make([]*groupproto.ReadGroupItem, len(lgis))
itemCount := 0
var err error
for i, lgi := range lgis {
g := &groupproto.ReadGroupItem{}
g.TimestampMicro, g.Value, err = s.gs.Read(ctx, req.KeyA, req.KeyB, lgi.ChildKeyA, lgi.ChildKeyB, nil)
if err != nil {
continue
}
g.ChildKeyA = lgi.ChildKeyA
g.ChildKeyB = lgi.ChildKeyB
resp.Items[i] = g
itemCount++
}
resp.Items = resp.Items[:itemCount]
}
return &resp, nil
}