Git Product home page Git Product logo

akka-streams-example's Introduction

scala-hashtags-akka-streams

A personal example to learn Akka Streams basics and Docker

This includes:

  • Basic example on bank accounts and web sockets taken from Paul Kinsky's intro to akka-streams
  • Blocking Twitter consumption to show Graph DSL
  • Streaming Twitter Publisher Actor pipeline on to a file
  • Akka Http streaming endpoints that consume the files from both processes
  • Tests - I couldn't get to use the akka-stream-testkit yet

Usage:

$ sbt run

will bring up a couple of main classes to run:

  • you might want to choose the Server.scala to make both endpoints (tweets and websockets) available
  • StreamingHashtags.scala to boot up a streaming processing of tweets on to a file on your /target directory
  • BlockingHashtags.scala will output both to console and to a file named interesting-tweets.txt the most recent tweets that interested me according to the file on src/resources/interesting-hashtags.txt
$ sbt test

will output some tests results, they test most of the machinery behind these examples and common Sources, Flows and Sinks.

PS: Don't forget to fill in your twitter creds in order to access the Twitter API. This is on the Twitter.scala file.

##API

  • / will pop up the bank accounts backendish frontend, if you fill in a name and an amount and click on an action you should be able to see the bank's current state if you inspect what's going on on the browser's console
  • /ws this endpoint is used by the bank accounts frontend to send the Withdraw or Deposit action through the websocket
  • /tweets/blocking will bring up the contents of a local file in your target folder. You need to run BlockingHashtags.scala before.
  • /tweets/streaming will bring up the contents of a local file in your target folder, product of running StreamingHashtags.scala

##Docker

I used the awesome sbt-docker plugin to push this project and run it as a container anywhere, free of installing Scala or sbt. Just remember to configure where to push it on the imageName field on build.sbt

$ sbt dockerBuildAndPush

should do the trick for you.

##Contributing

Feel obviously free to contribute to this project, open a pull request, or an issue and I'll be happy to address it. I've just started out with this awesome tool, constructive criticism is accepted.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.