Sign inSign up

erpya/play-backend-rs

By erpya

•Updated about 3 years ago

A backend for play app

Image
0

513

erpya/play-backend-rs repository overview

⁠Microservice Attendance Time for Rust

A microservice that read a kafka queue for import automacically all open attendances on ADempiere

⁠Requirements

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
⁠Production Requirements
apt install pkg-config openssl libssl-dev sqlite3 libsqlite3-dev
⁠Install SQLite
apt install sqlite3
apt install libsqlite3-dev
⁠Install SQLite on Windows to use with Rust and Diesel

On Windows Diesel require "sqlite3.lib" dependency

To Generate is need follow next steps:

⁠Prerequisites
  • Choco
  • VCRedist
  • Visual studio community
  • Donwload SQLite Precompiled Binaries for Windows
  1. Install choco
  1. On cmd prompt execute
choco install vcredist-all
  1. On cmd prompt execute
choco install visualstudio2019community
  1. Add to Windows Path
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\amd64
  1. Download SQLite Precompiled Binaries for Windows
  1. Unzip file, on cmd prompt execute

lib /def:sqlite3.def /machine:X64 /out:sqlite3.lib

That will create two files

sqlite3.exp
sqlite3.lib

then these files should be copied to the following path on the project

target\debug\deps
⁠Install dielsel cli
cargo install diesel_cli --no-default-features --features sqlite
⁠Create the Database enviroment variable
echo DATABASE_URL=time_attendance.db > .env
⁠Setup diesel
diesel setup
⁠Add SQLs for Migration
diesel migration generate setup
⁠Apply all Migrations
diesel migration run
⁠For redo all Migration
diesel migration redo

⁠Getting Started

⁠Deploy with docker

You can build images using the follow command

docker build -t play-backend-rs-rs -f docker/Dockerfile .

After build just run it

docker run -d -p 7878:7878 --name play-backend-rs -e KAFKA_HOST=0.0.0.0:9092 -e KAFKA_GROUP=default KAFKA_ATTENDANCE_QUEUE="attendances" play-backend-rs-rs
⁠Environment variables
  • DB_HOST: Hostname for data base server. Default: localhost
  • DB_PORT: Port used by data base server. Default: 5432
  • DB_NAME: Database name that adempiere-middleware will use to connect with the database. Default: adempiere
  • DB_USER: Database user that adempiere-middleware will use to connect with the database. Default: adempiere
  • DB_PASSWORD: Database password that Adempiere-Backend will use to connect with the database. Default: adempiere
  • ADEMPIERE_BACKEND_ENDPOINT: Backend endpoint for all request to ADempiere, default is http://0.0.0.0:7878/entities
  • ADEMPIERE_AUTHORIZATION: Private key used for validate sign with JWT⁠, default Bearer. This throw a error if is notr setted
  • RUST_LOG: The log level for service. Default info
  • TZ: (Time Zone) Indicates the time zone to set in the nginx-based container, the default value is America/Caracas (UTC -4:00).
⁠Running project

Just build it and run

⁠Kafka reader service
cargo build
cargo run --bin admin_server
⁠Console Output

A output generated by the Arduino UNO emulator can be like it:

Server Address: "0.0.0.0:7878"
└──!NULL!
    └──attendances
        └──[POST] -> server::create_attendance

Tag summary

Content type

Image

Digest

sha256:0e637c900…

Size

94.3 MB

Last updated

about 3 years ago

docker pull erpya/play-backend-rs