(key string, value interface{})
| 7 | ) |
| 8 | |
| 9 | func (c *Client) LPush(key string, value interface{}) error { |
| 10 | client, err := newListGrpcClient(c.Addr) |
| 11 | if err != nil { |
| 12 | return errors.New("new grpc client error: " + err.Error()) |
| 13 | } |
| 14 | |
| 15 | req := &glist.GListLPushRequest{Key: key} |
| 16 | |
| 17 | switch v := value.(type) { |
| 18 | case string: |
| 19 | req.Value = &glist.GListLPushRequest_StringValue{StringValue: v} |
| 20 | case int32: |
| 21 | req.Value = &glist.GListLPushRequest_Int32Value{Int32Value: v} |
| 22 | case int64: |
| 23 | req.Value = &glist.GListLPushRequest_Int64Value{Int64Value: v} |
| 24 | case float32: |
| 25 | req.Value = &glist.GListLPushRequest_Float32Value{Float32Value: v} |
| 26 | case float64: |
| 27 | req.Value = &glist.GListLPushRequest_Float64Value{Float64Value: v} |
| 28 | case bool: |
| 29 | req.Value = &glist.GListLPushRequest_BoolValue{BoolValue: v} |
| 30 | case []byte: |
| 31 | req.Value = &glist.GListLPushRequest_BytesValue{BytesValue: v} |
| 32 | default: |
| 33 | return errors.New("unknown value type") |
| 34 | } |
| 35 | lpush, err := client.LPush(context.Background(), req) |
| 36 | if err != nil { |
| 37 | return errors.New("client LPush failed: " + err.Error()) |
| 38 | } |
| 39 | if !lpush.Ok { |
| 40 | return errors.New("LPush failed") |
| 41 | } |
| 42 | return nil |
| 43 | } |
| 44 | |
| 45 | func (c *Client) LPushs(key string, values []interface{}) error { |
| 46 | client, err := newListGrpcClient(c.Addr) |
nothing calls this directly
no test coverage detected