Giter VIP home page Giter VIP logo

microservice-checksum's Introduction

microservice-checksum

A HTTP microservice that provides a checksum to POSTed data. POST data to it, and it will send you back a checksum.

If you have wanted to experiment with building a microservice in Rust, this might be useful as an example.

Usage

Server-side

Run the executable:

$ ROCKET_ENV=prod microservice-checksum
๐Ÿ”ง Configured for production.
    => address: 0.0.0.0
    => port: 8000
    => log: critical
    => workers: 24
    => secret key: generated
    => limits: forms = 32KiB
    => keep-alive: 5s
    => tls: disabled
Warning: environment is 'production', but no `secret_key` is configured
๐Ÿš€ Rocket has launched from http://0.0.0.0:8000

Client-side

microservice-checksum supports 3 endpoints: /crc16, /crc32, /crc64. From a new console window, you can POST data with curl via the -d option.

$ curl localhost:8000/crc32 -d 'hello?'
1619653635
$ curl localhost:8000/crc64 -d 'yes!'
6344572155291762688
$ curl localhost:8000/crc16 -d 'that was easy'
15643

(CRC16 comes last because it's the least likely to be used. Sorry CRC16.)

Custom polynomials

Each endpoint supports using custom polynomials if you wish to be specific:

CRC16

/crc16?polynomial=usb (default)

/crc16?polynomial=x25

/crc16?polynomial=n where n [0, 65,535] inclusive

CRC32

/crc16?polynomial=ieee (default)

/crc16?polynomial=castagnoli

/crc16?polynomial=koopman

/crc16?polynomial=n where n [0, 4,294,967,295] inclusive

CRC64

/crc64?polynomial=ecma (default)

/crc64?polynomial=iso

/crc64?polynomial=n where n [0, 18,446,744,073,709,551,615] inclusive

Performance

Your client should expect a response within 3ms. Usually it's closer to 1.

Build instructions

Pre-requisites

Install Rust, git (just in case) and GCC (Rust needs its linker)

sudo apt install build-essential git
curl -fsSL https://sh.rustup.rs | sh

Install microservice-checksum:

cargo install --git https://github.com/timClicks/microservice-checksum

(Optional) Generate a static binary

Install the pre-requisites

sudo apt install musl-tools 
rustup target add x86_64-unknown-linux-musl

Build the binary:

git clone https://github.com/timClicks/microservice-checksum
cd microservice-checksum
cargo build --release --target x86_64-unknown-linux-musl

Verify:

target/x86_64-unknown-linux-musl/release/microservice-checksum

Acknowledgements

I did none of the hard work for this. Please thank the maintainers of the rocket and crc crates.

microservice-checksum's People

Contributors

senden9 avatar timclicks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

microservice-checksum's Issues

Wrong musl target?

The list of supported platforms does not list a x86-unknown-linux-musl. Did you mean x86_64-unknown-linux-musl?

## (Optional) Generate a static binary
Install the pre-requisites
```
sudo apt install musl-tools
rustup target add x86-unknown-linux-musl
```
Build the binary:
```
git clone https://github.com/timClicks/microservice-checksum
cd microservice-checksum
cargo build --release --target x86-unknown-linux-musl
```
Verify:
```
target/x86-unknown-linux-musl/release/microservice-checksum
```

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.