func greetings()

in go/showcase/pkg/showcase/part6/greetings_fn.go [37:52]


func greetings(ctx statefun.Context, message statefun.Message) error {
	var profile UserProfile
	_ = message.As(UserProfileType, &profile)

	greeting := computeGreeting(profile)
	log.Printf("GreeingsFn (instance id: %s):\t%s", ctx.Self().Id, greeting)

	ctx.SendEgress(statefun.KafkaEgressBuilder{
		Target: KafkaEgress,
		Topic:  "greetings",
		Key:    ctx.Self().Id,
		Value:  []byte(greeting),
	})

	return nil
}