Skip to content

Instantly share code, notes, and snippets.

View mvandergrift's full-sized avatar
🔀
Share memory by communicating!

Matthew Vandergrift mvandergrift

🔀
Share memory by communicating!
View GitHub Profile
@mvandergrift
mvandergrift / initClients.go
Last active January 22, 2021 03:58
Initialize API clients to feed GO channel for consumer to process
const apiInitPause = 100 * time.Millisecond // delay between api calls to avoid triggering API flood protection
const apiInitMult = 3 // magnitude of spread between random min-max calls to client init calls
const apiUrl = "https://api.com/token=123456759"
func initClients(ctx context.Context, tickers []string, events []chan *sse.Event) {
rand.Seed(time.Now().UTC().UnixNano())
for _, v := range tickers {
apiInitPause := randInt(apiInitPause/apiInitMult, apiInitPause*apiInitMult)