(key string, value interface{})
| 130 | } |
| 131 | |
| 132 | func (c *Client) GetSet(key string, value interface{}) (interface{}, error) { |
| 133 | client, err := newGrpcClient(c.Addr) |
| 134 | if err != nil { |
| 135 | return err, nil |
| 136 | } |
| 137 | req := &gstring.GetSetRequest{ |
| 138 | Key: key, |
| 139 | } |
| 140 | |
| 141 | switch v := value.(type) { |
| 142 | case string: |
| 143 | req.Value = &gstring.GetSetRequest_StringValue{StringValue: v} |
| 144 | case int32: |
| 145 | req.Value = &gstring.GetSetRequest_Int32Value{Int32Value: v} |
| 146 | case int64: |
| 147 | req.Value = &gstring.GetSetRequest_Int64Value{Int64Value: v} |
| 148 | case float32: |
| 149 | req.Value = &gstring.GetSetRequest_Float32Value{Float32Value: v} |
| 150 | case float64: |
| 151 | req.Value = &gstring.GetSetRequest_Float64Value{Float64Value: v} |
| 152 | case bool: |
| 153 | req.Value = &gstring.GetSetRequest_BoolValue{BoolValue: v} |
| 154 | case []byte: |
| 155 | req.Value = &gstring.GetSetRequest_BytesValue{BytesValue: v} |
| 156 | default: |
| 157 | return nil, fmt.Errorf("unknown value type") |
| 158 | } |
| 159 | |
| 160 | resp, err := client.GetSet(context.Background(), req) |
| 161 | if err != nil { |
| 162 | return nil, err |
| 163 | } |
| 164 | |
| 165 | switch value := resp.Value.(type) { |
| 166 | case *gstring.GetSetResponse_StringValue: |
| 167 | return value.StringValue, nil |
| 168 | case *gstring.GetSetResponse_Int32Value: |
| 169 | return value.Int32Value, nil |
| 170 | case *gstring.GetSetResponse_Int64Value: |
| 171 | return value.Int64Value, nil |
| 172 | case *gstring.GetSetResponse_Float32Value: |
| 173 | return value.Float32Value, nil |
| 174 | case *gstring.GetSetResponse_Float64Value: |
| 175 | return value.Float64Value, nil |
| 176 | case *gstring.GetSetResponse_BoolValue: |
| 177 | return value.BoolValue, nil |
| 178 | case *gstring.GetSetResponse_BytesValue: |
| 179 | return value.BytesValue, nil |
| 180 | default: |
| 181 | return nil, fmt.Errorf("unknown response value type") |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | func (c *Client) Incr(key string) error { |
| 186 | client, err := newGrpcClient(c.Addr) |
nothing calls this directly
no test coverage detected