Giter VIP home page Giter VIP logo

go-wasm-to-layer8-to-db's Introduction

Go-Wasm-To-Layer8-To-DB

A test project for experimenting the connection between a Go standard WASM module > Custom Load Balancer > Layer8 Slaves + DB > Content Server

Prerequisites

  • Go 1.11 or higher
  • PostgreSQL 9.6 or higher

How to run

Usage

Note: Make sure to rungo mod tidy before running the project for the first time and make a .env file with the following variables (You can change the values if you want and use your own local DB Name and Password):

LOAD_BALANCER_PORT=8000
LAYER8_SLAVE_ONE_PORT=8001
LAYER8_SLAVE_TWO_PORT=8002
LAYER8_SLAVE_THREE_PORT=8003
WASM_SERVER_PORT=9000
LAYER8_MASTER_PORT=9001
CONTENT_SERVER_PORT=9002
DB_USER=postgres
DB_PASS=
DB_NAME=
DB_HOST=localhost
DB_PORT=5432
SSL_MODE=disable
JWT_SECRET=secret

Open multiple terminals (7) and run the following commands in each:

make wasm

Note: For installing a specific version of go i.e., go 1.20.7, use the commands:

$ go install golang.org/dl/go1.20.7@latest
$ go1.20.7 download
$ go1.20.7 version
make load-balancer
make layer8-slave-one
make layer8-slave-two
make layer8-slave-three
make content-server
make layer8-master

Note: The make wasm command will generate the WASM module and run a File Server on specified Port. The make load-balancer will start a custom Load Balancer, that will serve as a proxy between WASM Module and Layer8 Slaves and distribute incoming requests equally. The make layer8-slave-one & make layer8-slave-two & make layer8-slave-three will start 3 Layer8 Slaves, that have same functionality, but different ports. The make content-server will start a Content Server, from which Layer8 Slaves will get the content and send it to the WASM module and the make layer8-master will start a Layer8 Master, from where the Slaves will get the Secret Key for JWT.

Database

Note: For first time running, you need to create a database and a table. You can do that with the following SQL Query:

CREATE TABLE IF NOT EXISTS public.users
(
    id SERIAL PRIMARY KEY NOT NULL,
    username character varying UNIQUE NOT NULL,
    password character varying NOT NULL,
    salt character varying(255),
    public_key character varying(255)
);

Running

Go to http://localhost:9000 and try Login and Register. The WASM module will send the request to the Layer8 server and the Layer8 server will send the request to the DB and return the response to the WASM module.

go-wasm-to-layer8-to-db's People

Contributors

huzaifamk 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.