Giter Club home page Giter Club logo

multirequest's Introduction

multirequest

This is a program in GO that makes multiple HTTP GET requests taking the URLs from a text file. The multiple requests are made concurrently using Goroutines.

How to run

Open your favorite Terminal and run this command:

go run main.go

CLI docs

The program can be run with the following options:

Usage of multirequest:
  -f string
        File path (default "urls.txt")
  -h string

for example:

go run main.go -f "./my_other_urls.txt"

or for example on Windows using the executable:

multirequest.exe -f "./my_other_urls.txt"

In case you made it, you should see something like this:

multirequest

Test

go test -v ./...

The client_test.go file contains the tests for the client.go file. Mocks valid and invalid http response, generated by using httptest.

The scanner_test.go file contains the tests for the scanner.go file. Tests the reading of the file and the parsing of the urls.

Both are tested using table driven tests.

Coverage

client and scanner files are fully covered 100% by tests.

you can check the coverage by running:

go test -cover ./...

A code coverage summary is visilbe in the cover.html file.

Some files are not covered by tests, this is because they are not part of the core logic of the program.

Build

go build

Github Actions

The github actions are defined in the test.yml file. The actions are triggered on every push, testing and building the code.

JSONL file

The results of each http connection and user action, with the timestamp of the http response code, are written into a JSONL file. This kind of format is useful for streaming data, and it is also easy to parse. It is possible to check some example logs in the example_logs_result folder.

Logging framework

Logging is handled by using Zerolog that has the best performance in the Go envirovment

HTTP testing

Mock HTTP responses are generated by using httptest

Docker

The solution is dockerized by using Docker. Build a Docker image named multirequest based on the instructions in the Dockerfile:

docker build -t multirequest .

Use the docker run command to start a Docker container from the image:

docker run -p 8080:8080 multirequest

Tech used

Contributors

Thanks goes to these wonderful people, just me for now:


Lorenzo Zaccagnini

๐Ÿ’ฌ ๐Ÿ“–

multirequest's People

Contributors

lorenzozaccagnini avatar

Stargazers

 avatar  avatar

Watchers

 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.