Created
February 18, 2020 13:47
-
-
Save jackbillstrom/96f6a6731f0f259b1f6ab702fa69d4f8 to your computer and use it in GitHub Desktop.
Listen for specific message in PUB/SUB topic [golang]
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 consumer | |
import ( | |
"context" | |
"log" | |
"./gabatcher" | |
) | |
type event struct { | |
Data []byte | |
} | |
// Receive func logs an event payload | |
func Receive(ctx context.Context, e event) error { | |
switch string(e.Data) { | |
// If message in topis is == " " | |
case "start": | |
log.Printf("= Batcher initieras från start =") | |
gabatcher.Run() | |
log.Printf("OPERATION 1/3 ✔️\n") | |
default: | |
log.Printf("== default ==") | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment