| 201 | } |
| 202 | |
| 203 | func (l *list) LRange(ctx context.Context, req *glist.GListLRangeRequest) (*glist.GListLRangeResponse, error) { |
| 204 | // Implement the logic for the LRange gRPC method |
| 205 | listValues, err := l.dbs.LRange(req.Key, int(req.Start), int(req.Stop)) |
| 206 | if err != nil { |
| 207 | return nil, err |
| 208 | } |
| 209 | // Convert the list of values to the protobuf response format |
| 210 | resp := &glist.GListLRangeResponse{} |
| 211 | for _, val := range listValues { |
| 212 | switch v := val.(type) { |
| 213 | case string: |
| 214 | resp.Values = append(resp.Values, &glist.Value{Value: &glist.Value_StringValue{StringValue: v}}) |
| 215 | case int32: |
| 216 | resp.Values = append(resp.Values, &glist.Value{Value: &glist.Value_Int32Value{Int32Value: v}}) |
| 217 | case int64: |
| 218 | resp.Values = append(resp.Values, &glist.Value{Value: &glist.Value_Int64Value{Int64Value: v}}) |
| 219 | case float32: |
| 220 | resp.Values = append(resp.Values, &glist.Value{Value: &glist.Value_Float32Value{Float32Value: v}}) |
| 221 | case float64: |
| 222 | resp.Values = append(resp.Values, &glist.Value{Value: &glist.Value_Float64Value{Float64Value: v}}) |
| 223 | case bool: |
| 224 | resp.Values = append(resp.Values, &glist.Value{Value: &glist.Value_BoolValue{BoolValue: v}}) |
| 225 | case []byte: |
| 226 | resp.Values = append(resp.Values, &glist.Value{Value: &glist.Value_BytesValue{BytesValue: v}}) |
| 227 | } |
| 228 | |
| 229 | } |
| 230 | return resp, nil |
| 231 | } |
| 232 | |
| 233 | func (l *list) LLen(ctx context.Context, req *glist.GListLLenRequest) (*glist.GListLLenResponse, error) { |
| 234 | // Implement the logic for the LLen gRPC method |