| 34 | } |
| 35 | |
| 36 | func (e *Example) Get(ctx context.Context, id int64) (*Item, error) { |
| 37 | var item Item |
| 38 | eg, egCtx := errgroup.WithContext(ctx) |
| 39 | eg.Go(func() error { |
| 40 | item, err := e.storeV1.Get(egCtx, id) |
| 41 | if err != nil { |
| 42 | return fmt.Errorf("failed to get item (id: %d) from storeV1: %w", id, err) |
| 43 | } |
| 44 | |
| 45 | return nil |
| 46 | }) |
| 47 | eg.Go(func() error { |
| 48 | item, err := e.storeV2.Get(egCtx, id) |
| 49 | if err != nil { |
| 50 | return fmt.Errorf("failed to get item (id: %d) from storeV2: %w", id, err) |
| 51 | } |
| 52 | }) |
| 53 | |
| 54 | return &item, eg.Wait() |
| 55 | } |
| 56 | |
| 57 | func (e *Example) GetBatch(ctx context.Context, ids []int64) ([]*Item, error) { |
| 58 | // enable shadow read from new storage |