Skip to content

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

License

Notifications You must be signed in to change notification settings

makiftutuncu/tweet-tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages