func()

in app/eventgen/generator/publishers/publishers.go [139:166]


func (pbr *publisher) run(ctx context.Context) {
	var pbrCtx context.Context
	if pbr.timeout > 0 {
		pbrCtx, pbr.cancel = context.WithTimeout(ctx, pbr.timeout)
	} else {
		pbrCtx, pbr.cancel = context.WithCancel(ctx)
	}

	// Create new thread to publish until pbrCtx done
	go func() {
		defer pbr.finish()
		log.Printf("%v: started", pbr.name)
		for {
			select {
			case <-pbrCtx.Done():
				log.Printf("%v: context done, stopped", pbr.name)
				return
			default:
				msg := pbr.newMessage()
				if id, err := pbr.Publish(ctx, msg); err != nil {
					log.Printf("%v: err: %v", pbr.name, err)
				} else {
					log.Printf("%v: published message ID: %v", pbr.name, id)
				}
			}
		}
	}()
}