GithubHelp home page GithubHelp logo

makiftutuncu / tweet-tracker Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 34 KB

An application for streaming tweets containing a search term on Twitter in real time for a predefined duration or number of tweets

License: MIT License

Scala 100.00%
scala scala3 streaming sttp tweets twitter zio zio-streams

tweet-tracker's Introduction

Tweet Tracker

Table of Contents

  1. Introduction
  2. Configuration
  3. Development and Testing
  4. Docker
  5. Notes
  6. Contributing
  7. License

Introduction

Tweet Tracker is a standalone application for streaming tweets containing a search term on Twitter in real time for a predefined duration or number of tweets. It is built using Scala 3.2, ZIO and sttp. It logs the tweets it's streaming as Json objects to standard output.

Configuration

Application can be configured via application.conf. You can also override config values with following environment variables.

Variable Name Data Type Description Required
TOKEN String Twitter API v2 access token Yes, otherwise defaults to change-me which won't work
SEARCH_TERM String The term to search in tweets No, defaults to crypto
FOR_SECONDS Int How long to stream tweets, in seconds No, defaults to 30
UP_TO_TWEETS Int Maximum number of tweets to stream No, defaults to 100

For log configuration, see logback.xml.

Development and Testing

Application is built with SBT. So, standard SBT tasks like clean, compile and run can be used. To run the application locally:

sbt run

Example to stream up to 50 tweets containing bitcoin for 5 seconds:

TOKEN=your-own-token SEARCH_TERM=bitcoin FOR_SECONDS=5 UP_TO_TWEETS=50 sbt run

To run automated tests, you can use test and testOnly tasks of SBT. To run all tests:

sbt test

To run specific test(s):

sbt 'testOnly fullyQualifiedTestClassName1 fullyQualifiedTestClassName2 ...'

Docker

You may also run the application in a Docker container. Environment variables mentioned in Configuration are passed to the container while building image so you don't have to pass them with -e while creating the container with docker run.

To build the Docker image:

First build an image locally with

```bash
sbt 'Docker / publishLocal'

Then start a container from generated Docker image with

docker run --rm tweet-tracker

Notes

  • The streaming only logs to standard out. They could be persisted for future use.
  • There is no statistics across multiple runs of the application, app runs for a single time, every time.

Contributing

All contributions are welcome. Please feel free to send a pull request. Thank you.

License

Tweet Tracker is licensed with MIT License.

tweet-tracker's People

Contributors

makiftutuncu avatar sytac-bot avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.