Created
December 13, 2020 12:41
-
-
Save RicardoLinck/41efc7f96d0f5cbcad2f2eded0f0c6a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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