{"id":22696950,"url":"https://github.com/nirovision/fs2-sqs","last_synced_at":"2025-09-10T21:10:24.863Z","repository":{"id":144110452,"uuid":"75243797","full_name":"Nirovision/fs2-sqs","owner":"Nirovision","description":"SQS using FS2","archived":false,"fork":false,"pushed_at":"2018-04-28T19:30:13.000Z","size":22,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-13T04:46:02.343Z","etag":null,"topics":["fs2","scala","sqs","stream"],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Nirovision.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-01T01:40:17.000Z","updated_at":"2018-10-28T22:33:32.000Z","dependencies_parsed_at":"2023-04-25T05:40:30.841Z","dependency_job_id":null,"html_url":"https://github.com/Nirovision/fs2-sqs","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nirovision%2Ffs2-sqs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nirovision%2Ffs2-sqs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nirovision%2Ffs2-sqs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nirovision%2Ffs2-sqs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nirovision","download_url":"https://codeload.github.com/Nirovision/fs2-sqs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665779,"owners_count":21142123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fs2","scala","sqs","stream"],"created_at":"2024-12-10T05:11:41.794Z","updated_at":"2025-04-13T04:46:08.239Z","avatar_url":"https://github.com/Nirovision.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fs2-sqs\n\n[![Build Status](https://travis-ci.org/ImageIntelligence/fs2-sqs.svg?branch=master)](https://travis-ci.org/ImageIntelligence/fs2-sqs)\n[![Download](https://api.bintray.com/packages/imageintelligence/maven/fs2-sqs/images/download.svg)](https://bintray.com/imageintelligence/maven/fs2-sqs/_latestVersion)\n\n[SQS](https://aws.amazon.com/sqs/) using [FS2](https://github.com/functional-streams-for-scala/fs2).\n\n\n## Overview\n\n- Lightweight wrapper over the raw [Java AWS SDK](https://aws.amazon.com/sdk-for-java/). Doesn't wrap the types, so you\ngain the full power of the AWS SDK and aren't forced around a leaky abstraction.\n- Unopinionated primitive building blocks.\n\n## Goals\n\n- Automatic, hands off ability to perform batching of messages to reduce costs\n- Dead lettering of failed messages\n\n## Quick examples\n\nIncluded are explicit types for the sake of clarity \n\n### Publishing messages\n\n```scala\n...\n// Construct an infinite Stream SendMessageRequest's, with the same body \"123\"\nval messageRequestsStream: Stream[Task, SendMessageRequest] =\n  Stream.constant(new SendMessageRequest(queueUrl, \"123\")).repeat\n\n// Construct a Publish pipe that can turn SendMessageRequest's into SendMessageResult's\nval publishPipe: Pipe[Task, SendMessageRequest, SendMessageResult] = FS2SQS.publishPipe(client)\n\ndef loggingSink[A]: Sink[Task, A] = { s =\u003e\n  s.map { i =\u003e\n    println(i)\n  }\n}\n\n// Compose our stream and pipe.\nval effect = messageRequestsStream\n  .through(publishPipe)\n  .to(loggingSink)\n  .onError(e =\u003e Stream.emit(println(\"Error: \" + e.getMessage)))\n\n// Lift our effect into a Task, and run it.\neffect.run.unsafeRun()\n```\n\n### Consuming messages\n\n```scala\n...\n// Construct a request to get messages from SQS\nval messageRequest = new ReceiveMessageRequest(queueUrl)\n  .withMaxNumberOfMessages(1)\n  .withWaitTimeSeconds(10)\n\n// Construct an infinite stream of Messages from SQS\nval messagesStream: Stream[Task, Message] = FS2SQS.messageStream(client, messageRequest)\n\n// A sink that can acknowledge Messages using a MessageAction\nval ackSink: Sink[Task, (Message, (Message) =\u003e MessageAction)] = FS2SQS.ackSink(client)\n\n// A pipe that either deletes or requeues the message\nval workPipe: Pipe[Task, Message, (Message, (Message) =\u003e MessageAction)] = { messages =\u003e\n  messages.map { message =\u003e\n    if (message.getBody == \"DOM\") {\n      (message, (m: Message) =\u003e Right(new DeleteMessageRequest(queueUrl, m.getReceiptHandle)))\n    } else {\n      (message, (m: Message) =\u003e Left(new SendMessageRequest(queueUrl, m.getBody)))\n    }\n  }\n}\n\n// Compose our stream, work pipe and ack sink\nval effect: Stream[Task, Unit] = messagesStream\n  .through(workPipe)\n  .through(ackSink)\n\n// Lift our effect into a Task, and run it.\neffect.run.unsafeRun()\n```\n\n\n## Pipes, Streams and Sinks\n\nThe FS2 primitives are provided in FS2SQS.scala. You can use these as building blocks around SQS. \n\n### publishPipe `Pipe[Task, SendMessageRequest, SendMessageResult]`\n\nPublishes messages to SQS.\n\n### messageStream `Stream[Task, Message]`\n\nAn infinite stream of SQS messages.\n\n### ackSink `Sink[Task, (Message, (Message =\u003e MessageAction))]`\n\nA sink that accepts functions from `Message =\u003e MessageAction`. `MessageAction` is a type alias for \n`Either[SendMessageRequest, DeleteMessageRequest]`. In other words, this sink accepts functions from `Message` to \neither a `SendMessageRequest` (for requeuing), or `DeleteMessageRequest` (for successful acknowledgement).\n\n## Installation\n\n### As a library:\n\nJust add this to your build.sbt\n\n```\n\"com.imageintelligence\" %% \"fs2-sqs\" % \"1.0.0\"\n```\n\n### As a project to work on\n\nClone the repository:\n\n```\ngit clone https://github.com/ImageIntelligence/fs2-sqs.git\n```\n\nCompile\n\n```\nsbt compile\n```\n\nTest\n\n```\nsbt test\n```\n\n## Examples:\n\nPlease see the [examples](https://github.com/imageintelligence/fs2-sqs/tree/master/src/main/scala/com/imageintelligence/fs2-sqs/examples) directory.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnirovision%2Ffs2-sqs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnirovision%2Ffs2-sqs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnirovision%2Ffs2-sqs/lists"}