← ZIO SQS docs

Producer

zio.sqs.producer.Producer
See theProducer companion object
trait Producer[T]

Publishes events of type T to an SQS queue. Create an instance with Producer.make inside a Scope, then publish with the methods below.

import zio._
import zio.aws.sqs.Sqs
import zio.sqs.producer._
import zio.sqs.serialization.Serializer

def publish(queueUrl: String): ZIO[Sqs, Throwable, Unit] =
 ZIO.scoped {
   for {
     producer <- Producer.make(queueUrl, Serializer.serializeString)
     _        <- producer.produce(ProducerEvent("hello"))
   } yield ()
 }

Type parameters

T

type of the event to publish

Attributes

Companion
object
Source
Producer.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

Publishes one event.

Publishes one event.

Value parameters

e

event to produce.

Attributes

Returns

the published event. Fails with a ProducerError when SQS reports an error for the event that is not retried: either the error is not recoverable (see ProducerError.isRecoverable), or the event has used up its retryMaxCount retries. Fails with the request's error when the batch request to SQS fails as a whole.

Source
Producer.scala

Publishes a batch of events.

Publishes a batch of events.

Value parameters

es

events to publish.

Attributes

Returns

the published events, in the order they were given. Fails if any of the events fails to publish.

Source
Producer.scala

Publishes a batch of events and reports each result separately. An error that SQS reports for an event does not fail the returned task. Each such event is returned as a ProducerError on the left. Completes once every input event has either been published or has failed with an error that SQS reports for it. Fails when a batch request to SQS fails as a whole, for example on a network error.

Publishes a batch of events and reports each result separately. An error that SQS reports for an event does not fail the returned task. Each such event is returned as a ProducerError on the left. Completes once every input event has either been published or has failed with an error that SQS reports for it. Fails when a batch request to SQS fails as a whole, for example on a network error.

Value parameters

es

events to publish.

Attributes

Returns

one result per input event: the published event on the right, or a ProducerError on the left.

Source
Producer.scala
def sendSink: ZSink[Any, Throwable, Iterable[ProducerEvent[T]], Nothing, Unit]

A sink that publishes each incoming collection of events with produceBatch. Fails if an event fails to publish.

A sink that publishes each incoming collection of events with produceBatch. Fails if an event fails to publish.

Attributes

Returns

a sink for publishing.

Source
Producer.scala

A pipeline that publishes each event of the input stream and emits the published event. Fails if an event fails to publish.

A pipeline that publishes each event of the input stream and emits the published event. Fails if an event fails to publish.

import zio._
import zio.stream._
import zio.sqs.producer._

def publishAll(p: Producer[String], events: List[ProducerEvent[String]]): Task[Unit] =
 p.sendStream(ZStream.fromIterable(events)).runDrain

Attributes

Returns

a pipeline from the events to the published events.

Source
Producer.scala

A pipeline like sendStream that emits an error that SQS reports for an event as a ProducerError on the left, instead of failing. Each input event produces one ErrorOrEvent: the published event on the right, or a ProducerError on the left. The stream still fails when a batch request to SQS fails as a whole.

A pipeline like sendStream that emits an error that SQS reports for an event as a ProducerError on the left, instead of failing. Each input event produces one ErrorOrEvent: the published event on the right, or a ProducerError on the left. The stream still fails when a batch request to SQS fails as a whole.

Attributes

Returns

a pipeline from the events to their results.

Source
Producer.scala