Initial commit
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
# Change all vars before going to production and remove all comments (!)
|
||||
# Below all environment variables and default values
|
||||
|
||||
GRPC_PORT=50051
|
||||
GRPC_ENABLE_REFLECTION=false
|
||||
HTTP_HANDLER_ENABLE=false
|
||||
HTTP_PORT=8080
|
||||
LOG_LEVEL=info
|
||||
POSTGRES_HOST=localhost
|
||||
POSTGRES_PORT=5432
|
||||
POSTGRES_USERNAME=postgres
|
||||
POSTGRES_PASSWORD=postgres
|
||||
POSTGRES_DATABASE=postgres
|
||||
REDIS_URI=redis://localhost:6379
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
# compiled go binaries
|
||||
/bin/*
|
||||
|
||||
# gitkeep files
|
||||
!.gitkeep
|
||||
|
||||
# env files
|
||||
.env*
|
||||
!.env.template
|
||||
|
||||
.idea
|
||||
+470
@@ -0,0 +1,470 @@
|
||||
# This file is licensed under the terms of the MIT license https://opensource.org/license/mit
|
||||
# Copyright (c) 2021-2025 Marat Reymers
|
||||
|
||||
## Golden config for golangci-lint v2.5.0
|
||||
#
|
||||
# This is the best config for golangci-lint based on my experience and opinion.
|
||||
# It is very strict, but not extremely strict.
|
||||
# Feel free to adapt it to suit your needs.
|
||||
# If this config helps you, please consider keeping a link to this file (see the next comment).
|
||||
|
||||
# Based on https://gist.github.com/maratori/47a4d00457a92aa426dbd48a18776322
|
||||
|
||||
version: "2"
|
||||
|
||||
issues:
|
||||
# Maximum count of issues with the same text.
|
||||
# Set to 0 to disable.
|
||||
# Default: 3
|
||||
max-same-issues: 50
|
||||
|
||||
formatters:
|
||||
enable:
|
||||
- goimports # checks if the code and import statements are formatted according to the 'goimports' command
|
||||
- golines # checks if code is formatted, and fixes long lines
|
||||
|
||||
## you may want to enable
|
||||
#- gci # checks if code and import statements are formatted, with additional rules
|
||||
- gofmt # checks if the code is formatted according to 'gofmt' command
|
||||
#- gofumpt # enforces a stricter format than 'gofmt', while being backwards compatible
|
||||
- swaggo # formats swaggo comments
|
||||
|
||||
# All settings can be found here https://github.com/golangci/golangci-lint/blob/HEAD/.golangci.reference.yml
|
||||
settings:
|
||||
goimports:
|
||||
# A list of prefixes, which, if set, checks import paths
|
||||
# with the given prefixes are grouped after 3rd-party packages.
|
||||
# Default: []
|
||||
local-prefixes:
|
||||
- datarush
|
||||
|
||||
golines:
|
||||
# Target maximum line length.
|
||||
# Default: 100
|
||||
max-len: 120
|
||||
|
||||
linters:
|
||||
enable:
|
||||
- asasalint # checks for pass []any as any in variadic func(...any)
|
||||
- asciicheck # checks that your code does not contain non-ASCII identifiers
|
||||
- bidichk # checks for dangerous unicode character sequences
|
||||
- bodyclose # checks whether HTTP response body is closed successfully
|
||||
- canonicalheader # checks whether net/http.Header uses canonical header
|
||||
- copyloopvar # detects places where loop variables are copied (Go 1.22+)
|
||||
- cyclop # checks function and package cyclomatic complexity
|
||||
- depguard # checks if package imports are in a list of acceptable packages
|
||||
- dupl # tool for code clone detection
|
||||
- durationcheck # checks for two durations multiplied together
|
||||
- embeddedstructfieldcheck # checks embedded types in structs
|
||||
- errcheck # checking for unchecked errors, these unchecked errors can be critical bugs in some cases
|
||||
- errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
|
||||
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
|
||||
- exhaustive # checks exhaustiveness of enum switch statements
|
||||
- exptostd # detects functions from golang.org/x/exp/ that can be replaced by std functions
|
||||
- fatcontext # detects nested contexts in loops
|
||||
- forbidigo # forbids identifiers
|
||||
- funcorder # checks the order of functions, methods, and constructors
|
||||
- funlen # tool for detection of long functions
|
||||
- gocheckcompilerdirectives # validates go compiler directive comments (//go:)
|
||||
- gochecknoglobals # checks that no global variables exist
|
||||
- gochecknoinits # checks that no init functions are present in Go code
|
||||
- gochecksumtype # checks exhaustiveness on Go "sum types"
|
||||
- gocognit # computes and checks the cognitive complexity of functions
|
||||
- goconst # finds repeated strings that could be replaced by a constant
|
||||
- gocritic # provides diagnostics that check for bugs, performance and style issues
|
||||
- gocyclo # computes and checks the cyclomatic complexity of functions
|
||||
- godoclint # checks Golang's documentation practice
|
||||
- godot # checks if comments end in a period
|
||||
- gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod
|
||||
- goprintffuncname # checks that printf-like functions are named with f at the end
|
||||
- gosec # inspects source code for security problems
|
||||
- govet # reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
|
||||
- iface # checks the incorrect use of interfaces, helping developers avoid interface pollution
|
||||
- ineffassign # detects when assignments to existing variables are not used
|
||||
- intrange # finds places where for loops could make use of an integer range
|
||||
- iotamixing # checks if iotas are being used in const blocks with other non-iota declarations
|
||||
- loggercheck # checks key value pairs for common logger libraries (kitlog,klog,logr,zap)
|
||||
- makezero # finds slice declarations with non-zero initial length
|
||||
- mirror # reports wrong mirror patterns of bytes/strings usage
|
||||
- mnd # detects magic numbers
|
||||
- musttag # enforces field tags in (un)marshaled structs
|
||||
- nakedret # finds naked returns in functions greater than a specified function length
|
||||
- nestif # reports deeply nested if statements
|
||||
- nilerr # finds the code that returns nil even if it checks that the error is not nil
|
||||
- nilnesserr # reports that it checks for err != nil, but it returns a different nil value error (powered by nilness and nilerr)
|
||||
- nilnil # checks that there is no simultaneous return of nil error and an invalid value
|
||||
- noctx # finds sending http request without context.Context
|
||||
- nolintlint # reports ill-formed or insufficient nolint directives
|
||||
- nonamedreturns # reports all named returns
|
||||
- nosprintfhostport # checks for misuse of Sprintf to construct a host with port in a URL
|
||||
- perfsprint # checks that fmt.Sprintf can be replaced with a faster alternative
|
||||
- predeclared # finds code that shadows one of Go's predeclared identifiers
|
||||
- promlinter # checks Prometheus metrics naming via promlint
|
||||
- protogetter # reports direct reads from proto message fields when getters should be used
|
||||
- reassign # checks that package variables are not reassigned
|
||||
- recvcheck # checks for receiver type consistency
|
||||
- revive # fast, configurable, extensible, flexible, and beautiful linter for Go, drop-in replacement of golint
|
||||
- rowserrcheck # checks whether Err of rows is checked successfully
|
||||
- sloglint # ensure consistent code style when using log/slog
|
||||
- spancheck # checks for mistakes with OpenTelemetry/Census spans
|
||||
- sqlclosecheck # checks that sql.Rows and sql.Stmt are closed
|
||||
- staticcheck # is a go vet on steroids, applying a ton of static analysis checks
|
||||
- testableexamples # checks if examples are testable (have an expected output)
|
||||
- testifylint # checks usage of github.com/stretchr/testify
|
||||
- testpackage # makes you use a separate _test package
|
||||
- tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes
|
||||
- unconvert # removes unnecessary type conversions
|
||||
- unparam # reports unused function parameters
|
||||
- unqueryvet # detects SELECT * in SQL queries and SQL builders, encouraging explicit column selection
|
||||
- unused # checks for unused constants, variables, functions and types
|
||||
- usestdlibvars # detects the possibility to use variables/constants from the Go standard library
|
||||
- usetesting # reports uses of functions with replacement inside the testing package
|
||||
- wastedassign # finds wasted assignment statements
|
||||
- whitespace # detects leading and trailing whitespace
|
||||
|
||||
## you may want to enable
|
||||
#- arangolint # opinionated best practices for arangodb client
|
||||
#- decorder # checks declaration order and count of types, constants, variables and functions
|
||||
#- exhaustruct # [highly recommend to enable] checks if all structure fields are initialized
|
||||
#- ginkgolinter # [if you use ginkgo/gomega] enforces standards of using ginkgo and gomega
|
||||
#- godox # detects usage of FIXME, TODO and other keywords inside comments
|
||||
#- goheader # checks is file header matches to pattern
|
||||
#- inamedparam # [great idea, but too strict, need to ignore a lot of cases by default] reports interfaces with unnamed method parameters
|
||||
#- interfacebloat # checks the number of methods inside an interface
|
||||
#- ireturn # accept interfaces, return concrete types
|
||||
#- noinlineerr # disallows inline error handling `if err := ...; err != nil {`
|
||||
#- prealloc # [premature optimization, but can be used in some cases] finds slice declarations that could potentially be preallocated
|
||||
#- tagalign # checks that struct tags are well aligned
|
||||
#- varnamelen # [great idea, but too many false positives] checks that the length of a variable's name matches its scope
|
||||
#- wrapcheck # checks that errors returned from external packages are wrapped
|
||||
#- zerologlint # detects the wrong usage of zerolog that a user forgets to dispatch zerolog.Event
|
||||
|
||||
## disabled
|
||||
#- containedctx # detects struct contained context.Context field
|
||||
#- contextcheck # [too many false positives] checks the function whether use a non-inherited context
|
||||
#- dogsled # checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
|
||||
#- dupword # [useless without config] checks for duplicate words in the source code
|
||||
#- err113 # [too strict] checks the errors handling expressions
|
||||
#- errchkjson # [don't see profit + I'm against of omitting errors like in the first example https://github.com/breml/errchkjson] checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted
|
||||
#- forcetypeassert # [replaced by errcheck] finds forced type assertions
|
||||
#- gomodguard # [use more powerful depguard] allow and block lists linter for direct Go module dependencies
|
||||
#- gosmopolitan # reports certain i18n/l10n anti-patterns in your Go codebase
|
||||
#- grouper # analyzes expression groups
|
||||
#- importas # enforces consistent import aliases
|
||||
#- lll # [replaced by golines] reports long lines
|
||||
#- maintidx # measures the maintainability index of each function
|
||||
#- misspell # [useless] finds commonly misspelled English words in comments
|
||||
#- nlreturn # [too strict and mostly code is not more readable] checks for a new line before return and branch statements to increase code clarity
|
||||
#- paralleltest # [too many false positives] detects missing usage of t.Parallel() method in your Go test
|
||||
#- tagliatelle # checks the struct tags
|
||||
#- thelper # detects golang test helpers without t.Helper() call and checks the consistency of test helpers
|
||||
#- wsl # [too strict and mostly code is not more readable] whitespace linter forces you to use empty lines
|
||||
#- wsl_v5 # [too strict and mostly code is not more readable] add or remove empty lines
|
||||
|
||||
# All settings can be found here https://github.com/golangci/golangci-lint/blob/HEAD/.golangci.reference.yml
|
||||
settings:
|
||||
cyclop:
|
||||
# The maximal code complexity to report.
|
||||
# Default: 10
|
||||
max-complexity: 30
|
||||
# The maximal average package complexity.
|
||||
# If it's higher than 0.0 (float) the check is enabled.
|
||||
# Default: 0.0
|
||||
package-average: 10.0
|
||||
|
||||
depguard:
|
||||
# Rules to apply.
|
||||
#
|
||||
# Variables:
|
||||
# - File Variables
|
||||
# Use an exclamation mark `!` to negate a variable.
|
||||
# Example: `!$test` matches any file that is not a go test file.
|
||||
#
|
||||
# `$all` - matches all go files
|
||||
# `$test` - matches all go test files
|
||||
#
|
||||
# - Package Variables
|
||||
#
|
||||
# `$gostd` - matches all of go's standard library (Pulled from `GOROOT`)
|
||||
#
|
||||
# Default (applies if no custom rules are defined): Only allow $gostd in all files.
|
||||
rules:
|
||||
"deprecated":
|
||||
# List of file globs that will match this list of settings to compare against.
|
||||
# By default, if a path is relative, it is relative to the directory where the golangci-lint command is executed.
|
||||
# The placeholder '${base-path}' is substituted with a path relative to the mode defined with `run.relative-path-mode`.
|
||||
# The placeholder '${config-path}' is substituted with a path relative to the configuration file.
|
||||
# Default: $all
|
||||
files:
|
||||
- "$all"
|
||||
# List of packages that are not allowed.
|
||||
# Entries can be a variable (starting with $), a string prefix, or an exact match (if ending with $).
|
||||
# Default: []
|
||||
deny:
|
||||
- pkg: github.com/golang/protobuf
|
||||
desc: Use google.golang.org/protobuf instead, see https://developers.google.com/protocol-buffers/docs/reference/go/faq#modules
|
||||
- pkg: github.com/satori/go.uuid
|
||||
desc: Use github.com/google/uuid instead, satori's package is not maintained
|
||||
- pkg: github.com/gofrs/uuid$
|
||||
desc: Use github.com/gofrs/uuid/v5 or later, it was not a go module before v5
|
||||
"non-test files":
|
||||
files:
|
||||
- "!$test"
|
||||
deny:
|
||||
- pkg: math/rand$
|
||||
desc: Use math/rand/v2 instead, see https://go.dev/blog/randv2
|
||||
# "non-main files":
|
||||
# files:
|
||||
# - "!**/main.go"
|
||||
# deny:
|
||||
# - pkg: log$
|
||||
# desc: Use log/slog instead, see https://go.dev/blog/slog
|
||||
|
||||
embeddedstructfieldcheck:
|
||||
# Checks that sync.Mutex and sync.RWMutex are not used as embedded fields.
|
||||
# Default: false
|
||||
forbid-mutex: true
|
||||
|
||||
errcheck:
|
||||
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
|
||||
# Such cases aren't reported by default.
|
||||
# Default: false
|
||||
check-type-assertions: true
|
||||
|
||||
exhaustive:
|
||||
# Program elements to check for exhaustiveness.
|
||||
# Default: [ switch ]
|
||||
check:
|
||||
- switch
|
||||
- map
|
||||
|
||||
exhaustruct:
|
||||
# List of regular expressions to match type names that should be excluded from processing.
|
||||
# Anonymous structs can be matched by '<anonymous>' alias.
|
||||
# Has precedence over `include`.
|
||||
# Each regular expression must match the full type name, including package path.
|
||||
# For example, to match type `net/http.Cookie` regular expression should be `.*/http\.Cookie`,
|
||||
# but not `http\.Cookie`.
|
||||
# Default: []
|
||||
exclude:
|
||||
# std libs
|
||||
- ^net/http.Client$
|
||||
- ^net/http.Cookie$
|
||||
- ^net/http.Request$
|
||||
- ^net/http.Response$
|
||||
- ^net/http.Server$
|
||||
- ^net/http.Transport$
|
||||
- ^net/url.URL$
|
||||
- ^os/exec.Cmd$
|
||||
- ^reflect.StructField$
|
||||
# public libs
|
||||
- ^github.com/Shopify/sarama.Config$
|
||||
- ^github.com/Shopify/sarama.ProducerMessage$
|
||||
- ^github.com/mitchellh/mapstructure.DecoderConfig$
|
||||
- ^github.com/prometheus/client_golang/.+Opts$
|
||||
- ^github.com/spf13/cobra.Command$
|
||||
- ^github.com/spf13/cobra.CompletionOptions$
|
||||
- ^github.com/stretchr/testify/mock.Mock$
|
||||
- ^github.com/testcontainers/testcontainers-go.+Request$
|
||||
- ^github.com/testcontainers/testcontainers-go.FromDockerfile$
|
||||
- ^golang.org/x/tools/go/analysis.Analyzer$
|
||||
- ^google.golang.org/protobuf/.+Options$
|
||||
- ^gopkg.in/yaml.v3.Node$
|
||||
# Allows empty structures in return statements.
|
||||
# Default: false
|
||||
allow-empty-returns: true
|
||||
|
||||
funcorder:
|
||||
# Checks if the exported methods of a structure are placed before the non-exported ones.
|
||||
# Default: true
|
||||
struct-method: false
|
||||
|
||||
funlen:
|
||||
# Checks the number of lines in a function.
|
||||
# If lower than 0, disable the check.
|
||||
# Default: 60
|
||||
lines: 100
|
||||
# Checks the number of statements in a function.
|
||||
# If lower than 0, disable the check.
|
||||
# Default: 40
|
||||
statements: 50
|
||||
|
||||
gochecksumtype:
|
||||
# Presence of `default` case in switch statements satisfies exhaustiveness, if all members are not listed.
|
||||
# Default: true
|
||||
default-signifies-exhaustive: false
|
||||
|
||||
gocognit:
|
||||
# Minimal code complexity to report.
|
||||
# Default: 30 (but we recommend 10-20)
|
||||
min-complexity: 20
|
||||
|
||||
gocritic:
|
||||
# Settings passed to gocritic.
|
||||
# The settings key is the name of a supported gocritic checker.
|
||||
# The list of supported checkers can be found at https://go-critic.com/overview.
|
||||
settings:
|
||||
captLocal:
|
||||
# Whether to restrict checker to params only.
|
||||
# Default: true
|
||||
paramsOnly: false
|
||||
underef:
|
||||
# Whether to skip (*x).method() calls where x is a pointer receiver.
|
||||
# Default: true
|
||||
skipRecvDeref: false
|
||||
|
||||
godoclint:
|
||||
# List of rules to enable in addition to the default set.
|
||||
# Default: empty
|
||||
enable:
|
||||
# Assert no unused link in godocs.
|
||||
# https://github.com/godoc-lint/godoc-lint?tab=readme-ov-file#no-unused-link
|
||||
- no-unused-link
|
||||
|
||||
govet:
|
||||
# Enable all analyzers.
|
||||
# Default: false
|
||||
enable-all: true
|
||||
# Disable analyzers by name.
|
||||
# Run `GL_DEBUG=govet golangci-lint run --enable=govet` to see default, all available analyzers, and enabled analyzers.
|
||||
# Default: []
|
||||
disable:
|
||||
- fieldalignment # too strict
|
||||
# Settings per analyzer.
|
||||
settings:
|
||||
shadow:
|
||||
# Whether to be strict about shadowing; can be noisy.
|
||||
# Default: false
|
||||
strict: false
|
||||
|
||||
inamedparam:
|
||||
# Skips check for interface methods with only a single parameter.
|
||||
# Default: false
|
||||
skip-single-param: true
|
||||
|
||||
mnd:
|
||||
# List of function patterns to exclude from analysis.
|
||||
# Values always ignored: `time.Date`,
|
||||
# `strconv.FormatInt`, `strconv.FormatUint`, `strconv.FormatFloat`,
|
||||
# `strconv.ParseInt`, `strconv.ParseUint`, `strconv.ParseFloat`.
|
||||
# Default: []
|
||||
ignored-functions:
|
||||
- args.Error
|
||||
- flag.Arg
|
||||
- flag.Duration.*
|
||||
- flag.Float.*
|
||||
- flag.Int.*
|
||||
- flag.Uint.*
|
||||
- os.Chmod
|
||||
- os.Mkdir.*
|
||||
- os.OpenFile
|
||||
- os.WriteFile
|
||||
- prometheus.ExponentialBuckets.*
|
||||
- prometheus.LinearBuckets
|
||||
|
||||
nakedret:
|
||||
# Make an issue if func has more lines of code than this setting, and it has naked returns.
|
||||
# Default: 30
|
||||
max-func-lines: 0
|
||||
|
||||
nolintlint:
|
||||
# Exclude following linters from requiring an explanation.
|
||||
# Default: []
|
||||
allow-no-explanation: [ funlen, gocognit, golines ]
|
||||
# Enable to require an explanation of nonzero length after each nolint directive.
|
||||
# Default: false
|
||||
require-explanation: true
|
||||
# Enable to require nolint directives to mention the specific linter being suppressed.
|
||||
# Default: false
|
||||
require-specific: true
|
||||
|
||||
perfsprint:
|
||||
# Optimizes into strings concatenation.
|
||||
# Default: true
|
||||
strconcat: false
|
||||
|
||||
reassign:
|
||||
# Patterns for global variable names that are checked for reassignment.
|
||||
# See https://github.com/curioswitch/go-reassign#usage
|
||||
# Default: ["EOF", "Err.*"]
|
||||
patterns:
|
||||
- ".*"
|
||||
|
||||
rowserrcheck:
|
||||
# database/sql is always checked.
|
||||
# Default: []
|
||||
packages:
|
||||
- github.com/jmoiron/sqlx
|
||||
|
||||
sloglint:
|
||||
# Enforce not using global loggers.
|
||||
# Values:
|
||||
# - "": disabled
|
||||
# - "all": report all global loggers
|
||||
# - "default": report only the default slog logger
|
||||
# https://github.com/go-simpler/sloglint?tab=readme-ov-file#no-global
|
||||
# Default: ""
|
||||
no-global: all
|
||||
# Enforce using methods that accept a context.
|
||||
# Values:
|
||||
# - "": disabled
|
||||
# - "all": report all contextless calls
|
||||
# - "scope": report only if a context exists in the scope of the outermost function
|
||||
# https://github.com/go-simpler/sloglint?tab=readme-ov-file#context-only
|
||||
# Default: ""
|
||||
context: scope
|
||||
|
||||
staticcheck:
|
||||
# SAxxxx checks in https://staticcheck.dev/docs/configuration/options/#checks
|
||||
# Example (to disable some checks): [ "all", "-SA1000", "-SA1001"]
|
||||
# Default: ["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022"]
|
||||
checks:
|
||||
- all
|
||||
# Incorrect or missing package comment.
|
||||
# https://staticcheck.dev/docs/checks/#ST1000
|
||||
- -ST1000
|
||||
# Use consistent method receiver names.
|
||||
# https://staticcheck.dev/docs/checks/#ST1016
|
||||
- -ST1016
|
||||
# Omit embedded fields from selector expression.
|
||||
# https://staticcheck.dev/docs/checks/#QF1008
|
||||
- -QF1008
|
||||
|
||||
usetesting:
|
||||
# Enable/disable `os.TempDir()` detections.
|
||||
# Default: false
|
||||
os-temp-dir: true
|
||||
|
||||
exclusions:
|
||||
# Log a warning if an exclusion rule is unused.
|
||||
# Default: false
|
||||
warn-unused: true
|
||||
# Predefined exclusion rules.
|
||||
# Default: []
|
||||
presets:
|
||||
- std-error-handling
|
||||
- common-false-positives
|
||||
# Excluding configuration per-path, per-linter, per-text and per-source.
|
||||
rules:
|
||||
- source: 'TODO'
|
||||
linters: [ godot ]
|
||||
- text: 'should have a package comment'
|
||||
linters: [ revive ]
|
||||
- text: 'exported \S+ \S+ should have comment( \(or a comment on this block\))? or be unexported'
|
||||
linters: [ revive ]
|
||||
- text: 'package comment should be of the form ".+"'
|
||||
source: '// ?(nolint|TODO)'
|
||||
linters: [ revive ]
|
||||
- text: 'comment on exported \S+ \S+ should be of the form ".+"'
|
||||
source: '// ?(nolint|TODO)'
|
||||
linters: [ revive, staticcheck ]
|
||||
- path: '_test\.go'
|
||||
linters:
|
||||
- bodyclose
|
||||
- dupl
|
||||
- errcheck
|
||||
- funlen
|
||||
- goconst
|
||||
- gosec
|
||||
- noctx
|
||||
- wrapcheck
|
||||
@@ -0,0 +1,56 @@
|
||||
ARG GOARCH=amd64
|
||||
ARG GOOS=linux
|
||||
ARG CGO_ENABLED=0
|
||||
ARG VERSION=1.0.0
|
||||
ARG BUILD_TIME=unknown
|
||||
|
||||
# Stage 1: Build
|
||||
FROM docker.io/golang:1.24-alpine AS build
|
||||
|
||||
ARG GOOS
|
||||
ARG GOARCH
|
||||
ARG CGO_ENABLED
|
||||
ARG VERSION
|
||||
ARG BUILD_TIME
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN CGO_ENABLED=${CGO_ENABLED} \
|
||||
GOOS=${GOOS} \
|
||||
GOARCH=${GOARCH} \
|
||||
go build -trimpath \
|
||||
-ldflags="-s -w -X 'main.Version=${VERSION}' -X 'main.BuildTime=${BUILD_TIME}'" \
|
||||
-o /bin/app ./cmd/server
|
||||
|
||||
# Stage 2: Runtime
|
||||
FROM docker.io/alpine:3.22 AS runtime
|
||||
|
||||
ARG VERSION
|
||||
ARG BUILD_TIME
|
||||
|
||||
RUN addgroup -S app && adduser -S -G app app
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=build /bin/app /app/bin
|
||||
|
||||
RUN chown app:app /app/bin && chmod +x /app/bin
|
||||
|
||||
USER app
|
||||
|
||||
EXPOSE 8080 50051
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
||||
CMD wget -qO- --timeout=2 http://127.0.0.1:8080/health || exit 1
|
||||
|
||||
LABEL org.opencontainers.image.version=${VERSION}
|
||||
LABEL org.opencontainers.image.created=${BUILD_TIME}
|
||||
|
||||
ENTRYPOINT ["/app/bin"]
|
||||
|
||||
CMD [""]
|
||||
@@ -0,0 +1,51 @@
|
||||
ARG GOARCH=amd64
|
||||
ARG GOOS=linux
|
||||
ARG CGO_ENABLED=0
|
||||
ARG VERSION=1.0.0
|
||||
ARG BUILD_TIME=unknown
|
||||
|
||||
# Stage 1: Build
|
||||
FROM docker.io/golang:1.24-alpine AS build
|
||||
|
||||
ARG GOOS
|
||||
ARG GOARCH
|
||||
ARG CGO_ENABLED
|
||||
ARG VERSION
|
||||
ARG BUILD_TIME
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN CGO_ENABLED=${CGO_ENABLED} \
|
||||
GOOS=${GOOS} \
|
||||
GOARCH=${GOARCH} \
|
||||
go build -trimpath \
|
||||
-ldflags="-s -w -X 'main.Version=${VERSION}' -X 'main.BuildTime=${BUILD_TIME}'" \
|
||||
-o /bin/app ./cmd/migrate
|
||||
|
||||
# Stage 2: Runtime
|
||||
FROM docker.io/alpine:3.22 AS runtime
|
||||
|
||||
ARG VERSION
|
||||
ARG BUILD_TIME
|
||||
|
||||
RUN addgroup -S app && adduser -S -G app app
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=build /bin/app /app/bin
|
||||
|
||||
RUN chown app:app /app/bin && chmod +x /app/bin
|
||||
|
||||
USER app
|
||||
|
||||
LABEL org.opencontainers.image.version=${VERSION}
|
||||
LABEL org.opencontainers.image.created=${BUILD_TIME}
|
||||
|
||||
ENTRYPOINT ["/app/bin"]
|
||||
|
||||
CMD [""]
|
||||
@@ -0,0 +1,86 @@
|
||||
# Go parameters
|
||||
GOCMD=go
|
||||
GOBUILD=$(GOCMD) build -trimpath -ldflags="-s -w"
|
||||
GOTEST=$(GOCMD) test
|
||||
GODOWNLOAD=$(GOCMD) mod download
|
||||
BINARY_NAME=datarush
|
||||
MIGRATE_BINARY_NAME=datarush-migrate
|
||||
BINARY_DIR=bin
|
||||
|
||||
# Protobuf parameters
|
||||
PROTOC=protoc
|
||||
PROTO_DIR=api/proto
|
||||
PROTO_FILE=$(PROTO_DIR)/auth.proto $(PROTO_DIR)/competition.proto $(PROTO_DIR)/task.proto
|
||||
PROTO_OUT=.
|
||||
|
||||
.PHONY: install i generate gen generate-gw test build run migrate lint fmt format clean help
|
||||
|
||||
install:
|
||||
$(GODOWNLOAD)
|
||||
|
||||
i: install
|
||||
|
||||
generate:
|
||||
$(PROTOC) --version || (echo "protoc not found, install protoc"; exit 1)
|
||||
$(PROTOC) --go_out=$(PROTO_OUT) --go-grpc_out=$(PROTO_OUT) \
|
||||
$(PROTO_FILE)
|
||||
|
||||
gen: generate
|
||||
|
||||
generate-gw:
|
||||
$(PROTOC) --version || (echo "protoc not found, install protoc"; exit 1)
|
||||
$(PROTOC) --grpc-gateway_out=$(PROTO_OUT) --grpc-gateway_opt generate_unbound_methods=true \
|
||||
$(PROTO_FILE)
|
||||
|
||||
test:
|
||||
$(GOTEST) ./...
|
||||
|
||||
build:
|
||||
$(GOBUILD) -o ./$(BINARY_DIR)/$(BINARY_NAME) ./cmd/server
|
||||
chmod +x ./$(BINARY_DIR)/$(BINARY_NAME)
|
||||
|
||||
build-migrate:
|
||||
$(GOBUILD) -o ./$(BINARY_DIR)/$(MIGRATE_BINARY_NAME) ./cmd/migrate
|
||||
chmod +x ./$(BINARY_DIR)/$(MIGRATE_BINARY_NAME)
|
||||
|
||||
run: build
|
||||
./$(BINARY_DIR)/$(BINARY_NAME)
|
||||
|
||||
migrate: build-migrate
|
||||
@cmd=$(word 2,$(MAKECMDGOALS)); \
|
||||
if [ -z "$$cmd" ]; then \
|
||||
echo "Usage: make migrate <command>"; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
./$(BINARY_DIR)/$(MIGRATE_BINARY_NAME) -cmd $$cmd
|
||||
|
||||
lint:
|
||||
golangci-lint run -c .golangci.yaml ./...
|
||||
|
||||
fmt:
|
||||
golangci-lint fmt -c .golangci.yaml ./...
|
||||
|
||||
format: fmt
|
||||
|
||||
clean:
|
||||
rm -rf bin/*
|
||||
|
||||
help:
|
||||
@echo "Available commands:"
|
||||
@echo " install - Install all deps using go mod download"
|
||||
@echo " i"
|
||||
@echo " generate - Generate gRPC code"
|
||||
@echo " gen"
|
||||
@echo " protoc"
|
||||
@echo " test - Run tests"
|
||||
@echo " build - Build the binary"
|
||||
@echo " run - Run the application"
|
||||
@echo " lint - Run golangci-lint linter"
|
||||
@echo " format - Run golangci-lint formatter"
|
||||
@echo " fmt"
|
||||
@echo " clean - Clean build artifacts"
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
%:
|
||||
@:
|
||||
@@ -1,93 +1,61 @@
|
||||
# Datarush Go
|
||||
# Order service
|
||||
|
||||
Golang microservice to manage orders.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
## Getting started
|
||||
Ensure you have the following installed on your system:
|
||||
|
||||
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
||||
|
||||
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
||||
|
||||
## Add your files
|
||||
|
||||
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
||||
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
||||
|
||||
```
|
||||
cd existing_repo
|
||||
git remote add origin https://gitlab.crja72.ru/9-go/datarush-go.git
|
||||
git branch -M main
|
||||
git push -uf origin main
|
||||
```
|
||||
|
||||
## Integrate with your tools
|
||||
|
||||
- [ ] [Set up project integrations](https://gitlab.crja72.ru/9-go/datarush-go/-/settings/integrations)
|
||||
|
||||
## Collaborate with your team
|
||||
|
||||
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
||||
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
||||
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
||||
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
||||
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
||||
|
||||
## Test and Deploy
|
||||
|
||||
Use the built-in continuous integration in GitLab.
|
||||
|
||||
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
||||
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
||||
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
||||
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
||||
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
||||
|
||||
***
|
||||
|
||||
# Editing this README
|
||||
|
||||
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
||||
|
||||
## Suggestions for a good README
|
||||
|
||||
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
||||
|
||||
## Name
|
||||
Choose a self-explaining name for your project.
|
||||
|
||||
## Description
|
||||
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
||||
|
||||
## Badges
|
||||
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
||||
|
||||
## Visuals
|
||||
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
||||
- Golang (>=1.24)
|
||||
- protoc (Protocol Buffers compiler)
|
||||
- make (latest version recommended)
|
||||
|
||||
## Installation
|
||||
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
||||
|
||||
## Usage
|
||||
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
||||
### 1. Clone the project
|
||||
|
||||
## Support
|
||||
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
||||
### 2. Go to the project directory
|
||||
|
||||
## Roadmap
|
||||
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
||||
### 3. Install dependencies
|
||||
|
||||
## Contributing
|
||||
State if you are open to contributions and what your requirements are for accepting them.
|
||||
```bash
|
||||
make i
|
||||
```
|
||||
|
||||
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
||||
### 4. Customize environment
|
||||
|
||||
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
## Authors and acknowledgment
|
||||
Show your appreciation to those who have contributed to the project.
|
||||
And setup env vars according to your needs.
|
||||
|
||||
## License
|
||||
For open source projects, say how it is licensed.
|
||||
## Configuration
|
||||
|
||||
## Project status
|
||||
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
||||
```bash
|
||||
GRPC_PORT=50051 # gRPC server port
|
||||
GRPC_ENABLE_REFLECTION=false # whether to enable gRPC reflection or not
|
||||
HTTP_HANDLER_ENABLE=false # whether to enable HTTP gateway or not
|
||||
HTTP_PORT=8080 # HTTP gateway port
|
||||
LOG_LEVEL=info # logging severity (debug, info, warn, error)
|
||||
```
|
||||
|
||||
## Running
|
||||
|
||||
### Build + run
|
||||
|
||||
```bash
|
||||
make run
|
||||
```
|
||||
|
||||
### Build
|
||||
|
||||
```bash
|
||||
make build
|
||||
```
|
||||
|
||||
### gRPC code generation
|
||||
|
||||
```bash
|
||||
make generate
|
||||
```
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
syntax = "proto3";
|
||||
package auth;
|
||||
|
||||
option go_package = "pkg/api/auth";
|
||||
|
||||
service AuthService {
|
||||
rpc SignUp(SignUpRequest) returns (SignUpResponse);
|
||||
rpc SignIn(SignInRequest) returns (SignInResponse);
|
||||
rpc GetMe(GetMeRequest) returns (GetMeResponse);
|
||||
rpc GetUser(GetUserRequest) returns (GetUserResponse);
|
||||
rpc GetMyStat(GetMyStatRequest) returns (GetMyStatResponse);
|
||||
rpc GetLeaderboard(GetLeaderboardRequest) returns (GetLeaderboardResponse);
|
||||
}
|
||||
|
||||
message SignUpRequest {
|
||||
string email = 1;
|
||||
string username = 2;
|
||||
string password = 3;
|
||||
}
|
||||
message SignUpResponse {
|
||||
string token = 1;
|
||||
}
|
||||
|
||||
message SignInRequest {
|
||||
string email = 1;
|
||||
string password = 2;
|
||||
}
|
||||
message SignInResponse {
|
||||
string token = 1;
|
||||
}
|
||||
|
||||
message GetMeRequest {}
|
||||
message GetMeResponse {
|
||||
User user = 1;
|
||||
}
|
||||
|
||||
message GetUserRequest {
|
||||
string user_id = 1;
|
||||
}
|
||||
message GetUserResponse {
|
||||
User user = 1;
|
||||
}
|
||||
|
||||
message GetMyStatRequest {}
|
||||
message GetMyStatResponse {
|
||||
Stat stat = 1;
|
||||
}
|
||||
|
||||
message GetLeaderboardRequest {}
|
||||
message GetLeaderboardResponse {
|
||||
repeated User users = 1;
|
||||
}
|
||||
|
||||
message User {
|
||||
optional string id = 1;
|
||||
string email = 2;
|
||||
string username = 3;
|
||||
optional string avatar = 4;
|
||||
string created_at = 5;
|
||||
repeated UserAchievement achievements = 6;
|
||||
}
|
||||
|
||||
message UserAchievement {
|
||||
string name = 1;
|
||||
string description = 2;
|
||||
string icon = 3;
|
||||
string received_at = 4;
|
||||
}
|
||||
|
||||
message Stat {
|
||||
int32 total_attempts = 1;
|
||||
int32 solved_tasks = 2;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
syntax = "proto3";
|
||||
package competition;
|
||||
|
||||
option go_package = "pkg/api/competition";
|
||||
|
||||
service CompetitionService {
|
||||
rpc GetCompetition(GetCompetitionRequest) returns (GetCompetitionResponse);
|
||||
rpc ListCompetitions(ListCompetitionsRequest) returns (ListCompetitionsResponse);
|
||||
rpc ChangeCompetitionState(ChangeCompetitionStateRequest) returns (ChangeCompetitionStateResponse);
|
||||
}
|
||||
|
||||
message GetCompetitionRequest {
|
||||
string competition_id = 1;
|
||||
}
|
||||
message GetCompetitionResponse {
|
||||
Competition competition = 1;
|
||||
}
|
||||
|
||||
message ListCompetitionsRequest {
|
||||
bool is_participating = 1;
|
||||
}
|
||||
message ListCompetitionsResponse {
|
||||
repeated Competition competitions = 1;
|
||||
}
|
||||
|
||||
message ChangeCompetitionStateRequest {
|
||||
string competition_id = 1;
|
||||
CompetitionState state = 2;
|
||||
}
|
||||
message ChangeCompetitionStateResponse {
|
||||
CompetitionState state = 1;
|
||||
}
|
||||
|
||||
message Competition {
|
||||
string id = 1;
|
||||
CompetitionState state = 2;
|
||||
string title = 3;
|
||||
string description = 4;
|
||||
optional string image_url = 5;
|
||||
optional string end_date = 6;
|
||||
optional string start_date = 7;
|
||||
string type = 8;
|
||||
string participation_type = 9;
|
||||
}
|
||||
|
||||
enum CompetitionState {
|
||||
COMPETITION_STATE_UNSPECIFIED = 0;
|
||||
COMPETITION_STATE_NOT_STARTED = 1;
|
||||
COMPETITION_STATE_STARTED = 2;
|
||||
COMPETITION_STATE_FINISHED = 3;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
syntax = "proto3";
|
||||
package task;
|
||||
|
||||
option go_package = "pkg/api/task";
|
||||
|
||||
service TaskService {
|
||||
rpc StartCompetition(StartCompetitionRequest) returns (StartCompetitionResponse);
|
||||
rpc GetCompetitionTasks(GetCompetitionTasksRequest) returns (GetCompetitionTasksResponse);
|
||||
rpc GetTask(GetTaskRequest) returns (GetTaskResponse);
|
||||
rpc SubmitTask(SubmitTaskRequest) returns (SubmitTaskResponse);
|
||||
rpc GetSubmissionsHistory(GetSubmissionsHistoryRequest) returns (GetSubmissionsHistoryResponse);
|
||||
rpc GetTaskAttachments(GetTaskAttachmentsRequest) returns (GetTaskAttachmentsResponse);
|
||||
rpc GetCompetitionResults(GetCompetitionResultsRequest) returns (GetCompetitionResultsResponse);
|
||||
}
|
||||
|
||||
message StartCompetitionRequest {
|
||||
string competition_id = 1;
|
||||
}
|
||||
message StartCompetitionResponse {
|
||||
string status = 1;
|
||||
}
|
||||
|
||||
message GetCompetitionTasksRequest {
|
||||
string competition_id = 1;
|
||||
}
|
||||
message GetCompetitionTasksResponse {
|
||||
repeated Task tasks = 1;
|
||||
}
|
||||
|
||||
message GetTaskRequest {
|
||||
string competition_id = 1;
|
||||
string task_id = 2;
|
||||
}
|
||||
message GetTaskResponse {
|
||||
Task task = 1;
|
||||
}
|
||||
|
||||
message SubmitTaskRequest {
|
||||
string competition_id = 1;
|
||||
string task_id = 2;
|
||||
bytes content = 3;
|
||||
}
|
||||
message SubmitTaskResponse {
|
||||
string submission_id = 1;
|
||||
}
|
||||
|
||||
message GetSubmissionsHistoryRequest {
|
||||
string competition_id = 1;
|
||||
string task_id = 2;
|
||||
}
|
||||
message GetSubmissionsHistoryResponse {
|
||||
repeated HistorySubmission submissions = 1;
|
||||
}
|
||||
|
||||
message GetTaskAttachmentsRequest {
|
||||
string competition_id = 1;
|
||||
string task_id = 2;
|
||||
}
|
||||
message GetTaskAttachmentsResponse {
|
||||
repeated TaskAttachment attachments = 1;
|
||||
}
|
||||
|
||||
message GetCompetitionResultsRequest {
|
||||
string competition_id = 1;
|
||||
}
|
||||
message GetCompetitionResultsResponse {
|
||||
repeated TaskStatus results = 1;
|
||||
}
|
||||
|
||||
message Task {
|
||||
optional string id = 1;
|
||||
string competition = 2;
|
||||
string title = 3;
|
||||
string description = 4;
|
||||
int32 in_competition_position = 5;
|
||||
optional int32 points = 6;
|
||||
optional int32 max_attempts = 7;
|
||||
TaskType type = 8;
|
||||
TaskStatusEnum status = 9;
|
||||
}
|
||||
|
||||
enum TaskType {
|
||||
TASK_TYPE_UNSPECIFIED = 0;
|
||||
TASK_TYPE_INPUT = 1;
|
||||
TASK_TYPE_CHECKER = 2;
|
||||
TASK_TYPE_REVIEW = 3;
|
||||
}
|
||||
|
||||
enum TaskStatusEnum {
|
||||
TASK_STATUS_UNSPECIFIED = 0;
|
||||
TASK_STATUS_NOT_SUBMITTED = 1;
|
||||
TASK_STATUS_SENT = 2;
|
||||
TASK_STATUS_CHECKING = 3;
|
||||
TASK_STATUS_CHECKED = 4;
|
||||
}
|
||||
|
||||
message HistorySubmission {
|
||||
optional string id = 1;
|
||||
TaskStatusEnum status = 2;
|
||||
optional int32 earned_points = 3;
|
||||
string timestamp = 4;
|
||||
string content = 5;
|
||||
}
|
||||
|
||||
message TaskAttachment {
|
||||
optional string id = 1;
|
||||
string file = 2;
|
||||
bool public = 3;
|
||||
}
|
||||
|
||||
message TaskStatus {
|
||||
string task_name = 1;
|
||||
int32 result = 2;
|
||||
int32 max_points = 3;
|
||||
int32 position = 4;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"embed"
|
||||
"errors"
|
||||
"flag"
|
||||
"log"
|
||||
|
||||
"datarush/internal/lms/config"
|
||||
|
||||
"github.com/golang-migrate/migrate/v4"
|
||||
"github.com/golang-migrate/migrate/v4/database/postgres"
|
||||
"github.com/golang-migrate/migrate/v4/source/iofs"
|
||||
)
|
||||
|
||||
//go:embed migrations/*.sql
|
||||
var migrationsFS embed.FS
|
||||
|
||||
func main() {
|
||||
var cmd string
|
||||
|
||||
flag.StringVar(&cmd, "cmd", "up", "migration command: up|down|force|version")
|
||||
flag.Parse()
|
||||
|
||||
cfg, err := config.Load()
|
||||
if err != nil {
|
||||
log.Fatalf("failed to load config: %v", err)
|
||||
}
|
||||
|
||||
db, err := sql.Open("postgres", cfg.BuildPostgresDSN())
|
||||
if err != nil {
|
||||
log.Fatalf("open db: %v", err)
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
drv, err := postgres.WithInstance(db, &postgres.Config{})
|
||||
if err != nil {
|
||||
log.Printf("postgres driver: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
src, err := iofs.New(migrationsFS, "migrations")
|
||||
if err != nil {
|
||||
log.Printf("iofs source: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
m, err := migrate.NewWithInstance("iofs", src, "postgres", drv)
|
||||
if err != nil {
|
||||
log.Printf("migrate NewWithInstance: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
switch cmd {
|
||||
case "up":
|
||||
if err := m.Up(); err != nil && !errors.Is(err, migrate.ErrNoChange) {
|
||||
log.Printf("m.Up failed: %v", err)
|
||||
return
|
||||
}
|
||||
log.Println("migrations applied (up)")
|
||||
case "down":
|
||||
if err := m.Steps(-1); err != nil {
|
||||
log.Printf("m.Steps(-1) failed: %v", err)
|
||||
return
|
||||
}
|
||||
log.Println("stepped down 1 migration")
|
||||
case "version":
|
||||
v, dirty, verr := m.Version()
|
||||
if verr != nil {
|
||||
log.Printf("version: %v", verr)
|
||||
return
|
||||
}
|
||||
log.Printf("version: %d dirty: %v\n", v, dirty)
|
||||
default:
|
||||
log.Printf("unknown cmd: %s", cmd)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
drop table if exists orders;
|
||||
@@ -0,0 +1,5 @@
|
||||
create table if not exists orders (
|
||||
id uuid primary key,
|
||||
item varchar(500) not null,
|
||||
quantity integer not null check (quantity > 0)
|
||||
);
|
||||
@@ -0,0 +1,35 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"datarush/internal/lms/config"
|
||||
"datarush/internal/lms/server"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cfg, err := config.Load()
|
||||
if err != nil {
|
||||
log.Fatalf("failed to load config: %v", err)
|
||||
}
|
||||
|
||||
srv := server.New(cfg)
|
||||
srv.RegisterServices()
|
||||
|
||||
go func() {
|
||||
if err := srv.Start(); err != nil {
|
||||
log.Fatalf("failed to start server: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
quit := make(chan os.Signal, 1)
|
||||
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
||||
<-quit
|
||||
|
||||
log.Println("shutting down server...")
|
||||
srv.Stop()
|
||||
log.Println("server stopped")
|
||||
}
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
name: order
|
||||
|
||||
services:
|
||||
core:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Containerfile
|
||||
depends_on:
|
||||
migrate:
|
||||
restart: false
|
||||
condition: service_completed_successfully
|
||||
required: true
|
||||
postgres:
|
||||
restart: false
|
||||
condition: service_healthy
|
||||
required: true
|
||||
redis:
|
||||
restart: false
|
||||
condition: service_healthy
|
||||
required: true
|
||||
env_file:
|
||||
- path: ./infrastructure/core/.env.template
|
||||
required: true
|
||||
- path: ./infrastructure/core/.env
|
||||
ports:
|
||||
- name: http
|
||||
target: 8080
|
||||
published: 13440
|
||||
host_ip: 127.0.0.1
|
||||
protocol: tcp
|
||||
app_protocol: http
|
||||
- name: grpc
|
||||
target: 50051
|
||||
published: 13441
|
||||
host_ip: 127.0.0.1
|
||||
protocol: tcp
|
||||
app_protocol: http
|
||||
networks:
|
||||
- default
|
||||
restart: unless-stopped
|
||||
shm_size: 4mb
|
||||
|
||||
migrate:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Containerfile.migrate
|
||||
depends_on:
|
||||
postgres:
|
||||
restart: false
|
||||
condition: service_healthy
|
||||
required: true
|
||||
env_file:
|
||||
- path: ./infrastructure/core/.env.template
|
||||
required: true
|
||||
- path: ./infrastructure/core/.env
|
||||
networks:
|
||||
- default
|
||||
restart: no
|
||||
shm_size: 4mb
|
||||
|
||||
postgres:
|
||||
image: docker.io/postgres:17-alpine
|
||||
configs:
|
||||
- source: postgres_config
|
||||
target: /etc/postgresql/postgresql.conf
|
||||
env_file:
|
||||
- path: ./infrastructure/postgres/.env.template
|
||||
required: true
|
||||
- path: ./infrastructure/postgres/.env
|
||||
required: false
|
||||
healthcheck:
|
||||
test: [ "CMD", "pg_isready", "--dbname=postgres" ]
|
||||
interval: 1m30s
|
||||
timeout: 5s
|
||||
start_period: 5s
|
||||
start_interval: 2s
|
||||
retries: 5
|
||||
networks:
|
||||
- default
|
||||
oom_kill_disable: true
|
||||
restart: unless-stopped
|
||||
shm_size: 128mb
|
||||
volumes:
|
||||
- type: volume
|
||||
source: postgres_data
|
||||
target: /var/lib/postgresql/data
|
||||
|
||||
pgadmin:
|
||||
image: docker.io/dpage/pgadmin4:9
|
||||
configs:
|
||||
- source: pgadmin_servers_config
|
||||
target: /pgadmin4/servers.json
|
||||
depends_on:
|
||||
postgres:
|
||||
restart: false
|
||||
condition: service_healthy
|
||||
required: true
|
||||
env_file:
|
||||
- path: ./infrastructure/pgadmin/.env.template
|
||||
required: true
|
||||
- path: ./infrastructure/pgadmin/.env
|
||||
required: false
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-O", "-", "http://localhost:80/misc/ping"]
|
||||
interval: 1m30s
|
||||
timeout: 5s
|
||||
start_period: 5s
|
||||
start_interval: 2s
|
||||
retries: 5
|
||||
ports:
|
||||
- name: web
|
||||
target: 80
|
||||
published: 13442
|
||||
host_ip: 127.0.0.1
|
||||
protocol: tcp
|
||||
app_protocol: http
|
||||
networks:
|
||||
- default
|
||||
profiles:
|
||||
- observability
|
||||
restart: unless-stopped
|
||||
shm_size: 4mb
|
||||
volumes:
|
||||
- type: volume
|
||||
source: pgadmin_data
|
||||
target: /var/lib/pgadmin
|
||||
read_only: false
|
||||
|
||||
redis:
|
||||
image: docker.io/redis:8-alpine
|
||||
command: redis-server /usr/local/etc/redis/redis.conf
|
||||
configs:
|
||||
- source: redis_config
|
||||
target: /usr/local/etc/redis/redis.conf
|
||||
env_file:
|
||||
- path: ./infrastructure/redis/.env.template
|
||||
required: true
|
||||
- path: ./infrastructure/redis/.env
|
||||
required: false
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 1m30s
|
||||
timeout: 5s
|
||||
start_period: 5s
|
||||
start_interval: 2s
|
||||
retries: 5
|
||||
networks:
|
||||
- default
|
||||
restart: unless-stopped
|
||||
shm_size: 4mb
|
||||
volumes:
|
||||
- type: volume
|
||||
source: redis_data
|
||||
target: /data
|
||||
read_only: false
|
||||
|
||||
|
||||
networks:
|
||||
default:
|
||||
driver: bridge
|
||||
name: $COMPOSE_PROJECT_NAME
|
||||
attachable: false
|
||||
enable_ipv4: true
|
||||
enable_ipv6: true
|
||||
internal: false
|
||||
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
pgadmin_data:
|
||||
redis_data:
|
||||
|
||||
|
||||
configs:
|
||||
postgres_config:
|
||||
file: ./infrastructure/postgres/postgresql.conf
|
||||
pgadmin_servers_config:
|
||||
file: ./infrastructure/pgadmin/servers.json
|
||||
redis_config:
|
||||
file: ./infrastructure/redis/redis.conf
|
||||
@@ -0,0 +1,46 @@
|
||||
module datarush
|
||||
|
||||
go 1.24.0
|
||||
|
||||
toolchain go1.24.9
|
||||
|
||||
require (
|
||||
github.com/go-playground/validator/v10 v10.28.0
|
||||
github.com/golang-migrate/migrate/v4 v4.19.0
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3
|
||||
github.com/jmoiron/sqlx v1.4.0
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/lib/pq v1.10.9
|
||||
github.com/redis/go-redis/v9 v9.16.0
|
||||
google.golang.org/grpc v1.76.0
|
||||
google.golang.org/protobuf v1.36.10
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.10 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/rogpeppe/go-internal v1.14.1 // indirect
|
||||
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||
golang.org/x/crypto v0.42.0 // indirect
|
||||
golang.org/x/net v0.43.0 // indirect
|
||||
golang.org/x/sys v0.36.0 // indirect
|
||||
golang.org/x/text v0.29.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250929231259-57b25ae835d4 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250929231259-57b25ae835d4 // indirect
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 // indirect
|
||||
)
|
||||
|
||||
tool (
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc
|
||||
google.golang.org/protobuf/cmd/protoc-gen-go
|
||||
)
|
||||
@@ -0,0 +1,141 @@
|
||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
|
||||
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
||||
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
||||
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI=
|
||||
github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M=
|
||||
github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE=
|
||||
github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/dhui/dktest v0.4.6 h1:+DPKyScKSEp3VLtbMDHcUq6V5Lm5zfZZVb0Sk7Ahom4=
|
||||
github.com/dhui/dktest v0.4.6/go.mod h1:JHTSYDtKkvFNFHJKqCzVzqXecyv+tKt8EzceOmQOgbU=
|
||||
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
|
||||
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
|
||||
github.com/docker/docker v28.3.3+incompatible h1:Dypm25kh4rmk49v1eiVbsAtpAsYURjYkaKubwuBdxEI=
|
||||
github.com/docker/docker v28.3.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
|
||||
github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc=
|
||||
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
|
||||
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/gabriel-vasile/mimetype v1.4.10 h1:zyueNbySn/z8mJZHLt6IPw0KoZsiQNszIpU+bX4+ZK0=
|
||||
github.com/gabriel-vasile/mimetype v1.4.10/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.28.0 h1:Q7ibns33JjyW48gHkuFT91qX48KG0ktULL6FgHdG688=
|
||||
github.com/go-playground/validator/v10 v10.28.0/go.mod h1:GoI6I1SjPBh9p7ykNE/yj3fFYbyDOpwMn5KXd+m2hUU=
|
||||
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
|
||||
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
|
||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/golang-migrate/migrate/v4 v4.19.0 h1:RcjOnCGz3Or6HQYEJ/EEVLfWnmw9KnoigPSjzhCuaSE=
|
||||
github.com/golang-migrate/migrate/v4 v4.19.0/go.mod h1:9dyEcu+hO+G9hPSw8AIg50yg622pXJsoHItQnDGZkI0=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 h1:NmZ1PKzSTQbuGHw9DGPFomqkkLWMC+vZCkfs+FHv1Vg=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3/go.mod h1:zQrxl1YP88HQlA6i9c63DSVPFklWpGX4OWAc9bFuaH4=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
|
||||
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
|
||||
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
|
||||
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
|
||||
github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
||||
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
||||
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
|
||||
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
|
||||
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
|
||||
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
|
||||
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
|
||||
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
|
||||
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
|
||||
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
|
||||
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
|
||||
github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/redis/go-redis/v9 v9.16.0 h1:OotgqgLSRCmzfqChbQyG1PHC3tLNR89DG4jdOERSEP4=
|
||||
github.com/redis/go-redis/v9 v9.16.0/go.mod h1:u410H11HMLoB+TP67dz8rL9s6QW2j76l0//kSOd3370=
|
||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 h1:TT4fX+nBOA/+LUkobKGW1ydGcn+G3vRw9+g5HwCphpk=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0/go.mod h1:L7UH0GbB0p47T4Rri3uHjbpCFYrVrwc1I25QhNPiGK8=
|
||||
go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ=
|
||||
go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I=
|
||||
go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE=
|
||||
go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E=
|
||||
go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI=
|
||||
go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps=
|
||||
go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4=
|
||||
go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0=
|
||||
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
|
||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
|
||||
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
|
||||
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
|
||||
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
|
||||
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
|
||||
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
|
||||
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
|
||||
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
|
||||
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250929231259-57b25ae835d4 h1:8XJ4pajGwOlasW+L13MnEGA8W4115jJySQtVfS2/IBU=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250929231259-57b25ae835d4/go.mod h1:NnuHhy+bxcg30o7FnVAZbXsPHUDQ9qKWAQKCD7VxFtk=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250929231259-57b25ae835d4 h1:i8QOKZfYg6AbGVZzUAY3LrNWCKF8O6zFisU9Wl9RER4=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250929231259-57b25ae835d4/go.mod h1:HSkG/KdJWusxU1F6CNrwNDjBMgisKxGnc5dAZfT0mjQ=
|
||||
google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A=
|
||||
google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c=
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 h1:F29+wU6Ee6qgu9TddPgooOdaqsxTMunOoj8KA5yuS5A=
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1/go.mod h1:5KF+wpkbTSbGcR9zteSqZV6fqFOWBl4Yde8En8MryZA=
|
||||
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
|
||||
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
@@ -0,0 +1,5 @@
|
||||
# Custom environment files
|
||||
.env
|
||||
|
||||
# Password files
|
||||
password
|
||||
@@ -0,0 +1,10 @@
|
||||
GRPC_ENABLE_REFLECTION=true
|
||||
HTTP_HANDLER_ENABLE=true
|
||||
|
||||
POSTGRES_HOST=postgres
|
||||
POSTGRES_PORT=5432
|
||||
POSTGRES_USERNAME=postgres
|
||||
POSTGRES_PASSWORD=postgres
|
||||
POSTGRES_DATABASE=postgres
|
||||
|
||||
REDIS_URI=redis://redis:6379
|
||||
@@ -0,0 +1,4 @@
|
||||
PGADMIN_DEFAULT_EMAIL=admin@mail.com
|
||||
PGADMIN_DEFAULT_PASSWORD=password
|
||||
PGADMIN_DISABLE_POSTFIX=True
|
||||
PGADMIN_REPLACE_SERVERS_ON_STARTUP=True
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"Servers": {
|
||||
"1": {
|
||||
"Name": "default",
|
||||
"Group": "Servers",
|
||||
"Host": "postgres",
|
||||
"Port": 5432,
|
||||
"MaintenanceDB": "postgres",
|
||||
"Username": "postgres",
|
||||
"KerberosAuthentication": false,
|
||||
"ConnectionParameters": {
|
||||
"sslmode": "prefer",
|
||||
"connect_timeout": 10
|
||||
},
|
||||
"Tags": []
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
POSTGRES_DB=postgres
|
||||
POSTGRES_USER=postgres
|
||||
POSTGRES_PASSWORD=postgres
|
||||
@@ -0,0 +1,842 @@
|
||||
# -----------------------------
|
||||
# PostgreSQL configuration file
|
||||
# -----------------------------
|
||||
#
|
||||
# This file consists of lines of the form:
|
||||
#
|
||||
# name = value
|
||||
#
|
||||
# (The "=" is optional.) Whitespace may be used. Comments are introduced with
|
||||
# "#" anywhere on a line. The complete list of parameter names and allowed
|
||||
# values can be found in the PostgreSQL documentation.
|
||||
#
|
||||
# The commented-out settings shown in this file represent the default values.
|
||||
# Re-commenting a setting is NOT sufficient to revert it to the default value;
|
||||
# you need to reload the server.
|
||||
#
|
||||
# This file is read on server startup and when the server receives a SIGHUP
|
||||
# signal. If you edit the file on a running system, you have to SIGHUP the
|
||||
# server for the changes to take effect, run "pg_ctl reload", or execute
|
||||
# "SELECT pg_reload_conf()". Some parameters, which are marked below,
|
||||
# require a server shutdown and restart to take effect.
|
||||
#
|
||||
# Any parameter can also be given as a command-line option to the server, e.g.,
|
||||
# "postgres -c log_connections=on". Some parameters can be changed at run time
|
||||
# with the "SET" SQL command.
|
||||
#
|
||||
# Memory units: B = bytes Time units: us = microseconds
|
||||
# kB = kilobytes ms = milliseconds
|
||||
# MB = megabytes s = seconds
|
||||
# GB = gigabytes min = minutes
|
||||
# TB = terabytes h = hours
|
||||
# d = days
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# FILE LOCATIONS
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# The default values of these variables are driven from the -D command-line
|
||||
# option or PGDATA environment variable, represented here as ConfigDir.
|
||||
|
||||
#data_directory = 'ConfigDir' # use data in another directory
|
||||
# (change requires restart)
|
||||
#hba_file = 'ConfigDir/pg_hba.conf' # host-based authentication file
|
||||
# (change requires restart)
|
||||
#ident_file = 'ConfigDir/pg_ident.conf' # ident configuration file
|
||||
# (change requires restart)
|
||||
|
||||
# If external_pid_file is not explicitly set, no extra PID file is written.
|
||||
#external_pid_file = '' # write an extra PID file
|
||||
# (change requires restart)
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# CONNECTIONS AND AUTHENTICATION
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# - Connection Settings -
|
||||
|
||||
#listen_addresses = 'localhost' # what IP address(es) to listen on;
|
||||
# comma-separated list of addresses;
|
||||
# defaults to 'localhost'; use '*' for all
|
||||
# (change requires restart)
|
||||
#port = 5432 # (change requires restart)
|
||||
#max_connections = 100 # (change requires restart)
|
||||
#reserved_connections = 0 # (change requires restart)
|
||||
#superuser_reserved_connections = 3 # (change requires restart)
|
||||
#unix_socket_directories = '/tmp' # comma-separated list of directories
|
||||
# (change requires restart)
|
||||
#unix_socket_group = '' # (change requires restart)
|
||||
#unix_socket_permissions = 0777 # begin with 0 to use octal notation
|
||||
# (change requires restart)
|
||||
#bonjour = off # advertise server via Bonjour
|
||||
# (change requires restart)
|
||||
#bonjour_name = '' # defaults to the computer name
|
||||
# (change requires restart)
|
||||
|
||||
# - TCP settings -
|
||||
# see "man tcp" for details
|
||||
|
||||
#tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds;
|
||||
# 0 selects the system default
|
||||
#tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds;
|
||||
# 0 selects the system default
|
||||
#tcp_keepalives_count = 0 # TCP_KEEPCNT;
|
||||
# 0 selects the system default
|
||||
#tcp_user_timeout = 0 # TCP_USER_TIMEOUT, in milliseconds;
|
||||
# 0 selects the system default
|
||||
|
||||
#client_connection_check_interval = 0 # time between checks for client
|
||||
# disconnection while running queries;
|
||||
# 0 for never
|
||||
|
||||
# - Authentication -
|
||||
|
||||
#authentication_timeout = 1min # 1s-600s
|
||||
#password_encryption = scram-sha-256 # scram-sha-256 or md5
|
||||
#scram_iterations = 4096
|
||||
|
||||
# GSSAPI using Kerberos
|
||||
#krb_server_keyfile = 'FILE:${sysconfdir}/krb5.keytab'
|
||||
#krb_caseins_users = off
|
||||
#gss_accept_delegation = off
|
||||
|
||||
# - SSL -
|
||||
|
||||
#ssl = off
|
||||
#ssl_ca_file = ''
|
||||
#ssl_cert_file = 'server.crt'
|
||||
#ssl_crl_file = ''
|
||||
#ssl_crl_dir = ''
|
||||
#ssl_key_file = 'server.key'
|
||||
#ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers
|
||||
#ssl_prefer_server_ciphers = on
|
||||
#ssl_ecdh_curve = 'prime256v1'
|
||||
#ssl_min_protocol_version = 'TLSv1.2'
|
||||
#ssl_max_protocol_version = ''
|
||||
#ssl_dh_params_file = ''
|
||||
#ssl_passphrase_command = ''
|
||||
#ssl_passphrase_command_supports_reload = off
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# RESOURCE USAGE (except WAL)
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# - Memory -
|
||||
|
||||
#shared_buffers = 128MB # min 128kB
|
||||
# (change requires restart)
|
||||
#huge_pages = try # on, off, or try
|
||||
# (change requires restart)
|
||||
#huge_page_size = 0 # zero for system default
|
||||
# (change requires restart)
|
||||
#temp_buffers = 8MB # min 800kB
|
||||
#max_prepared_transactions = 0 # zero disables the feature
|
||||
# (change requires restart)
|
||||
# Caution: it is not advisable to set max_prepared_transactions nonzero unless
|
||||
# you actively intend to use prepared transactions.
|
||||
#work_mem = 4MB # min 64kB
|
||||
#hash_mem_multiplier = 2.0 # 1-1000.0 multiplier on hash table work_mem
|
||||
#maintenance_work_mem = 64MB # min 64kB
|
||||
#autovacuum_work_mem = -1 # min 64kB, or -1 to use maintenance_work_mem
|
||||
#logical_decoding_work_mem = 64MB # min 64kB
|
||||
#max_stack_depth = 2MB # min 100kB
|
||||
#shared_memory_type = mmap # the default is the first option
|
||||
# supported by the operating system:
|
||||
# mmap
|
||||
# sysv
|
||||
# windows
|
||||
# (change requires restart)
|
||||
#dynamic_shared_memory_type = posix # the default is usually the first option
|
||||
# supported by the operating system:
|
||||
# posix
|
||||
# sysv
|
||||
# windows
|
||||
# mmap
|
||||
# (change requires restart)
|
||||
#min_dynamic_shared_memory = 0MB # (change requires restart)
|
||||
#vacuum_buffer_usage_limit = 2MB # size of vacuum and analyze buffer access strategy ring;
|
||||
# 0 to disable vacuum buffer access strategy;
|
||||
# range 128kB to 16GB
|
||||
|
||||
# SLRU buffers (change requires restart)
|
||||
#commit_timestamp_buffers = 0 # memory for pg_commit_ts (0 = auto)
|
||||
#multixact_offset_buffers = 16 # memory for pg_multixact/offsets
|
||||
#multixact_member_buffers = 32 # memory for pg_multixact/members
|
||||
#notify_buffers = 16 # memory for pg_notify
|
||||
#serializable_buffers = 32 # memory for pg_serial
|
||||
#subtransaction_buffers = 0 # memory for pg_subtrans (0 = auto)
|
||||
#transaction_buffers = 0 # memory for pg_xact (0 = auto)
|
||||
|
||||
# - Disk -
|
||||
|
||||
#temp_file_limit = -1 # limits per-process temp file space
|
||||
# in kilobytes, or -1 for no limit
|
||||
|
||||
#max_notify_queue_pages = 1048576 # limits the number of SLRU pages allocated
|
||||
# for NOTIFY / LISTEN queue
|
||||
|
||||
# - Kernel Resources -
|
||||
|
||||
#max_files_per_process = 1000 # min 64
|
||||
# (change requires restart)
|
||||
|
||||
# - Cost-Based Vacuum Delay -
|
||||
|
||||
#vacuum_cost_delay = 0 # 0-100 milliseconds (0 disables)
|
||||
#vacuum_cost_page_hit = 1 # 0-10000 credits
|
||||
#vacuum_cost_page_miss = 2 # 0-10000 credits
|
||||
#vacuum_cost_page_dirty = 20 # 0-10000 credits
|
||||
#vacuum_cost_limit = 200 # 1-10000 credits
|
||||
|
||||
# - Background Writer -
|
||||
|
||||
#bgwriter_delay = 200ms # 10-10000ms between rounds
|
||||
#bgwriter_lru_maxpages = 100 # max buffers written/round, 0 disables
|
||||
#bgwriter_lru_multiplier = 2.0 # 0-10.0 multiplier on buffers scanned/round
|
||||
#bgwriter_flush_after = 0 # measured in pages, 0 disables
|
||||
|
||||
# - Asynchronous Behavior -
|
||||
|
||||
#backend_flush_after = 0 # measured in pages, 0 disables
|
||||
#effective_io_concurrency = 1 # 1-1000; 0 disables prefetching
|
||||
#maintenance_io_concurrency = 10 # 1-1000; 0 disables prefetching
|
||||
#io_combine_limit = 128kB # usually 1-32 blocks (depends on OS)
|
||||
#max_worker_processes = 8 # (change requires restart)
|
||||
#max_parallel_workers_per_gather = 2 # limited by max_parallel_workers
|
||||
#max_parallel_maintenance_workers = 2 # limited by max_parallel_workers
|
||||
#max_parallel_workers = 8 # number of max_worker_processes that
|
||||
# can be used in parallel operations
|
||||
#parallel_leader_participation = on
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# WRITE-AHEAD LOG
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# - Settings -
|
||||
|
||||
#wal_level = replica # minimal, replica, or logical
|
||||
# (change requires restart)
|
||||
#fsync = on # flush data to disk for crash safety
|
||||
# (turning this off can cause
|
||||
# unrecoverable data corruption)
|
||||
#synchronous_commit = on # synchronization level;
|
||||
# off, local, remote_write, remote_apply, or on
|
||||
#wal_sync_method = fsync # the default is the first option
|
||||
# supported by the operating system:
|
||||
# open_datasync
|
||||
# fdatasync (default on Linux and FreeBSD)
|
||||
# fsync
|
||||
# fsync_writethrough
|
||||
# open_sync
|
||||
#full_page_writes = on # recover from partial page writes
|
||||
#wal_log_hints = off # also do full page writes of non-critical updates
|
||||
# (change requires restart)
|
||||
#wal_compression = off # enables compression of full-page writes;
|
||||
# off, pglz, lz4, zstd, or on
|
||||
#wal_init_zero = on # zero-fill new WAL files
|
||||
#wal_recycle = on # recycle WAL files
|
||||
#wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers
|
||||
# (change requires restart)
|
||||
#wal_writer_delay = 200ms # 1-10000 milliseconds
|
||||
#wal_writer_flush_after = 1MB # measured in pages, 0 disables
|
||||
#wal_skip_threshold = 2MB
|
||||
|
||||
#commit_delay = 0 # range 0-100000, in microseconds
|
||||
#commit_siblings = 5 # range 1-1000
|
||||
|
||||
# - Checkpoints -
|
||||
|
||||
#checkpoint_timeout = 5min # range 30s-1d
|
||||
#checkpoint_completion_target = 0.9 # checkpoint target duration, 0.0 - 1.0
|
||||
#checkpoint_flush_after = 0 # measured in pages, 0 disables
|
||||
#checkpoint_warning = 30s # 0 disables
|
||||
#max_wal_size = 1GB
|
||||
#min_wal_size = 80MB
|
||||
|
||||
# - Prefetching during recovery -
|
||||
|
||||
#recovery_prefetch = try # prefetch pages referenced in the WAL?
|
||||
#wal_decode_buffer_size = 512kB # lookahead window used for prefetching
|
||||
# (change requires restart)
|
||||
|
||||
# - Archiving -
|
||||
|
||||
#archive_mode = off # enables archiving; off, on, or always
|
||||
# (change requires restart)
|
||||
#archive_library = '' # library to use to archive a WAL file
|
||||
# (empty string indicates archive_command should
|
||||
# be used)
|
||||
#archive_command = '' # command to use to archive a WAL file
|
||||
# placeholders: %p = path of file to archive
|
||||
# %f = file name only
|
||||
# e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f'
|
||||
#archive_timeout = 0 # force a WAL file switch after this
|
||||
# number of seconds; 0 disables
|
||||
|
||||
# - Archive Recovery -
|
||||
|
||||
# These are only used in recovery mode.
|
||||
|
||||
#restore_command = '' # command to use to restore an archived WAL file
|
||||
# placeholders: %p = path of file to restore
|
||||
# %f = file name only
|
||||
# e.g. 'cp /mnt/server/archivedir/%f %p'
|
||||
#archive_cleanup_command = '' # command to execute at every restartpoint
|
||||
#recovery_end_command = '' # command to execute at completion of recovery
|
||||
|
||||
# - Recovery Target -
|
||||
|
||||
# Set these only when performing a targeted recovery.
|
||||
|
||||
#recovery_target = '' # 'immediate' to end recovery as soon as a
|
||||
# consistent state is reached
|
||||
# (change requires restart)
|
||||
#recovery_target_name = '' # the named restore point to which recovery will proceed
|
||||
# (change requires restart)
|
||||
#recovery_target_time = '' # the time stamp up to which recovery will proceed
|
||||
# (change requires restart)
|
||||
#recovery_target_xid = '' # the transaction ID up to which recovery will proceed
|
||||
# (change requires restart)
|
||||
#recovery_target_lsn = '' # the WAL LSN up to which recovery will proceed
|
||||
# (change requires restart)
|
||||
#recovery_target_inclusive = on # Specifies whether to stop:
|
||||
# just after the specified recovery target (on)
|
||||
# just before the recovery target (off)
|
||||
# (change requires restart)
|
||||
#recovery_target_timeline = 'latest' # 'current', 'latest', or timeline ID
|
||||
# (change requires restart)
|
||||
#recovery_target_action = 'pause' # 'pause', 'promote', 'shutdown'
|
||||
# (change requires restart)
|
||||
|
||||
# - WAL Summarization -
|
||||
|
||||
#summarize_wal = off # run WAL summarizer process?
|
||||
#wal_summary_keep_time = '10d' # when to remove old summary files, 0 = never
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# REPLICATION
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# - Sending Servers -
|
||||
|
||||
# Set these on the primary and on any standby that will send replication data.
|
||||
|
||||
#max_wal_senders = 10 # max number of walsender processes
|
||||
# (change requires restart)
|
||||
#max_replication_slots = 10 # max number of replication slots
|
||||
# (change requires restart)
|
||||
#wal_keep_size = 0 # in megabytes; 0 disables
|
||||
#max_slot_wal_keep_size = -1 # in megabytes; -1 disables
|
||||
#wal_sender_timeout = 60s # in milliseconds; 0 disables
|
||||
#track_commit_timestamp = off # collect timestamp of transaction commit
|
||||
# (change requires restart)
|
||||
|
||||
# - Primary Server -
|
||||
|
||||
# These settings are ignored on a standby server.
|
||||
|
||||
#synchronous_standby_names = '' # standby servers that provide sync rep
|
||||
# method to choose sync standbys, number of sync standbys,
|
||||
# and comma-separated list of application_name
|
||||
# from standby(s); '*' = all
|
||||
#synchronized_standby_slots = '' # streaming replication standby server slot
|
||||
# names that logical walsender processes will wait for
|
||||
|
||||
# - Standby Servers -
|
||||
|
||||
# These settings are ignored on a primary server.
|
||||
|
||||
#primary_conninfo = '' # connection string to sending server
|
||||
#primary_slot_name = '' # replication slot on sending server
|
||||
#hot_standby = on # "off" disallows queries during recovery
|
||||
# (change requires restart)
|
||||
#max_standby_archive_delay = 30s # max delay before canceling queries
|
||||
# when reading WAL from archive;
|
||||
# -1 allows indefinite delay
|
||||
#max_standby_streaming_delay = 30s # max delay before canceling queries
|
||||
# when reading streaming WAL;
|
||||
# -1 allows indefinite delay
|
||||
#wal_receiver_create_temp_slot = off # create temp slot if primary_slot_name
|
||||
# is not set
|
||||
#wal_receiver_status_interval = 10s # send replies at least this often
|
||||
# 0 disables
|
||||
#hot_standby_feedback = off # send info from standby to prevent
|
||||
# query conflicts
|
||||
#wal_receiver_timeout = 60s # time that receiver waits for
|
||||
# communication from primary
|
||||
# in milliseconds; 0 disables
|
||||
#wal_retrieve_retry_interval = 5s # time to wait before retrying to
|
||||
# retrieve WAL after a failed attempt
|
||||
#recovery_min_apply_delay = 0 # minimum delay for applying changes during recovery
|
||||
#sync_replication_slots = off # enables slot synchronization on the physical standby from the primary
|
||||
|
||||
# - Subscribers -
|
||||
|
||||
# These settings are ignored on a publisher.
|
||||
|
||||
#max_logical_replication_workers = 4 # taken from max_worker_processes
|
||||
# (change requires restart)
|
||||
#max_sync_workers_per_subscription = 2 # taken from max_logical_replication_workers
|
||||
#max_parallel_apply_workers_per_subscription = 2 # taken from max_logical_replication_workers
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# QUERY TUNING
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# - Planner Method Configuration -
|
||||
|
||||
#enable_async_append = on
|
||||
#enable_bitmapscan = on
|
||||
#enable_gathermerge = on
|
||||
#enable_hashagg = on
|
||||
#enable_hashjoin = on
|
||||
#enable_incremental_sort = on
|
||||
#enable_indexscan = on
|
||||
#enable_indexonlyscan = on
|
||||
#enable_material = on
|
||||
#enable_memoize = on
|
||||
#enable_mergejoin = on
|
||||
#enable_nestloop = on
|
||||
#enable_parallel_append = on
|
||||
#enable_parallel_hash = on
|
||||
#enable_partition_pruning = on
|
||||
#enable_partitionwise_join = off
|
||||
#enable_partitionwise_aggregate = off
|
||||
#enable_presorted_aggregate = on
|
||||
#enable_seqscan = on
|
||||
#enable_sort = on
|
||||
#enable_tidscan = on
|
||||
#enable_group_by_reordering = on
|
||||
|
||||
# - Planner Cost Constants -
|
||||
|
||||
#seq_page_cost = 1.0 # measured on an arbitrary scale
|
||||
#random_page_cost = 4.0 # same scale as above
|
||||
#cpu_tuple_cost = 0.01 # same scale as above
|
||||
#cpu_index_tuple_cost = 0.005 # same scale as above
|
||||
#cpu_operator_cost = 0.0025 # same scale as above
|
||||
#parallel_setup_cost = 1000.0 # same scale as above
|
||||
#parallel_tuple_cost = 0.1 # same scale as above
|
||||
#min_parallel_table_scan_size = 8MB
|
||||
#min_parallel_index_scan_size = 512kB
|
||||
#effective_cache_size = 4GB
|
||||
|
||||
#jit_above_cost = 100000 # perform JIT compilation if available
|
||||
# and query more expensive than this;
|
||||
# -1 disables
|
||||
#jit_inline_above_cost = 500000 # inline small functions if query is
|
||||
# more expensive than this; -1 disables
|
||||
#jit_optimize_above_cost = 500000 # use expensive JIT optimizations if
|
||||
# query is more expensive than this;
|
||||
# -1 disables
|
||||
|
||||
# - Genetic Query Optimizer -
|
||||
|
||||
#geqo = on
|
||||
#geqo_threshold = 12
|
||||
#geqo_effort = 5 # range 1-10
|
||||
#geqo_pool_size = 0 # selects default based on effort
|
||||
#geqo_generations = 0 # selects default based on effort
|
||||
#geqo_selection_bias = 2.0 # range 1.5-2.0
|
||||
#geqo_seed = 0.0 # range 0.0-1.0
|
||||
|
||||
# - Other Planner Options -
|
||||
|
||||
#default_statistics_target = 100 # range 1-10000
|
||||
#constraint_exclusion = partition # on, off, or partition
|
||||
#cursor_tuple_fraction = 0.1 # range 0.0-1.0
|
||||
#from_collapse_limit = 8
|
||||
#jit = on # allow JIT compilation
|
||||
#join_collapse_limit = 8 # 1 disables collapsing of explicit
|
||||
# JOIN clauses
|
||||
#plan_cache_mode = auto # auto, force_generic_plan or
|
||||
# force_custom_plan
|
||||
#recursive_worktable_factor = 10.0 # range 0.001-1000000
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# REPORTING AND LOGGING
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# - Where to Log -
|
||||
|
||||
#log_destination = 'stderr' # Valid values are combinations of
|
||||
# stderr, csvlog, jsonlog, syslog, and
|
||||
# eventlog, depending on platform.
|
||||
# csvlog and jsonlog require
|
||||
# logging_collector to be on.
|
||||
|
||||
# This is used when logging to stderr:
|
||||
#logging_collector = off # Enable capturing of stderr, jsonlog,
|
||||
# and csvlog into log files. Required
|
||||
# to be on for csvlogs and jsonlogs.
|
||||
# (change requires restart)
|
||||
|
||||
# These are only used if logging_collector is on:
|
||||
#log_directory = 'log' # directory where log files are written,
|
||||
# can be absolute or relative to PGDATA
|
||||
#log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern,
|
||||
# can include strftime() escapes
|
||||
#log_file_mode = 0600 # creation mode for log files,
|
||||
# begin with 0 to use octal notation
|
||||
#log_rotation_age = 1d # Automatic rotation of logfiles will
|
||||
# happen after that time. 0 disables.
|
||||
#log_rotation_size = 10MB # Automatic rotation of logfiles will
|
||||
# happen after that much log output.
|
||||
# 0 disables.
|
||||
#log_truncate_on_rotation = off # If on, an existing log file with the
|
||||
# same name as the new log file will be
|
||||
# truncated rather than appended to.
|
||||
# But such truncation only occurs on
|
||||
# time-driven rotation, not on restarts
|
||||
# or size-driven rotation. Default is
|
||||
# off, meaning append to existing files
|
||||
# in all cases.
|
||||
|
||||
# These are relevant when logging to syslog:
|
||||
#syslog_facility = 'LOCAL0'
|
||||
#syslog_ident = 'postgres'
|
||||
#syslog_sequence_numbers = on
|
||||
#syslog_split_messages = on
|
||||
|
||||
# This is only relevant when logging to eventlog (Windows):
|
||||
# (change requires restart)
|
||||
#event_source = 'PostgreSQL'
|
||||
|
||||
# - When to Log -
|
||||
|
||||
#log_min_messages = warning # values in order of decreasing detail:
|
||||
# debug5
|
||||
# debug4
|
||||
# debug3
|
||||
# debug2
|
||||
# debug1
|
||||
# info
|
||||
# notice
|
||||
# warning
|
||||
# error
|
||||
# log
|
||||
# fatal
|
||||
# panic
|
||||
|
||||
#log_min_error_statement = error # values in order of decreasing detail:
|
||||
# debug5
|
||||
# debug4
|
||||
# debug3
|
||||
# debug2
|
||||
# debug1
|
||||
# info
|
||||
# notice
|
||||
# warning
|
||||
# error
|
||||
# log
|
||||
# fatal
|
||||
# panic (effectively off)
|
||||
|
||||
#log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements
|
||||
# and their durations, > 0 logs only
|
||||
# statements running at least this number
|
||||
# of milliseconds
|
||||
|
||||
#log_min_duration_sample = -1 # -1 is disabled, 0 logs a sample of statements
|
||||
# and their durations, > 0 logs only a sample of
|
||||
# statements running at least this number
|
||||
# of milliseconds;
|
||||
# sample fraction is determined by log_statement_sample_rate
|
||||
|
||||
#log_statement_sample_rate = 1.0 # fraction of logged statements exceeding
|
||||
# log_min_duration_sample to be logged;
|
||||
# 1.0 logs all such statements, 0.0 never logs
|
||||
|
||||
|
||||
#log_transaction_sample_rate = 0.0 # fraction of transactions whose statements
|
||||
# are logged regardless of their duration; 1.0 logs all
|
||||
# statements from all transactions, 0.0 never logs
|
||||
|
||||
#log_startup_progress_interval = 10s # Time between progress updates for
|
||||
# long-running startup operations.
|
||||
# 0 disables the feature, > 0 indicates
|
||||
# the interval in milliseconds.
|
||||
|
||||
# - What to Log -
|
||||
|
||||
#debug_print_parse = off
|
||||
#debug_print_rewritten = off
|
||||
#debug_print_plan = off
|
||||
#debug_pretty_print = on
|
||||
#log_autovacuum_min_duration = 10min # log autovacuum activity;
|
||||
# -1 disables, 0 logs all actions and
|
||||
# their durations, > 0 logs only
|
||||
# actions running at least this number
|
||||
# of milliseconds.
|
||||
#log_checkpoints = on
|
||||
#log_connections = off
|
||||
#log_disconnections = off
|
||||
#log_duration = off
|
||||
#log_error_verbosity = default # terse, default, or verbose messages
|
||||
#log_hostname = off
|
||||
#log_line_prefix = '%m [%p] ' # special values:
|
||||
# %a = application name
|
||||
# %u = user name
|
||||
# %d = database name
|
||||
# %r = remote host and port
|
||||
# %h = remote host
|
||||
# %b = backend type
|
||||
# %p = process ID
|
||||
# %P = process ID of parallel group leader
|
||||
# %t = timestamp without milliseconds
|
||||
# %m = timestamp with milliseconds
|
||||
# %n = timestamp with milliseconds (as a Unix epoch)
|
||||
# %Q = query ID (0 if none or not computed)
|
||||
# %i = command tag
|
||||
# %e = SQL state
|
||||
# %c = session ID
|
||||
# %l = session line number
|
||||
# %s = session start timestamp
|
||||
# %v = virtual transaction ID
|
||||
# %x = transaction ID (0 if none)
|
||||
# %q = stop here in non-session
|
||||
# processes
|
||||
# %% = '%'
|
||||
# e.g. '<%u%%%d> '
|
||||
#log_lock_waits = off # log lock waits >= deadlock_timeout
|
||||
#log_recovery_conflict_waits = off # log standby recovery conflict waits
|
||||
# >= deadlock_timeout
|
||||
#log_parameter_max_length = -1 # when logging statements, limit logged
|
||||
# bind-parameter values to N bytes;
|
||||
# -1 means print in full, 0 disables
|
||||
#log_parameter_max_length_on_error = 0 # when logging an error, limit logged
|
||||
# bind-parameter values to N bytes;
|
||||
# -1 means print in full, 0 disables
|
||||
#log_statement = 'none' # none, ddl, mod, all
|
||||
#log_replication_commands = off
|
||||
#log_temp_files = -1 # log temporary files equal or larger
|
||||
# than the specified size in kilobytes;
|
||||
# -1 disables, 0 logs all temp files
|
||||
#log_timezone = 'GMT'
|
||||
|
||||
# - Process Title -
|
||||
|
||||
#cluster_name = '' # added to process titles if nonempty
|
||||
# (change requires restart)
|
||||
#update_process_title = on
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# STATISTICS
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# - Cumulative Query and Index Statistics -
|
||||
|
||||
#track_activities = on
|
||||
#track_activity_query_size = 1024 # (change requires restart)
|
||||
#track_counts = on
|
||||
#track_io_timing = off
|
||||
#track_wal_io_timing = off
|
||||
#track_functions = none # none, pl, all
|
||||
#stats_fetch_consistency = cache # cache, none, snapshot
|
||||
|
||||
|
||||
# - Monitoring -
|
||||
|
||||
#compute_query_id = auto
|
||||
#log_statement_stats = off
|
||||
#log_parser_stats = off
|
||||
#log_planner_stats = off
|
||||
#log_executor_stats = off
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# AUTOVACUUM
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#autovacuum = on # Enable autovacuum subprocess? 'on'
|
||||
# requires track_counts to also be on.
|
||||
#autovacuum_max_workers = 3 # max number of autovacuum subprocesses
|
||||
# (change requires restart)
|
||||
#autovacuum_naptime = 1min # time between autovacuum runs
|
||||
#autovacuum_vacuum_threshold = 50 # min number of row updates before
|
||||
# vacuum
|
||||
#autovacuum_vacuum_insert_threshold = 1000 # min number of row inserts
|
||||
# before vacuum; -1 disables insert
|
||||
# vacuums
|
||||
#autovacuum_analyze_threshold = 50 # min number of row updates before
|
||||
# analyze
|
||||
#autovacuum_vacuum_scale_factor = 0.2 # fraction of table size before vacuum
|
||||
#autovacuum_vacuum_insert_scale_factor = 0.2 # fraction of inserts over table
|
||||
# size before insert vacuum
|
||||
#autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze
|
||||
#autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum
|
||||
# (change requires restart)
|
||||
#autovacuum_multixact_freeze_max_age = 400000000 # maximum multixact age
|
||||
# before forced vacuum
|
||||
# (change requires restart)
|
||||
#autovacuum_vacuum_cost_delay = 2ms # default vacuum cost delay for
|
||||
# autovacuum, in milliseconds;
|
||||
# -1 means use vacuum_cost_delay
|
||||
#autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for
|
||||
# autovacuum, -1 means use
|
||||
# vacuum_cost_limit
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# CLIENT CONNECTION DEFAULTS
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# - Statement Behavior -
|
||||
|
||||
#client_min_messages = notice # values in order of decreasing detail:
|
||||
# debug5
|
||||
# debug4
|
||||
# debug3
|
||||
# debug2
|
||||
# debug1
|
||||
# log
|
||||
# notice
|
||||
# warning
|
||||
# error
|
||||
#search_path = '"$user", public' # schema names
|
||||
#row_security = on
|
||||
#default_table_access_method = 'heap'
|
||||
#default_tablespace = '' # a tablespace name, '' uses the default
|
||||
#default_toast_compression = 'pglz' # 'pglz' or 'lz4'
|
||||
#temp_tablespaces = '' # a list of tablespace names, '' uses
|
||||
# only default tablespace
|
||||
#check_function_bodies = on
|
||||
#default_transaction_isolation = 'read committed'
|
||||
#default_transaction_read_only = off
|
||||
#default_transaction_deferrable = off
|
||||
#session_replication_role = 'origin'
|
||||
#statement_timeout = 0 # in milliseconds, 0 is disabled
|
||||
#transaction_timeout = 0 # in milliseconds, 0 is disabled
|
||||
#lock_timeout = 0 # in milliseconds, 0 is disabled
|
||||
#idle_in_transaction_session_timeout = 0 # in milliseconds, 0 is disabled
|
||||
#idle_session_timeout = 0 # in milliseconds, 0 is disabled
|
||||
#vacuum_freeze_table_age = 150000000
|
||||
#vacuum_freeze_min_age = 50000000
|
||||
#vacuum_failsafe_age = 1600000000
|
||||
#vacuum_multixact_freeze_table_age = 150000000
|
||||
#vacuum_multixact_freeze_min_age = 5000000
|
||||
#vacuum_multixact_failsafe_age = 1600000000
|
||||
#bytea_output = 'hex' # hex, escape
|
||||
#xmlbinary = 'base64'
|
||||
#xmloption = 'content'
|
||||
#gin_pending_list_limit = 4MB
|
||||
#createrole_self_grant = '' # set and/or inherit
|
||||
#event_triggers = on
|
||||
|
||||
# - Locale and Formatting -
|
||||
|
||||
#datestyle = 'iso, mdy'
|
||||
#intervalstyle = 'postgres'
|
||||
#timezone = 'GMT'
|
||||
#timezone_abbreviations = 'Default' # Select the set of available time zone
|
||||
# abbreviations. Currently, there are
|
||||
# Default
|
||||
# Australia (historical usage)
|
||||
# India
|
||||
# You can create your own file in
|
||||
# share/timezonesets/.
|
||||
#extra_float_digits = 1 # min -15, max 3; any value >0 actually
|
||||
# selects precise output mode
|
||||
#client_encoding = sql_ascii # actually, defaults to database
|
||||
# encoding
|
||||
|
||||
# These settings are initialized by initdb, but they can be changed.
|
||||
#lc_messages = '' # locale for system error message
|
||||
# strings
|
||||
#lc_monetary = 'C' # locale for monetary formatting
|
||||
#lc_numeric = 'C' # locale for number formatting
|
||||
#lc_time = 'C' # locale for time formatting
|
||||
|
||||
#icu_validation_level = warning # report ICU locale validation
|
||||
# errors at the given level
|
||||
|
||||
# default configuration for text search
|
||||
#default_text_search_config = 'pg_catalog.simple'
|
||||
|
||||
# - Shared Library Preloading -
|
||||
|
||||
#local_preload_libraries = ''
|
||||
#session_preload_libraries = ''
|
||||
#shared_preload_libraries = '' # (change requires restart)
|
||||
#jit_provider = 'llvmjit' # JIT library to use
|
||||
|
||||
# - Other Defaults -
|
||||
|
||||
#dynamic_library_path = '$libdir'
|
||||
#gin_fuzzy_search_limit = 0
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# LOCK MANAGEMENT
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#deadlock_timeout = 1s
|
||||
#max_locks_per_transaction = 64 # min 10
|
||||
# (change requires restart)
|
||||
#max_pred_locks_per_transaction = 64 # min 10
|
||||
# (change requires restart)
|
||||
#max_pred_locks_per_relation = -2 # negative values mean
|
||||
# (max_pred_locks_per_transaction
|
||||
# / -max_pred_locks_per_relation) - 1
|
||||
#max_pred_locks_per_page = 2 # min 0
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VERSION AND PLATFORM COMPATIBILITY
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# - Previous PostgreSQL Versions -
|
||||
|
||||
#array_nulls = on
|
||||
#backslash_quote = safe_encoding # on, off, or safe_encoding
|
||||
#escape_string_warning = on
|
||||
#lo_compat_privileges = off
|
||||
#quote_all_identifiers = off
|
||||
#standard_conforming_strings = on
|
||||
#synchronize_seqscans = on
|
||||
|
||||
# - Other Platforms and Clients -
|
||||
|
||||
#transform_null_equals = off
|
||||
#allow_alter_system = on
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# ERROR HANDLING
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#exit_on_error = off # terminate session on any error?
|
||||
#restart_after_crash = on # reinitialize after backend crash?
|
||||
#data_sync_retry = off # retry or panic on failure to fsync
|
||||
# data?
|
||||
# (change requires restart)
|
||||
#recovery_init_sync_method = fsync # fsync, syncfs (Linux 5.8+)
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# CONFIG FILE INCLUDES
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# These options allow settings to be loaded from files other than the
|
||||
# default postgresql.conf. Note that these are directives, not variable
|
||||
# assignments, so they can usefully be given more than once.
|
||||
|
||||
#include_dir = '...' # include files ending in '.conf' from
|
||||
# a directory, e.g., 'conf.d'
|
||||
#include_if_exists = '...' # include file only if it exists
|
||||
#include = '...' # include file
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# CUSTOMIZED OPTIONS
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Add settings for extensions here
|
||||
@@ -0,0 +1 @@
|
||||
REDIS_PORT=6379
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,78 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
GRPCPort int
|
||||
GRPCEnableReflection bool
|
||||
EnableHTTPHandler bool
|
||||
HTTPPort int
|
||||
LogLevel string
|
||||
DBHost string
|
||||
DBPort int
|
||||
DBUser string
|
||||
DBPassword string
|
||||
DBName string
|
||||
RedisURI string
|
||||
}
|
||||
|
||||
func Load() (*Config, error) {
|
||||
_ = godotenv.Load()
|
||||
|
||||
return &Config{
|
||||
GRPCPort: mustGetInt("GRPC_PORT", 50051), //nolint:mnd // false-positive
|
||||
GRPCEnableReflection: mustGetBool("GRPC_ENABLE_REFLECTION", false),
|
||||
EnableHTTPHandler: mustGetBool("HTTP_HANDLER_ENABLE", false),
|
||||
HTTPPort: mustGetInt("HTTP_PORT", 8080), //nolint:mnd // false-positive
|
||||
LogLevel: getEnv("LOG_LEVEL", "info"),
|
||||
DBHost: getEnv("POSTGRES_HOST", "localhost"),
|
||||
DBPort: mustGetInt("POSTGRES_PORT", 5432), //nolint:mnd // false-positive
|
||||
DBUser: getEnv("POSTGRES_USERNAME", "postgres"),
|
||||
DBPassword: getEnv("POSTGRES_PASSWORD", "postgres"),
|
||||
DBName: getEnv("POSTGRES_DATABASE", "postgres"),
|
||||
RedisURI: getEnv("REDIS_URI", "redis://localhost:6379"),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getEnv(key, def string) string {
|
||||
if val := os.Getenv(key); val != "" {
|
||||
return val
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
func mustGetInt(key string, def int) int {
|
||||
val := getEnv(key, strconv.Itoa(def))
|
||||
n, err := strconv.Atoi(val)
|
||||
if err != nil {
|
||||
log.Fatalf("invalid int for %s: %v", key, err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func mustGetBool(key string, def bool) bool {
|
||||
val := getEnv(key, strconv.FormatBool(def))
|
||||
b, err := strconv.ParseBool(val)
|
||||
if err != nil {
|
||||
log.Fatalf("invalid bool for %s: %v", key, err)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (c Config) BuildPostgresConnStr() string {
|
||||
return fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=disable",
|
||||
c.DBHost, c.DBPort, c.DBUser, c.DBPassword, c.DBName)
|
||||
}
|
||||
|
||||
func (c Config) BuildPostgresDSN() string {
|
||||
return fmt.Sprintf("postgresql://%s:%s@%s/%s?sslmode=disable",
|
||||
c.DBUser, c.DBPassword, net.JoinHostPort(c.DBHost, strconv.Itoa(c.DBPort)), c.DBName)
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrInvalidID = errors.New("invalid uuid")
|
||||
)
|
||||
@@ -0,0 +1,42 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/go-playground/validator/v10"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrOrderAlreadyExist = errors.New("order already exist")
|
||||
ErrOrderNotFound = errors.New("order not found")
|
||||
ErrInvalidOrderData = errors.New("invalid order data")
|
||||
)
|
||||
|
||||
type Order struct {
|
||||
ID uuid.UUID `db:"id" json:"id" validate:"required"`
|
||||
Item string `db:"item" json:"item" validate:"required"`
|
||||
Quantity int32 `db:"quantity" json:"quantity" validate:"required,gt=0"`
|
||||
}
|
||||
|
||||
func NewOrder(id uuid.UUID, item string, quantity int32) (*Order, error) {
|
||||
order := &Order{
|
||||
ID: id,
|
||||
Item: item,
|
||||
Quantity: quantity,
|
||||
}
|
||||
|
||||
err := order.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return order, nil
|
||||
}
|
||||
|
||||
func (o *Order) Validate() error {
|
||||
validate := validator.New()
|
||||
|
||||
return fmt.Errorf("%w: %w", ErrInvalidOrderData, validate.Struct(o))
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
|
||||
"datarush/internal/lms/domain"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
func mapError(err error) error {
|
||||
if errors.Is(err, domain.ErrOrderNotFound) {
|
||||
return status.Error(codes.NotFound, err.Error())
|
||||
}
|
||||
if errors.Is(err, domain.ErrOrderAlreadyExist) {
|
||||
return status.Error(codes.AlreadyExists, err.Error())
|
||||
}
|
||||
if errors.Is(err, domain.ErrInvalidOrderData) || errors.Is(err, domain.ErrInvalidID) {
|
||||
return status.Error(codes.InvalidArgument, err.Error())
|
||||
}
|
||||
|
||||
log.Printf("internal server error: %v", err)
|
||||
return status.Error(codes.Internal, "internal server error")
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"datarush/internal/lms/domain"
|
||||
"datarush/internal/lms/service"
|
||||
pb "datarush/pkg/api/order"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type OrderHandler struct {
|
||||
pb.UnimplementedOrderServiceServer
|
||||
|
||||
service *service.OrderService
|
||||
}
|
||||
|
||||
func NewOrderHandler(service *service.OrderService) *OrderHandler {
|
||||
return &OrderHandler{
|
||||
service: service,
|
||||
}
|
||||
}
|
||||
|
||||
func mapDomainStructToHandler(order *domain.Order) *pb.Order {
|
||||
return &pb.Order{
|
||||
Id: order.ID.String(),
|
||||
Item: order.Item,
|
||||
Quantity: order.Quantity,
|
||||
}
|
||||
}
|
||||
|
||||
func (h *OrderHandler) CreateOrder(
|
||||
ctx context.Context,
|
||||
req *pb.CreateOrderRequest,
|
||||
) (*pb.CreateOrderResponse, error) {
|
||||
order, err := h.service.Create(ctx, req.GetItem(), req.GetQuantity())
|
||||
if err != nil {
|
||||
return nil, mapError(err)
|
||||
}
|
||||
|
||||
return &pb.CreateOrderResponse{Id: order.ID.String()}, nil
|
||||
}
|
||||
|
||||
func (h *OrderHandler) GetOrder(ctx context.Context, req *pb.GetOrderRequest) (*pb.GetOrderResponse, error) {
|
||||
parsedID, err := uuid.Parse(req.GetId())
|
||||
if err != nil {
|
||||
return nil, domain.ErrInvalidID
|
||||
}
|
||||
|
||||
order, err := h.service.Get(ctx, parsedID)
|
||||
if err != nil {
|
||||
return nil, mapError(err)
|
||||
}
|
||||
|
||||
return &pb.GetOrderResponse{Order: mapDomainStructToHandler(order)}, nil
|
||||
}
|
||||
|
||||
func (h *OrderHandler) UpdateOrder(
|
||||
ctx context.Context,
|
||||
req *pb.UpdateOrderRequest,
|
||||
) (*pb.UpdateOrderResponse, error) {
|
||||
parsedID, err := uuid.Parse(req.GetId())
|
||||
if err != nil {
|
||||
return nil, mapError(domain.ErrInvalidID)
|
||||
}
|
||||
|
||||
order, err := h.service.Update(ctx, parsedID, req.GetItem(), req.GetQuantity())
|
||||
if err != nil {
|
||||
return nil, mapError(err)
|
||||
}
|
||||
|
||||
return &pb.UpdateOrderResponse{Order: mapDomainStructToHandler(order)}, nil
|
||||
}
|
||||
|
||||
func (h *OrderHandler) DeleteOrder(
|
||||
ctx context.Context,
|
||||
req *pb.DeleteOrderRequest,
|
||||
) (*pb.DeleteOrderResponse, error) {
|
||||
parsedID, err := uuid.Parse(req.GetId())
|
||||
if err != nil {
|
||||
return nil, domain.ErrInvalidID
|
||||
}
|
||||
|
||||
err = h.service.Delete(ctx, parsedID)
|
||||
if err != nil {
|
||||
return nil, mapError(err)
|
||||
}
|
||||
|
||||
return &pb.DeleteOrderResponse{Success: true}, nil
|
||||
}
|
||||
|
||||
func (h *OrderHandler) ListOrders(
|
||||
ctx context.Context,
|
||||
_ *pb.ListOrdersRequest,
|
||||
) (*pb.ListOrdersResponse, error) {
|
||||
domainOrders, err := h.service.List(ctx)
|
||||
if err != nil {
|
||||
return nil, mapError(err)
|
||||
}
|
||||
|
||||
orders := make([]*pb.Order, 0, len(domainOrders))
|
||||
for _, o := range domainOrders {
|
||||
orders = append(orders, mapDomainStructToHandler(o))
|
||||
}
|
||||
|
||||
return &pb.ListOrdersResponse{Orders: orders}, nil
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
type HealthHandler struct {
|
||||
DB *sqlx.DB
|
||||
Redis *redis.Client
|
||||
}
|
||||
|
||||
func NewHealthHandler(db *sqlx.DB, redisDB *redis.Client) *HealthHandler {
|
||||
return &HealthHandler{
|
||||
DB: db,
|
||||
Redis: redisDB,
|
||||
}
|
||||
}
|
||||
|
||||
type HealthResponse struct {
|
||||
Status string `json:"status"`
|
||||
Details map[string]string `json:"details"`
|
||||
}
|
||||
|
||||
func (h *HealthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 2*time.Second)
|
||||
defer cancel()
|
||||
|
||||
details := map[string]string{}
|
||||
|
||||
if err := h.DB.PingContext(ctx); err != nil {
|
||||
details["postgres"] = "unhealthy: " + err.Error()
|
||||
} else {
|
||||
details["postgres"] = "ok"
|
||||
}
|
||||
|
||||
if err := h.Redis.Ping(ctx).Err(); err != nil {
|
||||
details["redis"] = "unhealthy: " + err.Error()
|
||||
} else {
|
||||
details["redis"] = "ok"
|
||||
}
|
||||
|
||||
status := "ok"
|
||||
for _, v := range details {
|
||||
if v != "ok" {
|
||||
status = "unhealthy"
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
resp := HealthResponse{Status: status, Details: details}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
if status != "ok" {
|
||||
w.WriteHeader(http.StatusServiceUnavailable)
|
||||
}
|
||||
_ = json.NewEncoder(w).Encode(resp)
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package interceptor
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
type LoggerInterceptor struct{}
|
||||
|
||||
func NewLoggerInterceptor() *LoggerInterceptor {
|
||||
return &LoggerInterceptor{}
|
||||
}
|
||||
|
||||
func (i *LoggerInterceptor) Unary() grpc.UnaryServerInterceptor {
|
||||
return func(
|
||||
ctx context.Context,
|
||||
req any,
|
||||
info *grpc.UnaryServerInfo,
|
||||
handler grpc.UnaryHandler,
|
||||
) (any, error) {
|
||||
start := time.Now()
|
||||
|
||||
log.Printf("gRPC method %s called", info.FullMethod)
|
||||
|
||||
resp, err := handler(ctx, req)
|
||||
|
||||
duration := time.Since(start)
|
||||
|
||||
if err != nil {
|
||||
if st, ok := status.FromError(err); ok {
|
||||
log.Printf("error: %s, code: %s, duration: %v",
|
||||
st.Message(), st.Code(), duration)
|
||||
} else {
|
||||
log.Printf("error: %v, duration: %v", err, duration)
|
||||
}
|
||||
} else {
|
||||
log.Printf("method %s completed in %v", info.FullMethod, duration)
|
||||
}
|
||||
|
||||
return resp, err
|
||||
}
|
||||
}
|
||||
|
||||
func (i *LoggerInterceptor) Stream() grpc.StreamServerInterceptor {
|
||||
return func(
|
||||
srv any,
|
||||
stream grpc.ServerStream,
|
||||
info *grpc.StreamServerInfo,
|
||||
handler grpc.StreamHandler,
|
||||
) error {
|
||||
start := time.Now()
|
||||
|
||||
log.Printf("gRPC stream method %s started", info.FullMethod)
|
||||
|
||||
err := handler(srv, stream)
|
||||
|
||||
duration := time.Since(start)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("stream method %s failed: %v, duration: %v",
|
||||
info.FullMethod, err, duration)
|
||||
} else {
|
||||
log.Printf("stream method %s completed in %v",
|
||||
info.FullMethod, duration)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package inmemory
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"datarush/internal/lms/domain"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type OrderRepository struct {
|
||||
mu sync.RWMutex
|
||||
orders map[string]*domain.Order
|
||||
}
|
||||
|
||||
func NewOrderRepository() *OrderRepository {
|
||||
return &OrderRepository{
|
||||
orders: make(map[string]*domain.Order),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *OrderRepository) Create(ctx context.Context, order *domain.Order) error {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
if _, ok := r.orders[order.ID.String()]; ok {
|
||||
return domain.ErrOrderAlreadyExist
|
||||
}
|
||||
r.orders[order.ID.String()] = order
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *OrderRepository) Get(ctx context.Context, id uuid.UUID) (*domain.Order, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
r.mu.RLock()
|
||||
defer r.mu.RUnlock()
|
||||
|
||||
order, ok := r.orders[id.String()]
|
||||
if !ok {
|
||||
return nil, domain.ErrOrderNotFound
|
||||
}
|
||||
|
||||
return order, nil
|
||||
}
|
||||
|
||||
func (r *OrderRepository) Update(ctx context.Context, order *domain.Order) error {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
if _, ok := r.orders[order.ID.String()]; !ok {
|
||||
return domain.ErrOrderNotFound
|
||||
}
|
||||
r.orders[order.ID.String()] = order
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *OrderRepository) Delete(ctx context.Context, id uuid.UUID) error {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
if _, ok := r.orders[id.String()]; !ok {
|
||||
return domain.ErrOrderNotFound
|
||||
}
|
||||
|
||||
delete(r.orders, id.String())
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *OrderRepository) List(ctx context.Context) ([]*domain.Order, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
r.mu.RLock()
|
||||
defer r.mu.RUnlock()
|
||||
|
||||
orders := make([]*domain.Order, 0, len(r.orders))
|
||||
for _, order := range r.orders {
|
||||
orders = append(orders, order)
|
||||
}
|
||||
|
||||
return orders, nil
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"datarush/internal/lms/domain"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type OrderRepository interface {
|
||||
Create(ctx context.Context, order *domain.Order) error
|
||||
Get(ctx context.Context, id uuid.UUID) (*domain.Order, error)
|
||||
Update(ctx context.Context, order *domain.Order) error
|
||||
Delete(ctx context.Context, id uuid.UUID) error
|
||||
List(ctx context.Context) ([]*domain.Order, error)
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"datarush/internal/lms/domain"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
const (
|
||||
orderCachePrefix = "order:"
|
||||
cacheTTL = 5 * time.Minute
|
||||
)
|
||||
|
||||
type OrderRepository struct {
|
||||
db *sqlx.DB
|
||||
redisClient *redis.Client
|
||||
cacheEnable bool
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
CacheEnable bool
|
||||
}
|
||||
|
||||
func NewOrderRepository(db *sqlx.DB, redisClient *redis.Client, config *Config) *OrderRepository {
|
||||
if config == nil {
|
||||
config = &Config{
|
||||
CacheEnable: true,
|
||||
}
|
||||
}
|
||||
|
||||
return &OrderRepository{
|
||||
db: db,
|
||||
redisClient: redisClient,
|
||||
cacheEnable: config.CacheEnable,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *OrderRepository) cacheKey(id string) string {
|
||||
return orderCachePrefix + id
|
||||
}
|
||||
|
||||
func (r *OrderRepository) Create(ctx context.Context, order *domain.Order) error {
|
||||
tx, err := r.db.BeginTxx(ctx, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("begin transaction: %w", err)
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
query := `
|
||||
insert into orders (id, item, quantity)
|
||||
values (:id, :item, :quantity)
|
||||
`
|
||||
|
||||
if _, err := tx.NamedExecContext(ctx, query, order); err != nil {
|
||||
return fmt.Errorf("create order: %w", err)
|
||||
}
|
||||
|
||||
if err := tx.Commit(); err != nil {
|
||||
return fmt.Errorf("commit transaction: %w", err)
|
||||
}
|
||||
|
||||
if r.cacheEnable {
|
||||
if err := r.setCacheWithRetry(ctx, order); err != nil {
|
||||
log.Printf("warn: cache set error for order %s: %v", order.ID, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *OrderRepository) Get(ctx context.Context, id uuid.UUID) (*domain.Order, error) {
|
||||
if r.cacheEnable {
|
||||
if order, err := r.getFromCache(ctx, id.String()); err == nil {
|
||||
return order, nil
|
||||
} else if !errors.Is(err, redis.Nil) {
|
||||
log.Printf("warn: cache get error for order %s: %v", id, err)
|
||||
}
|
||||
}
|
||||
|
||||
const query = `
|
||||
select id, item, quantity
|
||||
from orders
|
||||
where id = $1
|
||||
`
|
||||
|
||||
var order domain.Order
|
||||
if err := r.db.GetContext(ctx, &order, query, id); err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, domain.ErrOrderNotFound
|
||||
}
|
||||
return nil, fmt.Errorf("get order by id: %w", err)
|
||||
}
|
||||
|
||||
if r.cacheEnable {
|
||||
if err := r.setCacheWithRetry(ctx, &order); err != nil {
|
||||
log.Printf("warn: cache set error for order %s: %v", id, err)
|
||||
}
|
||||
}
|
||||
|
||||
return &order, nil
|
||||
}
|
||||
|
||||
func (r *OrderRepository) Update(ctx context.Context, order *domain.Order) error {
|
||||
tx, err := r.db.BeginTxx(ctx, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("begin transaction: %w", err)
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
query := `
|
||||
update orders
|
||||
set item = :item, quantity = :quantity
|
||||
where id = :id
|
||||
`
|
||||
|
||||
result, err := tx.NamedExecContext(ctx, query, order)
|
||||
if err != nil {
|
||||
return fmt.Errorf("update order: %w", err)
|
||||
}
|
||||
|
||||
rowsAffected, err := result.RowsAffected()
|
||||
if err != nil {
|
||||
return fmt.Errorf("get rows affected: %w", err)
|
||||
}
|
||||
|
||||
if rowsAffected == 0 {
|
||||
return domain.ErrOrderNotFound
|
||||
}
|
||||
|
||||
if err := tx.Commit(); err != nil {
|
||||
return fmt.Errorf("commit transaction: %w", err)
|
||||
}
|
||||
|
||||
if r.cacheEnable {
|
||||
if err := r.setCacheWithRetry(ctx, order); err != nil {
|
||||
log.Printf("warn: cache set error for order %s: %v", order.ID, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *OrderRepository) Delete(ctx context.Context, id uuid.UUID) error {
|
||||
tx, err := r.db.BeginTxx(ctx, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("begin transaction: %w", err)
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
const query = `
|
||||
delete from orders
|
||||
where id = $1
|
||||
`
|
||||
|
||||
result, err := tx.ExecContext(ctx, query, id)
|
||||
if err != nil {
|
||||
return fmt.Errorf("delete order: %w", err)
|
||||
}
|
||||
|
||||
rowsAffected, err := result.RowsAffected()
|
||||
if err != nil {
|
||||
return fmt.Errorf("get rows affected: %w", err)
|
||||
}
|
||||
|
||||
if rowsAffected == 0 {
|
||||
return domain.ErrOrderNotFound
|
||||
}
|
||||
|
||||
if err := tx.Commit(); err != nil {
|
||||
return fmt.Errorf("commit transaction: %w", err)
|
||||
}
|
||||
|
||||
r.invalidateCache(ctx, id.String())
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *OrderRepository) List(ctx context.Context) ([]*domain.Order, error) {
|
||||
const query = `
|
||||
select id, item, quantity
|
||||
from orders
|
||||
order by id
|
||||
`
|
||||
|
||||
var orders []*domain.Order
|
||||
if err := r.db.SelectContext(ctx, &orders, query); err != nil {
|
||||
return nil, fmt.Errorf("list orders: %w", err)
|
||||
}
|
||||
|
||||
return orders, nil
|
||||
}
|
||||
|
||||
func (r *OrderRepository) getFromCache(ctx context.Context, id string) (*domain.Order, error) {
|
||||
data, err := r.redisClient.Get(ctx, r.cacheKey(id)).Bytes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var order domain.Order
|
||||
if err := json.Unmarshal(data, &order); err != nil {
|
||||
r.redisClient.Del(ctx, r.cacheKey(id))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &order, nil
|
||||
}
|
||||
|
||||
func (r *OrderRepository) setCacheWithRetry(ctx context.Context, order *domain.Order) error {
|
||||
data, err := json.Marshal(order)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
key := r.cacheKey(order.ID.String())
|
||||
|
||||
err = r.redisClient.Set(ctx, key, data, cacheTTL).Err()
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *OrderRepository) invalidateCache(_ context.Context, id string) {
|
||||
if !r.cacheEnable {
|
||||
return
|
||||
}
|
||||
|
||||
go func() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), r.redisClient.Options().ReadTimeout)
|
||||
defer cancel()
|
||||
|
||||
if err := r.redisClient.Del(ctx, r.cacheKey(id)).Err(); err != nil {
|
||||
log.Printf("warn: cache invalidation failed for order %s: %v", id, err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"datarush/internal/lms/config"
|
||||
"datarush/internal/lms/interceptor"
|
||||
|
||||
grpcHandlers "datarush/internal/lms/handler/grpc"
|
||||
httpHandlers "datarush/internal/lms/handler/http"
|
||||
orderPostgresRepo "datarush/internal/lms/repository/postgres"
|
||||
"datarush/internal/lms/service"
|
||||
|
||||
pb "datarush/pkg/api/order"
|
||||
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"github.com/jmoiron/sqlx"
|
||||
_ "github.com/lib/pq" // postgres driver
|
||||
"github.com/redis/go-redis/v9"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/reflection"
|
||||
)
|
||||
|
||||
const (
|
||||
httpReadTimeout = 10 * time.Second
|
||||
httpWriteTimeout = 10 * time.Second
|
||||
httpIdleTimeout = 60 * time.Second
|
||||
redisRetryCount = 2
|
||||
redisMinRetryBackoff = 50 * time.Millisecond
|
||||
redisMaxRetryBackoff = 200 * time.Millisecond
|
||||
redisDialTimeout = 1 * time.Second
|
||||
redisDialerRetries = 3
|
||||
redisTimeout = 2 * time.Second
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
grpcServer *grpc.Server
|
||||
config *config.Config
|
||||
db *sqlx.DB
|
||||
redisDB *redis.Client
|
||||
}
|
||||
|
||||
func New(cfg *config.Config) *Server {
|
||||
loggerInterceptor := interceptor.NewLoggerInterceptor()
|
||||
|
||||
grpcServer := grpc.NewServer(
|
||||
grpc.UnaryInterceptor(loggerInterceptor.Unary()),
|
||||
grpc.StreamInterceptor(loggerInterceptor.Stream()),
|
||||
)
|
||||
|
||||
return &Server{
|
||||
grpcServer: grpcServer,
|
||||
config: cfg,
|
||||
}
|
||||
}
|
||||
|
||||
func runHTTPHandler(s *Server, grpcServerEndpoint *string) error {
|
||||
ctx := context.Background()
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
|
||||
gwmux := runtime.NewServeMux()
|
||||
opts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}
|
||||
err := pb.RegisterOrderServiceHandlerFromEndpoint(ctx, gwmux, *grpcServerEndpoint, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mux := http.NewServeMux()
|
||||
mux.Handle("/healthz", httpHandlers.NewHealthHandler(s.db, s.redisDB))
|
||||
mux.Handle("/", gwmux)
|
||||
|
||||
srv := &http.Server{
|
||||
Addr: fmt.Sprintf(":%d", s.config.HTTPPort),
|
||||
Handler: mux,
|
||||
ReadTimeout: httpReadTimeout,
|
||||
WriteTimeout: httpWriteTimeout,
|
||||
IdleTimeout: httpIdleTimeout,
|
||||
}
|
||||
|
||||
return srv.ListenAndServe()
|
||||
}
|
||||
|
||||
func getDatabase(cfg config.Config) (*sqlx.DB, error) {
|
||||
db, err := sqlx.Connect("postgres", cfg.BuildPostgresConnStr())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("connect to database: %w", err)
|
||||
}
|
||||
|
||||
return db, nil
|
||||
}
|
||||
|
||||
func getRedis(cfg config.Config) (*redis.Client, error) {
|
||||
conn, err := redis.ParseURL(cfg.RedisURI)
|
||||
client := redis.NewClient(&redis.Options{
|
||||
Addr: conn.Addr,
|
||||
MaxRetries: redisRetryCount,
|
||||
MinRetryBackoff: redisMinRetryBackoff,
|
||||
MaxRetryBackoff: redisMaxRetryBackoff,
|
||||
DialTimeout: redisDialTimeout,
|
||||
DialerRetries: redisDialerRetries,
|
||||
DialerRetryTimeout: redisDialTimeout,
|
||||
ReadTimeout: redisTimeout,
|
||||
WriteTimeout: redisTimeout,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parse Redis URI: %w", err)
|
||||
}
|
||||
|
||||
_, err = client.Ping(context.Background()).Result()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("connect to Redis server: %w", err)
|
||||
}
|
||||
|
||||
return client, nil
|
||||
}
|
||||
|
||||
func (s *Server) RegisterServices() {
|
||||
db, err := getDatabase(*s.config)
|
||||
if err != nil {
|
||||
log.Print(err)
|
||||
}
|
||||
s.db = db
|
||||
|
||||
redisDB, err := getRedis(*s.config)
|
||||
if err != nil {
|
||||
log.Print(err)
|
||||
}
|
||||
s.redisDB = redisDB
|
||||
|
||||
orderRepo := orderPostgresRepo.NewOrderRepository(db, redisDB, &orderPostgresRepo.Config{CacheEnable: true})
|
||||
orderService := service.NewOrderService(orderRepo)
|
||||
orderHandler := grpcHandlers.NewOrderHandler(orderService)
|
||||
|
||||
pb.RegisterOrderServiceServer(s.grpcServer, orderHandler)
|
||||
|
||||
if s.config.GRPCEnableReflection {
|
||||
reflection.Register(s.grpcServer)
|
||||
log.Println("gRPC server will start with reflection")
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) Start() error {
|
||||
addr := fmt.Sprintf(":%d", s.config.GRPCPort)
|
||||
lis, err := net.Listen("tcp", addr) //nolint:noctx // no need to use context here
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to listen: %w", err)
|
||||
}
|
||||
|
||||
if s.config.EnableHTTPHandler {
|
||||
go func() {
|
||||
log.Printf("starting HTTP gateway on port %d", s.config.HTTPPort)
|
||||
if err := runHTTPHandler(s, &addr); err != nil {
|
||||
log.Printf("HTTP gateway failed: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
log.Printf("starting gRPC server on port %d", s.config.GRPCPort)
|
||||
|
||||
if err := s.grpcServer.Serve(lis); err != nil {
|
||||
return fmt.Errorf("failed to serve: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Server) Stop() {
|
||||
s.grpcServer.GracefulStop()
|
||||
log.Println("gRPC server stopped gracefully")
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"datarush/internal/lms/domain"
|
||||
"datarush/internal/lms/repository"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type OrderService struct {
|
||||
repo repository.OrderRepository
|
||||
}
|
||||
|
||||
func NewOrderService(repo repository.OrderRepository) *OrderService {
|
||||
return &OrderService{
|
||||
repo: repo,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *OrderService) Create(ctx context.Context, item string, quantity int32) (*domain.Order, error) {
|
||||
order, err := domain.NewOrder(uuid.New(), item, quantity)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := s.repo.Create(ctx, order); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return order, nil
|
||||
}
|
||||
|
||||
func (s *OrderService) Get(ctx context.Context, id uuid.UUID) (*domain.Order, error) {
|
||||
return s.repo.Get(ctx, id)
|
||||
}
|
||||
|
||||
func (s *OrderService) Update(ctx context.Context, id uuid.UUID, item string, quantity int32) (*domain.Order, error) {
|
||||
order, err := domain.NewOrder(id, item, quantity)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := s.repo.Update(ctx, order); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return order, nil
|
||||
}
|
||||
|
||||
func (s *OrderService) Delete(ctx context.Context, id uuid.UUID) error {
|
||||
return s.repo.Delete(ctx, id)
|
||||
}
|
||||
|
||||
func (s *OrderService) List(ctx context.Context) ([]*domain.Order, error) {
|
||||
return s.repo.List(ctx)
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,894 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.10
|
||||
// protoc v6.33.2
|
||||
// source: api/proto/auth.proto
|
||||
|
||||
package auth
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type SignUpRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"`
|
||||
Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
|
||||
Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *SignUpRequest) Reset() {
|
||||
*x = SignUpRequest{}
|
||||
mi := &file_api_proto_auth_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *SignUpRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SignUpRequest) ProtoMessage() {}
|
||||
|
||||
func (x *SignUpRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_auth_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SignUpRequest.ProtoReflect.Descriptor instead.
|
||||
func (*SignUpRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_auth_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *SignUpRequest) GetEmail() string {
|
||||
if x != nil {
|
||||
return x.Email
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SignUpRequest) GetUsername() string {
|
||||
if x != nil {
|
||||
return x.Username
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SignUpRequest) GetPassword() string {
|
||||
if x != nil {
|
||||
return x.Password
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type SignUpResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *SignUpResponse) Reset() {
|
||||
*x = SignUpResponse{}
|
||||
mi := &file_api_proto_auth_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *SignUpResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SignUpResponse) ProtoMessage() {}
|
||||
|
||||
func (x *SignUpResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_auth_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SignUpResponse.ProtoReflect.Descriptor instead.
|
||||
func (*SignUpResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_auth_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *SignUpResponse) GetToken() string {
|
||||
if x != nil {
|
||||
return x.Token
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type SignInRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"`
|
||||
Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *SignInRequest) Reset() {
|
||||
*x = SignInRequest{}
|
||||
mi := &file_api_proto_auth_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *SignInRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SignInRequest) ProtoMessage() {}
|
||||
|
||||
func (x *SignInRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_auth_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SignInRequest.ProtoReflect.Descriptor instead.
|
||||
func (*SignInRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_auth_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *SignInRequest) GetEmail() string {
|
||||
if x != nil {
|
||||
return x.Email
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SignInRequest) GetPassword() string {
|
||||
if x != nil {
|
||||
return x.Password
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type SignInResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *SignInResponse) Reset() {
|
||||
*x = SignInResponse{}
|
||||
mi := &file_api_proto_auth_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *SignInResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SignInResponse) ProtoMessage() {}
|
||||
|
||||
func (x *SignInResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_auth_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SignInResponse.ProtoReflect.Descriptor instead.
|
||||
func (*SignInResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_auth_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *SignInResponse) GetToken() string {
|
||||
if x != nil {
|
||||
return x.Token
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetMeRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetMeRequest) Reset() {
|
||||
*x = GetMeRequest{}
|
||||
mi := &file_api_proto_auth_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetMeRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetMeRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetMeRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_auth_proto_msgTypes[4]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetMeRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetMeRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_auth_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
type GetMeResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetMeResponse) Reset() {
|
||||
*x = GetMeResponse{}
|
||||
mi := &file_api_proto_auth_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetMeResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetMeResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetMeResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_auth_proto_msgTypes[5]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetMeResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetMeResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_auth_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *GetMeResponse) GetUser() *User {
|
||||
if x != nil {
|
||||
return x.User
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type GetUserRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetUserRequest) Reset() {
|
||||
*x = GetUserRequest{}
|
||||
mi := &file_api_proto_auth_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetUserRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetUserRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetUserRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_auth_proto_msgTypes[6]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetUserRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetUserRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_auth_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *GetUserRequest) GetUserId() string {
|
||||
if x != nil {
|
||||
return x.UserId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetUserResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetUserResponse) Reset() {
|
||||
*x = GetUserResponse{}
|
||||
mi := &file_api_proto_auth_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetUserResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetUserResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetUserResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_auth_proto_msgTypes[7]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetUserResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetUserResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_auth_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *GetUserResponse) GetUser() *User {
|
||||
if x != nil {
|
||||
return x.User
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type GetMyStatRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetMyStatRequest) Reset() {
|
||||
*x = GetMyStatRequest{}
|
||||
mi := &file_api_proto_auth_proto_msgTypes[8]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetMyStatRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetMyStatRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetMyStatRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_auth_proto_msgTypes[8]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetMyStatRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetMyStatRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_auth_proto_rawDescGZIP(), []int{8}
|
||||
}
|
||||
|
||||
type GetMyStatResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Stat *Stat `protobuf:"bytes,1,opt,name=stat,proto3" json:"stat,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetMyStatResponse) Reset() {
|
||||
*x = GetMyStatResponse{}
|
||||
mi := &file_api_proto_auth_proto_msgTypes[9]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetMyStatResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetMyStatResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetMyStatResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_auth_proto_msgTypes[9]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetMyStatResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetMyStatResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_auth_proto_rawDescGZIP(), []int{9}
|
||||
}
|
||||
|
||||
func (x *GetMyStatResponse) GetStat() *Stat {
|
||||
if x != nil {
|
||||
return x.Stat
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type GetLeaderboardRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetLeaderboardRequest) Reset() {
|
||||
*x = GetLeaderboardRequest{}
|
||||
mi := &file_api_proto_auth_proto_msgTypes[10]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetLeaderboardRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetLeaderboardRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetLeaderboardRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_auth_proto_msgTypes[10]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetLeaderboardRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetLeaderboardRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_auth_proto_rawDescGZIP(), []int{10}
|
||||
}
|
||||
|
||||
type GetLeaderboardResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Users []*User `protobuf:"bytes,1,rep,name=users,proto3" json:"users,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetLeaderboardResponse) Reset() {
|
||||
*x = GetLeaderboardResponse{}
|
||||
mi := &file_api_proto_auth_proto_msgTypes[11]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetLeaderboardResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetLeaderboardResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetLeaderboardResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_auth_proto_msgTypes[11]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetLeaderboardResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetLeaderboardResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_auth_proto_rawDescGZIP(), []int{11}
|
||||
}
|
||||
|
||||
func (x *GetLeaderboardResponse) GetUsers() []*User {
|
||||
if x != nil {
|
||||
return x.Users
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type User struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Id *string `protobuf:"bytes,1,opt,name=id,proto3,oneof" json:"id,omitempty"`
|
||||
Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`
|
||||
Username string `protobuf:"bytes,3,opt,name=username,proto3" json:"username,omitempty"`
|
||||
Avatar *string `protobuf:"bytes,4,opt,name=avatar,proto3,oneof" json:"avatar,omitempty"`
|
||||
CreatedAt string `protobuf:"bytes,5,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
|
||||
Achievements []*UserAchievement `protobuf:"bytes,6,rep,name=achievements,proto3" json:"achievements,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *User) Reset() {
|
||||
*x = User{}
|
||||
mi := &file_api_proto_auth_proto_msgTypes[12]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *User) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*User) ProtoMessage() {}
|
||||
|
||||
func (x *User) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_auth_proto_msgTypes[12]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use User.ProtoReflect.Descriptor instead.
|
||||
func (*User) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_auth_proto_rawDescGZIP(), []int{12}
|
||||
}
|
||||
|
||||
func (x *User) GetId() string {
|
||||
if x != nil && x.Id != nil {
|
||||
return *x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *User) GetEmail() string {
|
||||
if x != nil {
|
||||
return x.Email
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *User) GetUsername() string {
|
||||
if x != nil {
|
||||
return x.Username
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *User) GetAvatar() string {
|
||||
if x != nil && x.Avatar != nil {
|
||||
return *x.Avatar
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *User) GetCreatedAt() string {
|
||||
if x != nil {
|
||||
return x.CreatedAt
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *User) GetAchievements() []*UserAchievement {
|
||||
if x != nil {
|
||||
return x.Achievements
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type UserAchievement struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
|
||||
Icon string `protobuf:"bytes,3,opt,name=icon,proto3" json:"icon,omitempty"`
|
||||
ReceivedAt string `protobuf:"bytes,4,opt,name=received_at,json=receivedAt,proto3" json:"received_at,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *UserAchievement) Reset() {
|
||||
*x = UserAchievement{}
|
||||
mi := &file_api_proto_auth_proto_msgTypes[13]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *UserAchievement) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UserAchievement) ProtoMessage() {}
|
||||
|
||||
func (x *UserAchievement) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_auth_proto_msgTypes[13]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UserAchievement.ProtoReflect.Descriptor instead.
|
||||
func (*UserAchievement) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_auth_proto_rawDescGZIP(), []int{13}
|
||||
}
|
||||
|
||||
func (x *UserAchievement) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UserAchievement) GetDescription() string {
|
||||
if x != nil {
|
||||
return x.Description
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UserAchievement) GetIcon() string {
|
||||
if x != nil {
|
||||
return x.Icon
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UserAchievement) GetReceivedAt() string {
|
||||
if x != nil {
|
||||
return x.ReceivedAt
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type Stat struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
TotalAttempts int32 `protobuf:"varint,1,opt,name=total_attempts,json=totalAttempts,proto3" json:"total_attempts,omitempty"`
|
||||
SolvedTasks int32 `protobuf:"varint,2,opt,name=solved_tasks,json=solvedTasks,proto3" json:"solved_tasks,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Stat) Reset() {
|
||||
*x = Stat{}
|
||||
mi := &file_api_proto_auth_proto_msgTypes[14]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Stat) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Stat) ProtoMessage() {}
|
||||
|
||||
func (x *Stat) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_auth_proto_msgTypes[14]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Stat.ProtoReflect.Descriptor instead.
|
||||
func (*Stat) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_auth_proto_rawDescGZIP(), []int{14}
|
||||
}
|
||||
|
||||
func (x *Stat) GetTotalAttempts() int32 {
|
||||
if x != nil {
|
||||
return x.TotalAttempts
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Stat) GetSolvedTasks() int32 {
|
||||
if x != nil {
|
||||
return x.SolvedTasks
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_api_proto_auth_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_api_proto_auth_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x14api/proto/auth.proto\x12\x04auth\"]\n" +
|
||||
"\rSignUpRequest\x12\x14\n" +
|
||||
"\x05email\x18\x01 \x01(\tR\x05email\x12\x1a\n" +
|
||||
"\busername\x18\x02 \x01(\tR\busername\x12\x1a\n" +
|
||||
"\bpassword\x18\x03 \x01(\tR\bpassword\"&\n" +
|
||||
"\x0eSignUpResponse\x12\x14\n" +
|
||||
"\x05token\x18\x01 \x01(\tR\x05token\"A\n" +
|
||||
"\rSignInRequest\x12\x14\n" +
|
||||
"\x05email\x18\x01 \x01(\tR\x05email\x12\x1a\n" +
|
||||
"\bpassword\x18\x02 \x01(\tR\bpassword\"&\n" +
|
||||
"\x0eSignInResponse\x12\x14\n" +
|
||||
"\x05token\x18\x01 \x01(\tR\x05token\"\x0e\n" +
|
||||
"\fGetMeRequest\"/\n" +
|
||||
"\rGetMeResponse\x12\x1e\n" +
|
||||
"\x04user\x18\x01 \x01(\v2\n" +
|
||||
".auth.UserR\x04user\")\n" +
|
||||
"\x0eGetUserRequest\x12\x17\n" +
|
||||
"\auser_id\x18\x01 \x01(\tR\x06userId\"1\n" +
|
||||
"\x0fGetUserResponse\x12\x1e\n" +
|
||||
"\x04user\x18\x01 \x01(\v2\n" +
|
||||
".auth.UserR\x04user\"\x12\n" +
|
||||
"\x10GetMyStatRequest\"3\n" +
|
||||
"\x11GetMyStatResponse\x12\x1e\n" +
|
||||
"\x04stat\x18\x01 \x01(\v2\n" +
|
||||
".auth.StatR\x04stat\"\x17\n" +
|
||||
"\x15GetLeaderboardRequest\":\n" +
|
||||
"\x16GetLeaderboardResponse\x12 \n" +
|
||||
"\x05users\x18\x01 \x03(\v2\n" +
|
||||
".auth.UserR\x05users\"\xd6\x01\n" +
|
||||
"\x04User\x12\x13\n" +
|
||||
"\x02id\x18\x01 \x01(\tH\x00R\x02id\x88\x01\x01\x12\x14\n" +
|
||||
"\x05email\x18\x02 \x01(\tR\x05email\x12\x1a\n" +
|
||||
"\busername\x18\x03 \x01(\tR\busername\x12\x1b\n" +
|
||||
"\x06avatar\x18\x04 \x01(\tH\x01R\x06avatar\x88\x01\x01\x12\x1d\n" +
|
||||
"\n" +
|
||||
"created_at\x18\x05 \x01(\tR\tcreatedAt\x129\n" +
|
||||
"\fachievements\x18\x06 \x03(\v2\x15.auth.UserAchievementR\fachievementsB\x05\n" +
|
||||
"\x03_idB\t\n" +
|
||||
"\a_avatar\"|\n" +
|
||||
"\x0fUserAchievement\x12\x12\n" +
|
||||
"\x04name\x18\x01 \x01(\tR\x04name\x12 \n" +
|
||||
"\vdescription\x18\x02 \x01(\tR\vdescription\x12\x12\n" +
|
||||
"\x04icon\x18\x03 \x01(\tR\x04icon\x12\x1f\n" +
|
||||
"\vreceived_at\x18\x04 \x01(\tR\n" +
|
||||
"receivedAt\"P\n" +
|
||||
"\x04Stat\x12%\n" +
|
||||
"\x0etotal_attempts\x18\x01 \x01(\x05R\rtotalAttempts\x12!\n" +
|
||||
"\fsolved_tasks\x18\x02 \x01(\x05R\vsolvedTasks2\xec\x02\n" +
|
||||
"\vAuthService\x123\n" +
|
||||
"\x06SignUp\x12\x13.auth.SignUpRequest\x1a\x14.auth.SignUpResponse\x123\n" +
|
||||
"\x06SignIn\x12\x13.auth.SignInRequest\x1a\x14.auth.SignInResponse\x120\n" +
|
||||
"\x05GetMe\x12\x12.auth.GetMeRequest\x1a\x13.auth.GetMeResponse\x126\n" +
|
||||
"\aGetUser\x12\x14.auth.GetUserRequest\x1a\x15.auth.GetUserResponse\x12<\n" +
|
||||
"\tGetMyStat\x12\x16.auth.GetMyStatRequest\x1a\x17.auth.GetMyStatResponse\x12K\n" +
|
||||
"\x0eGetLeaderboard\x12\x1b.auth.GetLeaderboardRequest\x1a\x1c.auth.GetLeaderboardResponseB\x0eZ\fpkg/api/authb\x06proto3"
|
||||
|
||||
var (
|
||||
file_api_proto_auth_proto_rawDescOnce sync.Once
|
||||
file_api_proto_auth_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_api_proto_auth_proto_rawDescGZIP() []byte {
|
||||
file_api_proto_auth_proto_rawDescOnce.Do(func() {
|
||||
file_api_proto_auth_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_proto_auth_proto_rawDesc), len(file_api_proto_auth_proto_rawDesc)))
|
||||
})
|
||||
return file_api_proto_auth_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_api_proto_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 15)
|
||||
var file_api_proto_auth_proto_goTypes = []any{
|
||||
(*SignUpRequest)(nil), // 0: auth.SignUpRequest
|
||||
(*SignUpResponse)(nil), // 1: auth.SignUpResponse
|
||||
(*SignInRequest)(nil), // 2: auth.SignInRequest
|
||||
(*SignInResponse)(nil), // 3: auth.SignInResponse
|
||||
(*GetMeRequest)(nil), // 4: auth.GetMeRequest
|
||||
(*GetMeResponse)(nil), // 5: auth.GetMeResponse
|
||||
(*GetUserRequest)(nil), // 6: auth.GetUserRequest
|
||||
(*GetUserResponse)(nil), // 7: auth.GetUserResponse
|
||||
(*GetMyStatRequest)(nil), // 8: auth.GetMyStatRequest
|
||||
(*GetMyStatResponse)(nil), // 9: auth.GetMyStatResponse
|
||||
(*GetLeaderboardRequest)(nil), // 10: auth.GetLeaderboardRequest
|
||||
(*GetLeaderboardResponse)(nil), // 11: auth.GetLeaderboardResponse
|
||||
(*User)(nil), // 12: auth.User
|
||||
(*UserAchievement)(nil), // 13: auth.UserAchievement
|
||||
(*Stat)(nil), // 14: auth.Stat
|
||||
}
|
||||
var file_api_proto_auth_proto_depIdxs = []int32{
|
||||
12, // 0: auth.GetMeResponse.user:type_name -> auth.User
|
||||
12, // 1: auth.GetUserResponse.user:type_name -> auth.User
|
||||
14, // 2: auth.GetMyStatResponse.stat:type_name -> auth.Stat
|
||||
12, // 3: auth.GetLeaderboardResponse.users:type_name -> auth.User
|
||||
13, // 4: auth.User.achievements:type_name -> auth.UserAchievement
|
||||
0, // 5: auth.AuthService.SignUp:input_type -> auth.SignUpRequest
|
||||
2, // 6: auth.AuthService.SignIn:input_type -> auth.SignInRequest
|
||||
4, // 7: auth.AuthService.GetMe:input_type -> auth.GetMeRequest
|
||||
6, // 8: auth.AuthService.GetUser:input_type -> auth.GetUserRequest
|
||||
8, // 9: auth.AuthService.GetMyStat:input_type -> auth.GetMyStatRequest
|
||||
10, // 10: auth.AuthService.GetLeaderboard:input_type -> auth.GetLeaderboardRequest
|
||||
1, // 11: auth.AuthService.SignUp:output_type -> auth.SignUpResponse
|
||||
3, // 12: auth.AuthService.SignIn:output_type -> auth.SignInResponse
|
||||
5, // 13: auth.AuthService.GetMe:output_type -> auth.GetMeResponse
|
||||
7, // 14: auth.AuthService.GetUser:output_type -> auth.GetUserResponse
|
||||
9, // 15: auth.AuthService.GetMyStat:output_type -> auth.GetMyStatResponse
|
||||
11, // 16: auth.AuthService.GetLeaderboard:output_type -> auth.GetLeaderboardResponse
|
||||
11, // [11:17] is the sub-list for method output_type
|
||||
5, // [5:11] is the sub-list for method input_type
|
||||
5, // [5:5] is the sub-list for extension type_name
|
||||
5, // [5:5] is the sub-list for extension extendee
|
||||
0, // [0:5] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_api_proto_auth_proto_init() }
|
||||
func file_api_proto_auth_proto_init() {
|
||||
if File_api_proto_auth_proto != nil {
|
||||
return
|
||||
}
|
||||
file_api_proto_auth_proto_msgTypes[12].OneofWrappers = []any{}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_proto_auth_proto_rawDesc), len(file_api_proto_auth_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 15,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_api_proto_auth_proto_goTypes,
|
||||
DependencyIndexes: file_api_proto_auth_proto_depIdxs,
|
||||
MessageInfos: file_api_proto_auth_proto_msgTypes,
|
||||
}.Build()
|
||||
File_api_proto_auth_proto = out.File
|
||||
file_api_proto_auth_proto_goTypes = nil
|
||||
file_api_proto_auth_proto_depIdxs = nil
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v6.33.2
|
||||
// source: api/proto/auth.proto
|
||||
|
||||
package auth
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
AuthService_SignUp_FullMethodName = "/auth.AuthService/SignUp"
|
||||
AuthService_SignIn_FullMethodName = "/auth.AuthService/SignIn"
|
||||
AuthService_GetMe_FullMethodName = "/auth.AuthService/GetMe"
|
||||
AuthService_GetUser_FullMethodName = "/auth.AuthService/GetUser"
|
||||
AuthService_GetMyStat_FullMethodName = "/auth.AuthService/GetMyStat"
|
||||
AuthService_GetLeaderboard_FullMethodName = "/auth.AuthService/GetLeaderboard"
|
||||
)
|
||||
|
||||
// AuthServiceClient is the client API for AuthService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type AuthServiceClient interface {
|
||||
SignUp(ctx context.Context, in *SignUpRequest, opts ...grpc.CallOption) (*SignUpResponse, error)
|
||||
SignIn(ctx context.Context, in *SignInRequest, opts ...grpc.CallOption) (*SignInResponse, error)
|
||||
GetMe(ctx context.Context, in *GetMeRequest, opts ...grpc.CallOption) (*GetMeResponse, error)
|
||||
GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*GetUserResponse, error)
|
||||
GetMyStat(ctx context.Context, in *GetMyStatRequest, opts ...grpc.CallOption) (*GetMyStatResponse, error)
|
||||
GetLeaderboard(ctx context.Context, in *GetLeaderboardRequest, opts ...grpc.CallOption) (*GetLeaderboardResponse, error)
|
||||
}
|
||||
|
||||
type authServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewAuthServiceClient(cc grpc.ClientConnInterface) AuthServiceClient {
|
||||
return &authServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *authServiceClient) SignUp(ctx context.Context, in *SignUpRequest, opts ...grpc.CallOption) (*SignUpResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(SignUpResponse)
|
||||
err := c.cc.Invoke(ctx, AuthService_SignUp_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *authServiceClient) SignIn(ctx context.Context, in *SignInRequest, opts ...grpc.CallOption) (*SignInResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(SignInResponse)
|
||||
err := c.cc.Invoke(ctx, AuthService_SignIn_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *authServiceClient) GetMe(ctx context.Context, in *GetMeRequest, opts ...grpc.CallOption) (*GetMeResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetMeResponse)
|
||||
err := c.cc.Invoke(ctx, AuthService_GetMe_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *authServiceClient) GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*GetUserResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetUserResponse)
|
||||
err := c.cc.Invoke(ctx, AuthService_GetUser_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *authServiceClient) GetMyStat(ctx context.Context, in *GetMyStatRequest, opts ...grpc.CallOption) (*GetMyStatResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetMyStatResponse)
|
||||
err := c.cc.Invoke(ctx, AuthService_GetMyStat_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *authServiceClient) GetLeaderboard(ctx context.Context, in *GetLeaderboardRequest, opts ...grpc.CallOption) (*GetLeaderboardResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetLeaderboardResponse)
|
||||
err := c.cc.Invoke(ctx, AuthService_GetLeaderboard_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// AuthServiceServer is the server API for AuthService service.
|
||||
// All implementations must embed UnimplementedAuthServiceServer
|
||||
// for forward compatibility.
|
||||
type AuthServiceServer interface {
|
||||
SignUp(context.Context, *SignUpRequest) (*SignUpResponse, error)
|
||||
SignIn(context.Context, *SignInRequest) (*SignInResponse, error)
|
||||
GetMe(context.Context, *GetMeRequest) (*GetMeResponse, error)
|
||||
GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error)
|
||||
GetMyStat(context.Context, *GetMyStatRequest) (*GetMyStatResponse, error)
|
||||
GetLeaderboard(context.Context, *GetLeaderboardRequest) (*GetLeaderboardResponse, error)
|
||||
mustEmbedUnimplementedAuthServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedAuthServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedAuthServiceServer struct{}
|
||||
|
||||
func (UnimplementedAuthServiceServer) SignUp(context.Context, *SignUpRequest) (*SignUpResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SignUp not implemented")
|
||||
}
|
||||
func (UnimplementedAuthServiceServer) SignIn(context.Context, *SignInRequest) (*SignInResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SignIn not implemented")
|
||||
}
|
||||
func (UnimplementedAuthServiceServer) GetMe(context.Context, *GetMeRequest) (*GetMeResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetMe not implemented")
|
||||
}
|
||||
func (UnimplementedAuthServiceServer) GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetUser not implemented")
|
||||
}
|
||||
func (UnimplementedAuthServiceServer) GetMyStat(context.Context, *GetMyStatRequest) (*GetMyStatResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetMyStat not implemented")
|
||||
}
|
||||
func (UnimplementedAuthServiceServer) GetLeaderboard(context.Context, *GetLeaderboardRequest) (*GetLeaderboardResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetLeaderboard not implemented")
|
||||
}
|
||||
func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {}
|
||||
func (UnimplementedAuthServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeAuthServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to AuthServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeAuthServiceServer interface {
|
||||
mustEmbedUnimplementedAuthServiceServer()
|
||||
}
|
||||
|
||||
func RegisterAuthServiceServer(s grpc.ServiceRegistrar, srv AuthServiceServer) {
|
||||
// If the following call pancis, it indicates UnimplementedAuthServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&AuthService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _AuthService_SignUp_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SignUpRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AuthServiceServer).SignUp(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: AuthService_SignUp_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthServiceServer).SignUp(ctx, req.(*SignUpRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AuthService_SignIn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SignInRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AuthServiceServer).SignIn(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: AuthService_SignIn_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthServiceServer).SignIn(ctx, req.(*SignInRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AuthService_GetMe_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetMeRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AuthServiceServer).GetMe(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: AuthService_GetMe_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthServiceServer).GetMe(ctx, req.(*GetMeRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AuthService_GetUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetUserRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AuthServiceServer).GetUser(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: AuthService_GetUser_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthServiceServer).GetUser(ctx, req.(*GetUserRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AuthService_GetMyStat_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetMyStatRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AuthServiceServer).GetMyStat(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: AuthService_GetMyStat_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthServiceServer).GetMyStat(ctx, req.(*GetMyStatRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AuthService_GetLeaderboard_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetLeaderboardRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AuthServiceServer).GetLeaderboard(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: AuthService_GetLeaderboard_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthServiceServer).GetLeaderboard(ctx, req.(*GetLeaderboardRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// AuthService_ServiceDesc is the grpc.ServiceDesc for AuthService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var AuthService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "auth.AuthService",
|
||||
HandlerType: (*AuthServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "SignUp",
|
||||
Handler: _AuthService_SignUp_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "SignIn",
|
||||
Handler: _AuthService_SignIn_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetMe",
|
||||
Handler: _AuthService_GetMe_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetUser",
|
||||
Handler: _AuthService_GetUser_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetMyStat",
|
||||
Handler: _AuthService_GetMyStat_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetLeaderboard",
|
||||
Handler: _AuthService_GetLeaderboard_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api/proto/auth.proto",
|
||||
}
|
||||
@@ -0,0 +1,566 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.10
|
||||
// protoc v6.33.2
|
||||
// source: api/proto/competition.proto
|
||||
|
||||
package competition
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type CompetitionState int32
|
||||
|
||||
const (
|
||||
CompetitionState_COMPETITION_STATE_UNSPECIFIED CompetitionState = 0
|
||||
CompetitionState_COMPETITION_STATE_NOT_STARTED CompetitionState = 1
|
||||
CompetitionState_COMPETITION_STATE_STARTED CompetitionState = 2
|
||||
CompetitionState_COMPETITION_STATE_FINISHED CompetitionState = 3
|
||||
)
|
||||
|
||||
// Enum value maps for CompetitionState.
|
||||
var (
|
||||
CompetitionState_name = map[int32]string{
|
||||
0: "COMPETITION_STATE_UNSPECIFIED",
|
||||
1: "COMPETITION_STATE_NOT_STARTED",
|
||||
2: "COMPETITION_STATE_STARTED",
|
||||
3: "COMPETITION_STATE_FINISHED",
|
||||
}
|
||||
CompetitionState_value = map[string]int32{
|
||||
"COMPETITION_STATE_UNSPECIFIED": 0,
|
||||
"COMPETITION_STATE_NOT_STARTED": 1,
|
||||
"COMPETITION_STATE_STARTED": 2,
|
||||
"COMPETITION_STATE_FINISHED": 3,
|
||||
}
|
||||
)
|
||||
|
||||
func (x CompetitionState) Enum() *CompetitionState {
|
||||
p := new(CompetitionState)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
|
||||
func (x CompetitionState) String() string {
|
||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||
}
|
||||
|
||||
func (CompetitionState) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_api_proto_competition_proto_enumTypes[0].Descriptor()
|
||||
}
|
||||
|
||||
func (CompetitionState) Type() protoreflect.EnumType {
|
||||
return &file_api_proto_competition_proto_enumTypes[0]
|
||||
}
|
||||
|
||||
func (x CompetitionState) Number() protoreflect.EnumNumber {
|
||||
return protoreflect.EnumNumber(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use CompetitionState.Descriptor instead.
|
||||
func (CompetitionState) EnumDescriptor() ([]byte, []int) {
|
||||
return file_api_proto_competition_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
type GetCompetitionRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
CompetitionId string `protobuf:"bytes,1,opt,name=competition_id,json=competitionId,proto3" json:"competition_id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetCompetitionRequest) Reset() {
|
||||
*x = GetCompetitionRequest{}
|
||||
mi := &file_api_proto_competition_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetCompetitionRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetCompetitionRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetCompetitionRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_competition_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetCompetitionRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetCompetitionRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_competition_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *GetCompetitionRequest) GetCompetitionId() string {
|
||||
if x != nil {
|
||||
return x.CompetitionId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetCompetitionResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Competition *Competition `protobuf:"bytes,1,opt,name=competition,proto3" json:"competition,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetCompetitionResponse) Reset() {
|
||||
*x = GetCompetitionResponse{}
|
||||
mi := &file_api_proto_competition_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetCompetitionResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetCompetitionResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetCompetitionResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_competition_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetCompetitionResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetCompetitionResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_competition_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *GetCompetitionResponse) GetCompetition() *Competition {
|
||||
if x != nil {
|
||||
return x.Competition
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ListCompetitionsRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
IsParticipating bool `protobuf:"varint,1,opt,name=is_participating,json=isParticipating,proto3" json:"is_participating,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ListCompetitionsRequest) Reset() {
|
||||
*x = ListCompetitionsRequest{}
|
||||
mi := &file_api_proto_competition_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ListCompetitionsRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ListCompetitionsRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ListCompetitionsRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_competition_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ListCompetitionsRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ListCompetitionsRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_competition_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *ListCompetitionsRequest) GetIsParticipating() bool {
|
||||
if x != nil {
|
||||
return x.IsParticipating
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type ListCompetitionsResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Competitions []*Competition `protobuf:"bytes,1,rep,name=competitions,proto3" json:"competitions,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ListCompetitionsResponse) Reset() {
|
||||
*x = ListCompetitionsResponse{}
|
||||
mi := &file_api_proto_competition_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ListCompetitionsResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ListCompetitionsResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ListCompetitionsResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_competition_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ListCompetitionsResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ListCompetitionsResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_competition_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *ListCompetitionsResponse) GetCompetitions() []*Competition {
|
||||
if x != nil {
|
||||
return x.Competitions
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ChangeCompetitionStateRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
CompetitionId string `protobuf:"bytes,1,opt,name=competition_id,json=competitionId,proto3" json:"competition_id,omitempty"`
|
||||
State CompetitionState `protobuf:"varint,2,opt,name=state,proto3,enum=competition.CompetitionState" json:"state,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ChangeCompetitionStateRequest) Reset() {
|
||||
*x = ChangeCompetitionStateRequest{}
|
||||
mi := &file_api_proto_competition_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ChangeCompetitionStateRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ChangeCompetitionStateRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ChangeCompetitionStateRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_competition_proto_msgTypes[4]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ChangeCompetitionStateRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ChangeCompetitionStateRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_competition_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *ChangeCompetitionStateRequest) GetCompetitionId() string {
|
||||
if x != nil {
|
||||
return x.CompetitionId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ChangeCompetitionStateRequest) GetState() CompetitionState {
|
||||
if x != nil {
|
||||
return x.State
|
||||
}
|
||||
return CompetitionState_COMPETITION_STATE_UNSPECIFIED
|
||||
}
|
||||
|
||||
type ChangeCompetitionStateResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
State CompetitionState `protobuf:"varint,1,opt,name=state,proto3,enum=competition.CompetitionState" json:"state,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ChangeCompetitionStateResponse) Reset() {
|
||||
*x = ChangeCompetitionStateResponse{}
|
||||
mi := &file_api_proto_competition_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ChangeCompetitionStateResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ChangeCompetitionStateResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ChangeCompetitionStateResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_competition_proto_msgTypes[5]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ChangeCompetitionStateResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ChangeCompetitionStateResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_competition_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *ChangeCompetitionStateResponse) GetState() CompetitionState {
|
||||
if x != nil {
|
||||
return x.State
|
||||
}
|
||||
return CompetitionState_COMPETITION_STATE_UNSPECIFIED
|
||||
}
|
||||
|
||||
type Competition struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
State CompetitionState `protobuf:"varint,2,opt,name=state,proto3,enum=competition.CompetitionState" json:"state,omitempty"`
|
||||
Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"`
|
||||
Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"`
|
||||
ImageUrl *string `protobuf:"bytes,5,opt,name=image_url,json=imageUrl,proto3,oneof" json:"image_url,omitempty"`
|
||||
EndDate *string `protobuf:"bytes,6,opt,name=end_date,json=endDate,proto3,oneof" json:"end_date,omitempty"`
|
||||
StartDate *string `protobuf:"bytes,7,opt,name=start_date,json=startDate,proto3,oneof" json:"start_date,omitempty"`
|
||||
Type string `protobuf:"bytes,8,opt,name=type,proto3" json:"type,omitempty"`
|
||||
ParticipationType string `protobuf:"bytes,9,opt,name=participation_type,json=participationType,proto3" json:"participation_type,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Competition) Reset() {
|
||||
*x = Competition{}
|
||||
mi := &file_api_proto_competition_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Competition) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Competition) ProtoMessage() {}
|
||||
|
||||
func (x *Competition) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_proto_competition_proto_msgTypes[6]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Competition.ProtoReflect.Descriptor instead.
|
||||
func (*Competition) Descriptor() ([]byte, []int) {
|
||||
return file_api_proto_competition_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *Competition) GetId() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Competition) GetState() CompetitionState {
|
||||
if x != nil {
|
||||
return x.State
|
||||
}
|
||||
return CompetitionState_COMPETITION_STATE_UNSPECIFIED
|
||||
}
|
||||
|
||||
func (x *Competition) GetTitle() string {
|
||||
if x != nil {
|
||||
return x.Title
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Competition) GetDescription() string {
|
||||
if x != nil {
|
||||
return x.Description
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Competition) GetImageUrl() string {
|
||||
if x != nil && x.ImageUrl != nil {
|
||||
return *x.ImageUrl
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Competition) GetEndDate() string {
|
||||
if x != nil && x.EndDate != nil {
|
||||
return *x.EndDate
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Competition) GetStartDate() string {
|
||||
if x != nil && x.StartDate != nil {
|
||||
return *x.StartDate
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Competition) GetType() string {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Competition) GetParticipationType() string {
|
||||
if x != nil {
|
||||
return x.ParticipationType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_api_proto_competition_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_api_proto_competition_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x1bapi/proto/competition.proto\x12\vcompetition\">\n" +
|
||||
"\x15GetCompetitionRequest\x12%\n" +
|
||||
"\x0ecompetition_id\x18\x01 \x01(\tR\rcompetitionId\"T\n" +
|
||||
"\x16GetCompetitionResponse\x12:\n" +
|
||||
"\vcompetition\x18\x01 \x01(\v2\x18.competition.CompetitionR\vcompetition\"D\n" +
|
||||
"\x17ListCompetitionsRequest\x12)\n" +
|
||||
"\x10is_participating\x18\x01 \x01(\bR\x0fisParticipating\"X\n" +
|
||||
"\x18ListCompetitionsResponse\x12<\n" +
|
||||
"\fcompetitions\x18\x01 \x03(\v2\x18.competition.CompetitionR\fcompetitions\"{\n" +
|
||||
"\x1dChangeCompetitionStateRequest\x12%\n" +
|
||||
"\x0ecompetition_id\x18\x01 \x01(\tR\rcompetitionId\x123\n" +
|
||||
"\x05state\x18\x02 \x01(\x0e2\x1d.competition.CompetitionStateR\x05state\"U\n" +
|
||||
"\x1eChangeCompetitionStateResponse\x123\n" +
|
||||
"\x05state\x18\x01 \x01(\x0e2\x1d.competition.CompetitionStateR\x05state\"\xdd\x02\n" +
|
||||
"\vCompetition\x12\x0e\n" +
|
||||
"\x02id\x18\x01 \x01(\tR\x02id\x123\n" +
|
||||
"\x05state\x18\x02 \x01(\x0e2\x1d.competition.CompetitionStateR\x05state\x12\x14\n" +
|
||||
"\x05title\x18\x03 \x01(\tR\x05title\x12 \n" +
|
||||
"\vdescription\x18\x04 \x01(\tR\vdescription\x12 \n" +
|
||||
"\timage_url\x18\x05 \x01(\tH\x00R\bimageUrl\x88\x01\x01\x12\x1e\n" +
|
||||
"\bend_date\x18\x06 \x01(\tH\x01R\aendDate\x88\x01\x01\x12\"\n" +
|
||||
"\n" +
|
||||
"start_date\x18\a \x01(\tH\x02R\tstartDate\x88\x01\x01\x12\x12\n" +
|
||||
"\x04type\x18\b \x01(\tR\x04type\x12-\n" +
|
||||
"\x12participation_type\x18\t \x01(\tR\x11participationTypeB\f\n" +
|
||||
"\n" +
|
||||
"_image_urlB\v\n" +
|
||||
"\t_end_dateB\r\n" +
|
||||
"\v_start_date*\x97\x01\n" +
|
||||
"\x10CompetitionState\x12!\n" +
|
||||
"\x1dCOMPETITION_STATE_UNSPECIFIED\x10\x00\x12!\n" +
|
||||
"\x1dCOMPETITION_STATE_NOT_STARTED\x10\x01\x12\x1d\n" +
|
||||
"\x19COMPETITION_STATE_STARTED\x10\x02\x12\x1e\n" +
|
||||
"\x1aCOMPETITION_STATE_FINISHED\x10\x032\xc3\x02\n" +
|
||||
"\x12CompetitionService\x12Y\n" +
|
||||
"\x0eGetCompetition\x12\".competition.GetCompetitionRequest\x1a#.competition.GetCompetitionResponse\x12_\n" +
|
||||
"\x10ListCompetitions\x12$.competition.ListCompetitionsRequest\x1a%.competition.ListCompetitionsResponse\x12q\n" +
|
||||
"\x16ChangeCompetitionState\x12*.competition.ChangeCompetitionStateRequest\x1a+.competition.ChangeCompetitionStateResponseB\x15Z\x13pkg/api/competitionb\x06proto3"
|
||||
|
||||
var (
|
||||
file_api_proto_competition_proto_rawDescOnce sync.Once
|
||||
file_api_proto_competition_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_api_proto_competition_proto_rawDescGZIP() []byte {
|
||||
file_api_proto_competition_proto_rawDescOnce.Do(func() {
|
||||
file_api_proto_competition_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_proto_competition_proto_rawDesc), len(file_api_proto_competition_proto_rawDesc)))
|
||||
})
|
||||
return file_api_proto_competition_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_api_proto_competition_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_api_proto_competition_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
|
||||
var file_api_proto_competition_proto_goTypes = []any{
|
||||
(CompetitionState)(0), // 0: competition.CompetitionState
|
||||
(*GetCompetitionRequest)(nil), // 1: competition.GetCompetitionRequest
|
||||
(*GetCompetitionResponse)(nil), // 2: competition.GetCompetitionResponse
|
||||
(*ListCompetitionsRequest)(nil), // 3: competition.ListCompetitionsRequest
|
||||
(*ListCompetitionsResponse)(nil), // 4: competition.ListCompetitionsResponse
|
||||
(*ChangeCompetitionStateRequest)(nil), // 5: competition.ChangeCompetitionStateRequest
|
||||
(*ChangeCompetitionStateResponse)(nil), // 6: competition.ChangeCompetitionStateResponse
|
||||
(*Competition)(nil), // 7: competition.Competition
|
||||
}
|
||||
var file_api_proto_competition_proto_depIdxs = []int32{
|
||||
7, // 0: competition.GetCompetitionResponse.competition:type_name -> competition.Competition
|
||||
7, // 1: competition.ListCompetitionsResponse.competitions:type_name -> competition.Competition
|
||||
0, // 2: competition.ChangeCompetitionStateRequest.state:type_name -> competition.CompetitionState
|
||||
0, // 3: competition.ChangeCompetitionStateResponse.state:type_name -> competition.CompetitionState
|
||||
0, // 4: competition.Competition.state:type_name -> competition.CompetitionState
|
||||
1, // 5: competition.CompetitionService.GetCompetition:input_type -> competition.GetCompetitionRequest
|
||||
3, // 6: competition.CompetitionService.ListCompetitions:input_type -> competition.ListCompetitionsRequest
|
||||
5, // 7: competition.CompetitionService.ChangeCompetitionState:input_type -> competition.ChangeCompetitionStateRequest
|
||||
2, // 8: competition.CompetitionService.GetCompetition:output_type -> competition.GetCompetitionResponse
|
||||
4, // 9: competition.CompetitionService.ListCompetitions:output_type -> competition.ListCompetitionsResponse
|
||||
6, // 10: competition.CompetitionService.ChangeCompetitionState:output_type -> competition.ChangeCompetitionStateResponse
|
||||
8, // [8:11] is the sub-list for method output_type
|
||||
5, // [5:8] is the sub-list for method input_type
|
||||
5, // [5:5] is the sub-list for extension type_name
|
||||
5, // [5:5] is the sub-list for extension extendee
|
||||
0, // [0:5] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_api_proto_competition_proto_init() }
|
||||
func file_api_proto_competition_proto_init() {
|
||||
if File_api_proto_competition_proto != nil {
|
||||
return
|
||||
}
|
||||
file_api_proto_competition_proto_msgTypes[6].OneofWrappers = []any{}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_proto_competition_proto_rawDesc), len(file_api_proto_competition_proto_rawDesc)),
|
||||
NumEnums: 1,
|
||||
NumMessages: 7,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_api_proto_competition_proto_goTypes,
|
||||
DependencyIndexes: file_api_proto_competition_proto_depIdxs,
|
||||
EnumInfos: file_api_proto_competition_proto_enumTypes,
|
||||
MessageInfos: file_api_proto_competition_proto_msgTypes,
|
||||
}.Build()
|
||||
File_api_proto_competition_proto = out.File
|
||||
file_api_proto_competition_proto_goTypes = nil
|
||||
file_api_proto_competition_proto_depIdxs = nil
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v6.33.2
|
||||
// source: api/proto/competition.proto
|
||||
|
||||
package competition
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
CompetitionService_GetCompetition_FullMethodName = "/competition.CompetitionService/GetCompetition"
|
||||
CompetitionService_ListCompetitions_FullMethodName = "/competition.CompetitionService/ListCompetitions"
|
||||
CompetitionService_ChangeCompetitionState_FullMethodName = "/competition.CompetitionService/ChangeCompetitionState"
|
||||
)
|
||||
|
||||
// CompetitionServiceClient is the client API for CompetitionService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type CompetitionServiceClient interface {
|
||||
GetCompetition(ctx context.Context, in *GetCompetitionRequest, opts ...grpc.CallOption) (*GetCompetitionResponse, error)
|
||||
ListCompetitions(ctx context.Context, in *ListCompetitionsRequest, opts ...grpc.CallOption) (*ListCompetitionsResponse, error)
|
||||
ChangeCompetitionState(ctx context.Context, in *ChangeCompetitionStateRequest, opts ...grpc.CallOption) (*ChangeCompetitionStateResponse, error)
|
||||
}
|
||||
|
||||
type competitionServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewCompetitionServiceClient(cc grpc.ClientConnInterface) CompetitionServiceClient {
|
||||
return &competitionServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *competitionServiceClient) GetCompetition(ctx context.Context, in *GetCompetitionRequest, opts ...grpc.CallOption) (*GetCompetitionResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetCompetitionResponse)
|
||||
err := c.cc.Invoke(ctx, CompetitionService_GetCompetition_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *competitionServiceClient) ListCompetitions(ctx context.Context, in *ListCompetitionsRequest, opts ...grpc.CallOption) (*ListCompetitionsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListCompetitionsResponse)
|
||||
err := c.cc.Invoke(ctx, CompetitionService_ListCompetitions_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *competitionServiceClient) ChangeCompetitionState(ctx context.Context, in *ChangeCompetitionStateRequest, opts ...grpc.CallOption) (*ChangeCompetitionStateResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ChangeCompetitionStateResponse)
|
||||
err := c.cc.Invoke(ctx, CompetitionService_ChangeCompetitionState_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// CompetitionServiceServer is the server API for CompetitionService service.
|
||||
// All implementations must embed UnimplementedCompetitionServiceServer
|
||||
// for forward compatibility.
|
||||
type CompetitionServiceServer interface {
|
||||
GetCompetition(context.Context, *GetCompetitionRequest) (*GetCompetitionResponse, error)
|
||||
ListCompetitions(context.Context, *ListCompetitionsRequest) (*ListCompetitionsResponse, error)
|
||||
ChangeCompetitionState(context.Context, *ChangeCompetitionStateRequest) (*ChangeCompetitionStateResponse, error)
|
||||
mustEmbedUnimplementedCompetitionServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedCompetitionServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedCompetitionServiceServer struct{}
|
||||
|
||||
func (UnimplementedCompetitionServiceServer) GetCompetition(context.Context, *GetCompetitionRequest) (*GetCompetitionResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetCompetition not implemented")
|
||||
}
|
||||
func (UnimplementedCompetitionServiceServer) ListCompetitions(context.Context, *ListCompetitionsRequest) (*ListCompetitionsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ListCompetitions not implemented")
|
||||
}
|
||||
func (UnimplementedCompetitionServiceServer) ChangeCompetitionState(context.Context, *ChangeCompetitionStateRequest) (*ChangeCompetitionStateResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ChangeCompetitionState not implemented")
|
||||
}
|
||||
func (UnimplementedCompetitionServiceServer) mustEmbedUnimplementedCompetitionServiceServer() {}
|
||||
func (UnimplementedCompetitionServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeCompetitionServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to CompetitionServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeCompetitionServiceServer interface {
|
||||
mustEmbedUnimplementedCompetitionServiceServer()
|
||||
}
|
||||
|
||||
func RegisterCompetitionServiceServer(s grpc.ServiceRegistrar, srv CompetitionServiceServer) {
|
||||
// If the following call pancis, it indicates UnimplementedCompetitionServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&CompetitionService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _CompetitionService_GetCompetition_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetCompetitionRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(CompetitionServiceServer).GetCompetition(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: CompetitionService_GetCompetition_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(CompetitionServiceServer).GetCompetition(ctx, req.(*GetCompetitionRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _CompetitionService_ListCompetitions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListCompetitionsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(CompetitionServiceServer).ListCompetitions(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: CompetitionService_ListCompetitions_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(CompetitionServiceServer).ListCompetitions(ctx, req.(*ListCompetitionsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _CompetitionService_ChangeCompetitionState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ChangeCompetitionStateRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(CompetitionServiceServer).ChangeCompetitionState(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: CompetitionService_ChangeCompetitionState_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(CompetitionServiceServer).ChangeCompetitionState(ctx, req.(*ChangeCompetitionStateRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// CompetitionService_ServiceDesc is the grpc.ServiceDesc for CompetitionService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var CompetitionService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "competition.CompetitionService",
|
||||
HandlerType: (*CompetitionServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetCompetition",
|
||||
Handler: _CompetitionService_GetCompetition_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListCompetitions",
|
||||
Handler: _CompetitionService_ListCompetitions_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ChangeCompetitionState",
|
||||
Handler: _CompetitionService_ChangeCompetitionState_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api/proto/competition.proto",
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,349 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v6.33.2
|
||||
// source: api/proto/task.proto
|
||||
|
||||
package task
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
TaskService_StartCompetition_FullMethodName = "/task.TaskService/StartCompetition"
|
||||
TaskService_GetCompetitionTasks_FullMethodName = "/task.TaskService/GetCompetitionTasks"
|
||||
TaskService_GetTask_FullMethodName = "/task.TaskService/GetTask"
|
||||
TaskService_SubmitTask_FullMethodName = "/task.TaskService/SubmitTask"
|
||||
TaskService_GetSubmissionsHistory_FullMethodName = "/task.TaskService/GetSubmissionsHistory"
|
||||
TaskService_GetTaskAttachments_FullMethodName = "/task.TaskService/GetTaskAttachments"
|
||||
TaskService_GetCompetitionResults_FullMethodName = "/task.TaskService/GetCompetitionResults"
|
||||
)
|
||||
|
||||
// TaskServiceClient is the client API for TaskService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type TaskServiceClient interface {
|
||||
StartCompetition(ctx context.Context, in *StartCompetitionRequest, opts ...grpc.CallOption) (*StartCompetitionResponse, error)
|
||||
GetCompetitionTasks(ctx context.Context, in *GetCompetitionTasksRequest, opts ...grpc.CallOption) (*GetCompetitionTasksResponse, error)
|
||||
GetTask(ctx context.Context, in *GetTaskRequest, opts ...grpc.CallOption) (*GetTaskResponse, error)
|
||||
SubmitTask(ctx context.Context, in *SubmitTaskRequest, opts ...grpc.CallOption) (*SubmitTaskResponse, error)
|
||||
GetSubmissionsHistory(ctx context.Context, in *GetSubmissionsHistoryRequest, opts ...grpc.CallOption) (*GetSubmissionsHistoryResponse, error)
|
||||
GetTaskAttachments(ctx context.Context, in *GetTaskAttachmentsRequest, opts ...grpc.CallOption) (*GetTaskAttachmentsResponse, error)
|
||||
GetCompetitionResults(ctx context.Context, in *GetCompetitionResultsRequest, opts ...grpc.CallOption) (*GetCompetitionResultsResponse, error)
|
||||
}
|
||||
|
||||
type taskServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewTaskServiceClient(cc grpc.ClientConnInterface) TaskServiceClient {
|
||||
return &taskServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *taskServiceClient) StartCompetition(ctx context.Context, in *StartCompetitionRequest, opts ...grpc.CallOption) (*StartCompetitionResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(StartCompetitionResponse)
|
||||
err := c.cc.Invoke(ctx, TaskService_StartCompetition_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *taskServiceClient) GetCompetitionTasks(ctx context.Context, in *GetCompetitionTasksRequest, opts ...grpc.CallOption) (*GetCompetitionTasksResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetCompetitionTasksResponse)
|
||||
err := c.cc.Invoke(ctx, TaskService_GetCompetitionTasks_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *taskServiceClient) GetTask(ctx context.Context, in *GetTaskRequest, opts ...grpc.CallOption) (*GetTaskResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetTaskResponse)
|
||||
err := c.cc.Invoke(ctx, TaskService_GetTask_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *taskServiceClient) SubmitTask(ctx context.Context, in *SubmitTaskRequest, opts ...grpc.CallOption) (*SubmitTaskResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(SubmitTaskResponse)
|
||||
err := c.cc.Invoke(ctx, TaskService_SubmitTask_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *taskServiceClient) GetSubmissionsHistory(ctx context.Context, in *GetSubmissionsHistoryRequest, opts ...grpc.CallOption) (*GetSubmissionsHistoryResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetSubmissionsHistoryResponse)
|
||||
err := c.cc.Invoke(ctx, TaskService_GetSubmissionsHistory_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *taskServiceClient) GetTaskAttachments(ctx context.Context, in *GetTaskAttachmentsRequest, opts ...grpc.CallOption) (*GetTaskAttachmentsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetTaskAttachmentsResponse)
|
||||
err := c.cc.Invoke(ctx, TaskService_GetTaskAttachments_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *taskServiceClient) GetCompetitionResults(ctx context.Context, in *GetCompetitionResultsRequest, opts ...grpc.CallOption) (*GetCompetitionResultsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetCompetitionResultsResponse)
|
||||
err := c.cc.Invoke(ctx, TaskService_GetCompetitionResults_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// TaskServiceServer is the server API for TaskService service.
|
||||
// All implementations must embed UnimplementedTaskServiceServer
|
||||
// for forward compatibility.
|
||||
type TaskServiceServer interface {
|
||||
StartCompetition(context.Context, *StartCompetitionRequest) (*StartCompetitionResponse, error)
|
||||
GetCompetitionTasks(context.Context, *GetCompetitionTasksRequest) (*GetCompetitionTasksResponse, error)
|
||||
GetTask(context.Context, *GetTaskRequest) (*GetTaskResponse, error)
|
||||
SubmitTask(context.Context, *SubmitTaskRequest) (*SubmitTaskResponse, error)
|
||||
GetSubmissionsHistory(context.Context, *GetSubmissionsHistoryRequest) (*GetSubmissionsHistoryResponse, error)
|
||||
GetTaskAttachments(context.Context, *GetTaskAttachmentsRequest) (*GetTaskAttachmentsResponse, error)
|
||||
GetCompetitionResults(context.Context, *GetCompetitionResultsRequest) (*GetCompetitionResultsResponse, error)
|
||||
mustEmbedUnimplementedTaskServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedTaskServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedTaskServiceServer struct{}
|
||||
|
||||
func (UnimplementedTaskServiceServer) StartCompetition(context.Context, *StartCompetitionRequest) (*StartCompetitionResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method StartCompetition not implemented")
|
||||
}
|
||||
func (UnimplementedTaskServiceServer) GetCompetitionTasks(context.Context, *GetCompetitionTasksRequest) (*GetCompetitionTasksResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetCompetitionTasks not implemented")
|
||||
}
|
||||
func (UnimplementedTaskServiceServer) GetTask(context.Context, *GetTaskRequest) (*GetTaskResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetTask not implemented")
|
||||
}
|
||||
func (UnimplementedTaskServiceServer) SubmitTask(context.Context, *SubmitTaskRequest) (*SubmitTaskResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SubmitTask not implemented")
|
||||
}
|
||||
func (UnimplementedTaskServiceServer) GetSubmissionsHistory(context.Context, *GetSubmissionsHistoryRequest) (*GetSubmissionsHistoryResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetSubmissionsHistory not implemented")
|
||||
}
|
||||
func (UnimplementedTaskServiceServer) GetTaskAttachments(context.Context, *GetTaskAttachmentsRequest) (*GetTaskAttachmentsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetTaskAttachments not implemented")
|
||||
}
|
||||
func (UnimplementedTaskServiceServer) GetCompetitionResults(context.Context, *GetCompetitionResultsRequest) (*GetCompetitionResultsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetCompetitionResults not implemented")
|
||||
}
|
||||
func (UnimplementedTaskServiceServer) mustEmbedUnimplementedTaskServiceServer() {}
|
||||
func (UnimplementedTaskServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeTaskServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to TaskServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeTaskServiceServer interface {
|
||||
mustEmbedUnimplementedTaskServiceServer()
|
||||
}
|
||||
|
||||
func RegisterTaskServiceServer(s grpc.ServiceRegistrar, srv TaskServiceServer) {
|
||||
// If the following call pancis, it indicates UnimplementedTaskServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&TaskService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _TaskService_StartCompetition_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(StartCompetitionRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(TaskServiceServer).StartCompetition(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: TaskService_StartCompetition_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(TaskServiceServer).StartCompetition(ctx, req.(*StartCompetitionRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _TaskService_GetCompetitionTasks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetCompetitionTasksRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(TaskServiceServer).GetCompetitionTasks(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: TaskService_GetCompetitionTasks_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(TaskServiceServer).GetCompetitionTasks(ctx, req.(*GetCompetitionTasksRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _TaskService_GetTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetTaskRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(TaskServiceServer).GetTask(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: TaskService_GetTask_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(TaskServiceServer).GetTask(ctx, req.(*GetTaskRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _TaskService_SubmitTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SubmitTaskRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(TaskServiceServer).SubmitTask(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: TaskService_SubmitTask_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(TaskServiceServer).SubmitTask(ctx, req.(*SubmitTaskRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _TaskService_GetSubmissionsHistory_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetSubmissionsHistoryRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(TaskServiceServer).GetSubmissionsHistory(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: TaskService_GetSubmissionsHistory_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(TaskServiceServer).GetSubmissionsHistory(ctx, req.(*GetSubmissionsHistoryRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _TaskService_GetTaskAttachments_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetTaskAttachmentsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(TaskServiceServer).GetTaskAttachments(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: TaskService_GetTaskAttachments_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(TaskServiceServer).GetTaskAttachments(ctx, req.(*GetTaskAttachmentsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _TaskService_GetCompetitionResults_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetCompetitionResultsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(TaskServiceServer).GetCompetitionResults(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: TaskService_GetCompetitionResults_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(TaskServiceServer).GetCompetitionResults(ctx, req.(*GetCompetitionResultsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// TaskService_ServiceDesc is the grpc.ServiceDesc for TaskService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var TaskService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "task.TaskService",
|
||||
HandlerType: (*TaskServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "StartCompetition",
|
||||
Handler: _TaskService_StartCompetition_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetCompetitionTasks",
|
||||
Handler: _TaskService_GetCompetitionTasks_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetTask",
|
||||
Handler: _TaskService_GetTask_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "SubmitTask",
|
||||
Handler: _TaskService_SubmitTask_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetSubmissionsHistory",
|
||||
Handler: _TaskService_GetSubmissionsHistory_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetTaskAttachments",
|
||||
Handler: _TaskService_GetTaskAttachments_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetCompetitionResults",
|
||||
Handler: _TaskService_GetCompetitionResults_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api/proto/task.proto",
|
||||
}
|
||||
Reference in New Issue
Block a user