Skip to content

Instantly share code, notes, and snippets.

@RicardoLinck
Created December 13, 2020 12:41
Show Gist options
  • Save RicardoLinck/41efc7f96d0f5cbcad2f2eded0f0c6a9 to your computer and use it in GitHub Desktop.
Save RicardoLinck/41efc7f96d0f5cbcad2f2eded0f0c6a9 to your computer and use it in GitHub Desktop.
package fetch
import (
"context"
"time"
)
type PartnerFetcher struct {
partners map[string]int
}
func NewPartnerFetcher() *PartnerFetcher {
return &PartnerFetcher{
partners: map[string]int{
"[email protected]": 20,
},
}
}
func (p *PartnerFetcher) Fetch(ctx context.Context, email string, results chan<- Result) error {
time.Sleep(time.Second)
points, ok := p.partners[email]
if ok {
results <- Result{Key: "loyalty_points", Value: points}
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment