Skip to content

Instantly share code, notes, and snippets.

@jackbillstrom
Created February 18, 2020 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackbillstrom/96f6a6731f0f259b1f6ab702fa69d4f8 to your computer and use it in GitHub Desktop.
Save jackbillstrom/96f6a6731f0f259b1f6ab702fa69d4f8 to your computer and use it in GitHub Desktop.
Listen for specific message in PUB/SUB topic [golang]
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