Skip to content

Commit

Permalink
Reimplement with cleaner architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
erickskrauch committed Sep 30, 2024
1 parent 8fbd295 commit 5b9666b
Show file tree
Hide file tree
Showing 17 changed files with 827 additions and 669 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- master

env:
go_version: 1.21
go_version: 1.23

jobs:
build:
Expand All @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v4

- name: Setup Go ${{ env.go_version }}
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ env.go_version }}
cache-dependency-path: go.sum
Expand All @@ -34,8 +34,24 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- id: version
name: Set up build version
run: |
if [[ $GITHUB_REF_TYPE == "tag" ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
BRANCH_NAME=${GITHUB_REF#refs/heads/}
SHORT_SHA=$(git rev-parse --short $GITHUB_SHA)
VERSION="${BRANCH_NAME}-${SHORT_SHA}"
fi
echo "### Version: $VERSION" >> $GITHUB_STEP_SUMMARY
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Build and push
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
push: true
tags: ghcr.io/${{ github.repository }}:latest
build-args: |
VERSION=${{ steps.version.outputs.version }}
COMMIT=${{ github.sha }}
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# syntax=docker/dockerfile:1

FROM golang:1.21 AS builder
FROM golang:1.23 AS builder

ARG VERSION=undefined
ARG COMMIT=unknown

COPY . /build
WORKDIR /build
Expand All @@ -9,7 +12,7 @@ RUN go mod download
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \
go build \
-trimpath \
-ldflags="-w -s" \
-ldflags="-w -s -X ely.by/sessionserver/internal/version.version=$VERSION -X ely.by/sessionserver/internal/version.commit=$COMMIT" \
-o app \
main.go

Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@
This is a "microservice" which solves PHP's inability to handle large numbers of small requests.

We faced the problem that the [endpoint for accessing player's profile by uuid](https://docs.ely.by/en/minecraft-auth.html#profile-request) become receiving a huge number of requests. For PHP, initialization of the framework, database connections and so on is more expensive than the query processing itself. So I wrote this endpoint in Go to take the load off PHP.

This project is not an example of a perfect architecture or anything else. It just does its job by being written very quickly. If I have the mood and, more importantly, the time, I will tidy up this code. But here and now it does its job and that is the most important thing.
57 changes: 40 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,33 +1,56 @@
module accounts-profiles-endpoint
module ely.by/sessionserver

go 1.21
go 1.23.0

// Main dependencies
require (
github.com/getsentry/sentry-go v0.28.0
github.com/go-sql-driver/mysql v1.7.1
github.com/julienschmidt/httprouter v1.3.0
github.com/spf13/viper v1.17.0
github.com/urfave/negroni v1.0.0
github.com/etherlabsio/healthcheck/v2 v2.0.0
github.com/getsentry/sentry-go v0.29.0
github.com/gin-gonic/gin v1.10.0
github.com/go-sql-driver/mysql v1.8.1
github.com/spf13/viper v1.19.0
go.uber.org/multierr v1.11.0
)

require (
github.com/fsnotify/fsnotify v1.6.0 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/bytedance/sonic v1.11.8 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.4 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.22.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.3.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.10.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 5b9666b

Please sign in to comment.