donkey

command module
v0.0.0-...-2781dfa Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2024 License: MPL-2.0 Imports: 14 Imported by: 0

README

Donkey

env vars:

The reddit client uses 3 environment variables that I will provide in another manner

export REDDIT_CLIENT_ID=
export REDDIT_SECRET=
export REDDIT_USER_AGENT=

Usage

On first run it will prompt you to click a reddit site granting perms, and then capture the code after you allow via callback

Subsequent runs will attempt to use the existing Oauth Token.

Usage of ./donkey:
  -debug
    	enable debug mode
  -r string
    	comma-separated list of subreddits i.e. "Askreddit, music" (default "Askreddit")
    	
% ./donkey -r "AskReddit, funny, gaming, aww, music, todayilearned, movies, science, showerthoughts"
ctl + c to quit

While I store relavant data in sqlite "donkey.db" it gets purged on startup for fresh data. That file will be created if it doesn't exist.

Outputs

Debug mode will print the http request and gorm/sqlite access times and information this is a LOT of info

Every request will print information so you know its working and when a new post is found it will print information about it to screen

2024/04/09 16:58:52 Ratelimit-Used: 17, Ratelimit-Remaining: 583.0, Ratelimit-Reset: 68, URL: https://oauth.reddit.com/r/AskReddit/new.json
New Post found, PostID: 1c07ewr, Upvotes:    1 Comments:    0, Author:       MarvelsGrantMan136, Subreddit       movies, Title: ‘Super/Man: The Christopher Reeve Story’ To Hit Theaters In September

The statistics print after you hit ctl + c, if there are "ties" it will print all Author and post statistics

Assignment:

Reddit, much like other social media platforms, provides a way for users to communicate their interests etc. For this exercise, we would like to see you build an application that listens to your choice of subreddits (best to choose one with a good amount of posts). You can use this link to help identify one that interests you. We'd like to see this as a .NET 6/7 (Confirmed can be Golang, Stephen) application, and you are free to use any 3rd party libraries you would like.

Your app should consume the posts from your chosen subreddit in near real time and keep track of the following statistics between the time your application starts until it ends:

  • Posts with most up votes
  • Users with most posts

Your app should also provide some way to report these values to a user (periodically log to terminal, return from RESTful web service, etc.). If there are other interesting statistics you’d like to collect, that would be great. There is no need to store this data in a database; keeping everything in-memory is fine. That said, you should think about how you would persist data if that was a requirement.

To acquire near real time statistics from Reddit, you will need to continuously request data from Reddit's rest APIs. Reddit implements rate limiting and provides details regarding rate limit used, rate limit remaining, and rate limit reset period via response headers. Your application should use these values to control throughput in an even and consistent manner while utilizing a high percentage of the available request rate.

It’s very important that the various application processes do not block each other as Reddit can have a high volume on many of their subreddits. The app should process posts as concurrently as possible to take advantage of available computing resources. While we are only asking to track a single subreddit, you should be thinking about his you could scale up your app to handle multiple subreddits.

While designing and developing this application, you should keep SOLID principles in mind. Although this is a code challenge, we are looking for patterns that could scale and are loosely coupled to external systems / dependencies. In that same theme, there should be some level of error handling and unit testing. The submission should contain code that you would consider production ready.

When you're finished, please put your project in a repository on either GitHub or Bitbucket and send us a link. Please be sure to provide guidance as to where the Reddit API Token values are located so that the team reviewing the code can replace/configure the value. After review, we may follow-up with an interview session with questions for you about your code and the choices made in design/implementation.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL