Giter Site home page Giter Site logo

http-service-golang's Introduction

Stream HTTP Service Template (Version 2)

[Stream] Microservices REST API template using Go Fiber Framework + exception tracking by Sentry.io

Extra feature includes

  1. Object relational mapping (ORM)
  2. In-memory Caching
  3. Error exception handling
  4. Observability (tracing)

Documentation

System requirements

  • Golang 1.21
  • PostgreSQL Database 15.x
  • Redis 6

Install dependencies

go install

Update dependencies

go mod tidy

Start development server

go run .

The server will listen by default at http://localhost:8000


Build go executable file

go build -o main

Environment Variables

# App config
ENV="local"
HTTP_PORT=8000
GRPC_PORT=8001
APP_NAME="Stream - User Service"
SERVICE_NAME="user-service"

# Fiber config
FIBER_PREFORK=true
CORS_ALLOW_ORIGINS="*"
RATE_LIMIT=60

# Database config
DATABASE_HOST="localhost"
DATABASE_PORT=5432
DATABASE_NAME="postgres"
DATABASE_USER="postgres"
DATABASE_PASSWORD="mysecretpassword"
DATABASE_TIMEZONE="Asia/Bangkok"
DATABASE_MAX_IDLE_CONNS=2
DATABASE_MAX_OPEN_CONNS=3

# Redis config
REDIS_HOST="127.0.0.1"
REDIS_PORT="6379"
REDIS_USERNAME="default"
REDIS_PASSWORD=""
REDIS_CACHE_PREFIX="http-service"
REDIS_CACHE_DURATION=5

# Sentry config
SENTRY_DSN=""
SENTRY_ERROR_TRACING=false
SENTRY_TRACES_SAMPLE_RATE=0.2

# OpenTelemetry config
OTEL_EXPORTER_OTLP_ENDPOINT="localhost:4317"
OTEL_INSECURE_MODE=true

# OAuth 2.0 secrets
OAUTH_PUBLIC_KEY=""
OAUTH_PRIVATE_KEY=""

http-service-golang's People

Contributors

ruttanachote avatar

Stargazers

 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.