func()

in internal/output/gcppubsub/gcppubsub.go [89:102]


func (o *Output) Write(b []byte) (int, error) {
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	topic := o.client.Topic(o.opts.GCPPubsubOptions.Topic)
	result := topic.Publish(ctx, &pubsub.Message{Data: b})

	// Wait for message to publish and get assigned ID.
	if _, err := result.Get(ctx); err != nil {
		return 0, err
	}

	return len(b), nil
}