Compare commits

..

43 Commits

Author SHA1 Message Date
413ad0629a 💄 Optimize meet page 2025-04-06 14:49:00 +08:00
aa3c0a9dbf 🐛 Fix meet room page missing channel 2025-04-06 14:41:25 +08:00
00ef003be9 Meet room rendering 2025-04-06 14:30:45 +08:00
e21ec2e81c 🐛 Fix wrong route for rate limiter 2025-03-30 22:58:02 +08:00
4350d197f9 DirectAccess Realm 2025-03-30 14:31:16 +08:00
d5422ab5b0 🐛 Fix nil rdl 2025-03-29 15:59:32 +08:00
4a08fd8f1c Revert to use cached userinfo for security reason 2025-03-29 15:27:29 +08:00
f113ae6cba User info DirectAccess™ 2025-03-29 15:21:30 +08:00
1ea5aea6b3 Prevent from creating multiple redis client 2025-03-29 15:11:07 +08:00
2c4355257c 🚚 Rename CaConn to Conn 2025-03-29 15:02:25 +08:00
69012b9cc3 👔 Make the just added service status up & running 2025-03-29 13:51:53 +08:00
488793a2dc 🐛 Trying to fix cache sdk issue 2025-03-29 13:39:29 +08:00
e7d7cd1000 🐛 Fix nexus allocate did not alloc db in cache 2025-03-29 13:25:46 +08:00
66df1392c4 Advance cachekit API built with gocache/v4 2025-03-29 12:39:15 +08:00
1651328a74 Redis cache 2025-03-29 02:24:15 +08:00
f3f9ebb5af IP Blacklist 2025-03-29 00:26:05 +08:00
105ec693f8 Captcha gateway provide postMessage for better compability 2025-03-23 16:15:34 +08:00
c7f3c1b2cc 🔇 Disable pushing websocket logs 2025-03-23 13:16:13 +08:00
e670724c4c Captcha Gateway Toolkit 2025-03-22 19:50:40 +08:00
62dcbbf424 Captcha Gateway 2025-03-22 19:48:19 +08:00
ba1d96b118 Heavier rate limiting for POST and other methods may create data 2025-03-22 19:23:45 +08:00
c8bba4fb2d 🐛 Increase the header field size limit 2025-03-20 21:34:29 +08:00
7994d1a897 Forward webfinger request 2025-03-11 21:52:47 +08:00
31f29cf940 🐛 Trying to fix unstable ws by limit client id length 2025-03-05 21:52:25 +08:00
8ac88413e0 ♻️ Refactor websocket client id 2025-03-01 14:51:53 +08:00
1f07c0edf4 🔊 More logs in db maintain 2025-03-01 13:27:07 +08:00
74dd8fc182 👔 Reduce deleting recycle deadline 2025-03-01 13:23:25 +08:00
2a5b90b530 Status checking 2025-03-01 13:22:38 +08:00
fe2e682267 ♻️ Replace logger 2025-03-01 13:07:57 +08:00
481404c4a2 🗑️ Clean up command related stuff
🚚 Move http package to web
2025-03-01 13:00:50 +08:00
fbb670b96b Rate limiter 2025-02-25 00:22:46 +08:00
15c39609b8 User info now include the language 2025-02-16 18:38:38 +08:00
4675b65476 🐛 Fix wrong IsAllSuccess value 2025-02-04 14:08:38 +08:00
0f350d00a8 Push stream able to get which request success
⬆️ Upgrade protobuf version
2025-02-02 15:52:00 +08:00
6de240179f Localize toolkit 2025-02-02 13:47:14 +08:00
cf513a7ee8 👔 Optimize watchtower backup format 2025-01-30 23:59:24 +08:00
7942873e21 🐛 Fix .pgpass 2025-01-30 23:33:01 +08:00
6a520603cb ♻️ Use .pgpass file instead stdin enter password 2025-01-30 23:22:43 +08:00
5a71f8268a 🐛 Bug fixes for watchtower backup 2025-01-30 23:08:07 +08:00
22fafa2e84 🔊 Verbose backup db output 2025-01-30 22:53:43 +08:00
2e3c663525 🐛 Keep the nex_user in context always the pointer 2025-01-30 22:44:43 +08:00
7cf9b80fe6 WatchTower admin API 2025-01-30 22:24:58 +08:00
bda9ab6c3d WatchTower for database 2025-01-30 22:14:23 +08:00
75 changed files with 2748 additions and 2509 deletions

1
.gitignore vendored
View File

@@ -3,4 +3,5 @@
/default.etcd
/keys
.idea
.DS_Store

View File

@@ -10,7 +10,10 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -buildvcs -o /dist ./pkg/main
# Runtime
FROM golang:alpine
RUN apk add postgresql-client
COPY --from=nexus-server /dist /nexus/server
COPY ./templates /templates
EXPOSE 8444

View File

@@ -41,6 +41,8 @@ the establishment of the connection.
At the same time, the allocated database will be added into the watchtower for auto maintenance
(auto remove the soft-deleted records, backup and more).
Currently, the database is only support postgres, there is no plan for supporting other databases.
### Authorization
All the request forwarded by the Nexus will handle the authorization automatically.

View File

@@ -1,16 +0,0 @@
# Roadmap
The development progress and plan for Hypernet.Nexus
- [x] Service discovery
- [x] Command system
- [x] High availability
- [x] Microservice gateway
- [ ] Authenticate (W.I.P)
- [ ] FastLSF (fast lua based serverless function)
The goal of project Hypernet is going to replace the Hydrogen as Solar Network server-side software.
And the goal of this project is going to replace Hydrogen.Dealer as the core component of Solar Network.
Other Hydrogen project will be refactored and upgraded to support Nexus as soon as the first stable version is released.
Some features will moved to command based api, such as daily sign in Passport which isn't in Nexus Standard and will be not in it.

45
go.mod
View File

@@ -2,23 +2,30 @@ module git.solsynth.dev/hypernet/nexus
go 1.22.0
toolchain go1.23.2
require (
github.com/eko/gocache/lib/v4 v4.2.0
github.com/eko/gocache/store/redis/v4 v4.2.2
github.com/fatih/color v1.18.0
github.com/go-playground/validator/v10 v10.22.1
github.com/goccy/go-json v0.10.3
github.com/gofiber/contrib/fiberzerolog v1.0.2
github.com/gofiber/contrib/websocket v1.3.2
github.com/gofiber/fiber/v2 v2.52.5
github.com/gofiber/fiber/v2 v2.52.6
github.com/gofiber/template/html/v2 v2.1.3
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/google/uuid v1.6.0
github.com/json-iterator/go v1.1.12
github.com/lib/pq v1.10.9
github.com/nats-io/nats.go v1.37.0
github.com/nicksnyder/go-i18n/v2 v2.5.0
github.com/redis/go-redis/v9 v9.7.3
github.com/robfig/cron/v3 v3.0.1
github.com/rs/zerolog v1.33.0
github.com/samber/lo v1.47.0
github.com/spf13/viper v1.19.0
github.com/valyala/fasthttp v1.59.0
go.etcd.io/etcd/client/v3 v3.5.16
golang.org/x/text v0.22.0
google.golang.org/grpc v1.67.1
google.golang.org/protobuf v1.35.1
gorm.io/datatypes v1.2.4
@@ -29,17 +36,22 @@ require (
require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fasthttp/websocket v1.5.10 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/gofiber/template v1.8.3 // indirect
github.com/gofiber/utils v1.1.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
@@ -47,10 +59,10 @@ require (
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
@@ -60,7 +72,12 @@ require (
github.com/nats-io/nuid v1.0.1 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.52.3 // indirect
github.com/prometheus/procfs v0.13.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/savsgio/gotils v0.0.0-20240704082632-aef3928b8a38 // indirect
@@ -69,25 +86,21 @@ require (
github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tinylib/msgp v1.2.4 // indirect
github.com/tinylib/msgp v1.2.5 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.57.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
go.etcd.io/etcd/api/v3 v3.5.16 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.16 // indirect
go.uber.org/mock v0.4.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/crypto v0.33.0 // indirect
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/net v0.35.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sys v0.30.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/driver/mysql v1.5.7 // indirect
)
replace git.solsynth.dev/hydrogen/bus => ../Bus

98
go.sum
View File

@@ -1,7 +1,17 @@
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA=
github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
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/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
@@ -10,6 +20,12 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/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/eko/gocache/lib/v4 v4.2.0 h1:MNykyi5Xw+5Wu3+PUrvtOCaKSZM1nUSVftbzmeC7Yuw=
github.com/eko/gocache/lib/v4 v4.2.0/go.mod h1:7ViVmbU+CzDHzRpmB4SXKyyzyuJ8A3UW3/cszpcqB4M=
github.com/eko/gocache/store/redis/v4 v4.2.2 h1:Thw31fzGuH3WzJywsdbMivOmP550D6JS7GDHhvCJPA0=
github.com/eko/gocache/store/redis/v4 v4.2.2/go.mod h1:LaTxLKx9TG/YUEybQvPMij++D7PBTIJ4+pzvk0ykz0w=
github.com/fasthttp/websocket v1.5.10 h1:bc7NIGyrg1L6sd5pRzCIbXpro54SZLEluZCu0rOpcN4=
github.com/fasthttp/websocket v1.5.10/go.mod h1:BwHeuXGWzCW1/BIKUKD3+qfCl+cTdsHu/f243NcAI/Q=
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
@@ -34,10 +50,18 @@ github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqw
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofiber/contrib/fiberzerolog v1.0.2 h1:LMa/luarQVeINoRwZLHtLQYepLPDIwUNB5OmdZKk+s8=
github.com/gofiber/contrib/fiberzerolog v1.0.2/go.mod h1:aTPsgArSgxRWcUeJ/K6PiICz3mbQENR1QOR426QwOoQ=
github.com/gofiber/contrib/websocket v1.3.2 h1:AUq5PYeKwK50s0nQrnluuINYeep1c4nRCJ0NWsV3cvg=
github.com/gofiber/contrib/websocket v1.3.2/go.mod h1:07u6QGMsvX+sx7iGNCl5xhzuUVArWwLQ3tBIH24i+S8=
github.com/gofiber/fiber/v2 v2.52.5 h1:tWoP1MJQjGEe4GB5TUGOi7P2E0ZMMRx5ZTG4rT+yGMo=
github.com/gofiber/fiber/v2 v2.52.5/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ=
github.com/gofiber/fiber/v2 v2.52.6 h1:Rfp+ILPiYSvvVuIPvxrBns+HJp8qGLDnLJawAu27XVI=
github.com/gofiber/fiber/v2 v2.52.6/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw=
github.com/gofiber/template v1.8.3 h1:hzHdvMwMo/T2kouz2pPCA0zGiLCeMnoGsQZBTSYgZxc=
github.com/gofiber/template v1.8.3/go.mod h1:bs/2n0pSNPOkRa5VJ8zTIvedcI/lEYxzV3+YPXdBvq8=
github.com/gofiber/template/html/v2 v2.1.3 h1:n1LYBtmr9C0V/k/3qBblXyMxV5B0o/gpb6dFLp8ea+o=
github.com/gofiber/template/html/v2 v2.1.3/go.mod h1:U5Fxgc5KpyujU9OqKzy6Kn6Qup6Tm7zdsISR+VpnHRE=
github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM=
github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
@@ -46,6 +70,8 @@ github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0kt
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A=
github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
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.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
@@ -71,8 +97,8 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
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=
@@ -83,8 +109,9 @@ github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
@@ -108,6 +135,8 @@ github.com/nats-io/nkeys v0.4.7 h1:RwNJbbIdYCoClSDNY7QVKZlyb/wfT6ugvFCiKy6vDvI=
github.com/nats-io/nkeys v0.4.7/go.mod h1:kqXRgRDPlGy7nGaEDMuYzmiJCIAAWDK0IMBtDmGD0nc=
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/nicksnyder/go-i18n/v2 v2.5.0 h1:3wH1gpaekcgGuwzWdSu7JwJhH9Tk87k1ezt0i1p2/Is=
github.com/nicksnyder/go-i18n/v2 v2.5.0/go.mod h1:DrhgsSDZxoAfvVrBVLXoxZn/pN5TXqaDbq7ju94viiQ=
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c h1:dAMKvw0MlJT1GshSTtih8C2gDs04w8dReiOGXrGLNoY=
@@ -116,13 +145,23 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU=
github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k=
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
github.com/prometheus/common v0.52.3 h1:5f8uj6ZwHSscOGNdIQg6OiZv/ybiK2CO2q2drVZAQSA=
github.com/prometheus/common v0.52.3/go.mod h1:BrxBKv3FWBIGXw89Mg1AeBq7FSyRzXWI3l3e7W3RN5U=
github.com/prometheus/procfs v0.13.0 h1:GqzLlQyfsPbaEHaQkO7tbDlriv/4o5Hudv6OXHGKX7o=
github.com/prometheus/procfs v0.13.0/go.mod h1:cd4PFCR54QLnGKPaKGA6l+cfuNXtht43ZKY6tow0Y1g=
github.com/redis/go-redis/v9 v9.7.3 h1:YpPyAayJV+XErNsatSElgRZZVCwXX9QzkKYNvO7x0wM=
github.com/redis/go-redis/v9 v9.7.3/go.mod h1:bGUrSggJ9X9GUmZpZNEOQKaANxSGgOEBRltRTZHSvrA=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
@@ -147,22 +186,21 @@ github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/tinylib/msgp v1.2.4 h1:yLFeUGostXXSGW5vxfT5dXG/qzkn4schv2I7at5+hVU=
github.com/tinylib/msgp v1.2.4/go.mod h1:ykjzy2wzgrlvpDCRc4LA8UXy6D8bzMSuAF3WD57Gok0=
github.com/tinylib/msgp v1.2.5 h1:WeQg1whrXRFiZusidTQqzETkRpGjFjcIhW6uqWH09po=
github.com/tinylib/msgp v1.2.5/go.mod h1:ykjzy2wzgrlvpDCRc4LA8UXy6D8bzMSuAF3WD57Gok0=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.57.0 h1:Xw8SjWGEP/+wAAgyy5XTvgrWlOD1+TxbbvNADYCm1Tg=
github.com/valyala/fasthttp v1.57.0/go.mod h1:h6ZBaPRlzpZ6O3H5t2gEk1Qi33+TmLvfwgLLp0t9CpE=
github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8=
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
github.com/valyala/fasthttp v1.59.0 h1:Qu0qYHfXvPk1mSLNqcFtEk6DpxgA26hy6bmydotDpRI=
github.com/valyala/fasthttp v1.59.0/go.mod h1:GTxNb9Bc6r2a9D0TWNSPwDz78UxnTGBViY3xZNEqyYU=
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
go.etcd.io/etcd/api/v3 v3.5.16 h1:WvmyJVbjWqK4R1E+B12RRHz3bRGy9XVfh++MgbN+6n0=
go.etcd.io/etcd/api/v3 v3.5.16/go.mod h1:1P4SlIP/VwkDmGo3OlOD7faPeP8KDIFhqvciH5EfN28=
go.etcd.io/etcd/client/pkg/v3 v3.5.16 h1:ZgY48uH6UvB+/7R9Yf4x574uCO3jIx0TRDyetSfId3Q=
@@ -171,6 +209,8 @@ go.etcd.io/etcd/client/v3 v3.5.16 h1:sSmVYOAHeC9doqi0gv7v86oY/BTld0SEFGaxsU9eRhE
go.etcd.io/etcd/client/v3 v3.5.16/go.mod h1:X+rExSGkyqxvu276cr2OwPLBaeqFu1cIl4vmRjAD/50=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
@@ -178,39 +218,47 @@ go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY=
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

0
ip_block.list Normal file
View File

View File

@@ -3,14 +3,15 @@ package auth
import (
"context"
"fmt"
"strconv"
"time"
"git.solsynth.dev/hypernet/nexus/pkg/internal/directory"
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
"github.com/gofiber/fiber/v2"
"github.com/rs/zerolog/log"
"strconv"
"time"
)
func userinfoFetch(c *fiber.Ctx) error {
@@ -29,7 +30,7 @@ func userinfoFetch(c *fiber.Ctx) error {
defer cancel()
sed, err := strconv.Atoi(claims.Session)
if err != nil {
return fiber.NewError(fiber.StatusUnauthorized, fmt.Sprintf("invalid token payload"))
return fiber.NewError(fiber.StatusUnauthorized, "invalid token payload")
}
resp, err := proto.NewAuthServiceClient(conn).Authenticate(ctx, &proto.AuthRequest{
SessionId: uint64(sed),
@@ -38,7 +39,7 @@ func userinfoFetch(c *fiber.Ctx) error {
return fiber.NewError(fiber.StatusUnauthorized, fmt.Sprintf("unable to load userinfo: %v", err))
}
userinfo := sec.NewUserInfoFromProto(resp.Info.Info)
c.Locals("nex_user", userinfo)
c.Locals("nex_user", &userinfo)
tk, err := IWriter.WriteUserInfoJwt(userinfo)
if err != nil {
return fiber.NewError(fiber.StatusInternalServerError, fmt.Sprintf("unable to sign userinfo: %v", err))

26
pkg/internal/cache/redis.go vendored Normal file
View File

@@ -0,0 +1,26 @@
package cache
import (
"time"
"git.solsynth.dev/hypernet/nexus/pkg/nex/cachekit"
"github.com/redis/go-redis/v9"
)
var (
Rdb *redis.Client
Kcc *cachekit.Conn
)
func ConnectRedis(addr, password string, db int) error {
Rdb = redis.NewClient(&redis.Options{
Addr: addr,
Password: password,
DB: db,
})
Kcc = &cachekit.Conn{
Rd: Rdb,
Timeout: 3 * time.Second,
}
return nil
}

View File

@@ -0,0 +1,33 @@
package captcha
import (
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
)
type TemplateData struct {
ApiKey string `json:"api_key"`
}
func GetTemplateData() TemplateData {
return TemplateData{
ApiKey: viper.GetString("captcha.api_key"),
}
}
type CaptchaAdapter interface {
Validate(token, ip string) bool
}
var adapters = map[string]CaptchaAdapter{
"turnstile": &TurnstileAdapter{},
}
func Validate(token, ip string) bool {
provider := viper.GetString("captcha.provider")
if adapter, ok := adapters[provider]; ok {
return adapter.Validate(token, ip)
}
log.Error().Msg("Unable to handle captcha validate request due to unsupported provider.")
return false
}

View File

@@ -0,0 +1,46 @@
package captcha
import (
"bytes"
"encoding/json"
"net/http"
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
)
type TurnstileAdapter struct{}
type turnstileResponse struct {
Success bool `json:"success"`
ErrorCodes []string `json:"error-codes"`
}
func (a *TurnstileAdapter) Validate(token, ip string) bool {
url := "https://challenges.cloudflare.com/turnstile/v0/siteverify"
data := map[string]string{
"secret": viper.GetString("captcha.api_secret"),
"response": token,
"remoteip": ip,
}
jsonData, _ := json.Marshal(data)
resp, err := http.Post(url, "application/json", bytes.NewBuffer(jsonData))
if err != nil {
log.Error().Err(err).Msg("Error sending request to Turnstile...")
return false
}
defer resp.Body.Close()
var result turnstileResponse
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
log.Error().Err(err).Msg("Error decoding response from Turnstile...")
return false
}
if !result.Success {
log.Warn().Strs("errors", result.ErrorCodes).Msg("An captcha validation request failed...")
}
return result.Success
}

View File

@@ -2,9 +2,11 @@ package database
import (
"fmt"
"strings"
"git.solsynth.dev/hypernet/nexus/pkg/internal/watchtower"
"github.com/samber/lo"
"github.com/spf13/viper"
"strings"
)
func AllocDatabase(name string) (string, error) {
@@ -34,6 +36,9 @@ func AllocDatabase(name string) (string, error) {
}
connString = append(connString, "dbname="+name)
dsn := strings.Join(connString, " ")
return strings.Join(connString, " "), nil
watchtower.AddWatchDb(dsn)
return dsn, nil
}

View File

@@ -1,22 +0,0 @@
package directory
const (
CommandMethodGet = "get"
CommandMethodPut = "put"
CommandMethodPatch = "patch"
CommandMethodPost = "post"
CommandMethodDelete = "delete"
)
type Command struct {
// The unique identifier of the command, different method command can hold the same command id
ID string `json:"id"`
// The method of the command, such as get, post, others; inspired by RESTful design
Method string `json:"method"`
// The tags of the command will be used to invoke the pre-command middlewares and post-command middlewares
Tags []string `json:"tags"`
// The implementation of the command, the handler is the service that will be invoked
Handler []*ServiceInstance `json:"handler"`
RobinIndex uint `json:"robin_index"`
}

View File

@@ -1,79 +0,0 @@
package directory
import (
"context"
"git.solsynth.dev/hypernet/nexus/pkg/internal/kv"
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"github.com/goccy/go-json"
"github.com/rs/zerolog/log"
"github.com/samber/lo"
)
const CommandInfoKvPrefix = "nexus.command/"
func AddCommand(id, method string, tags []string, handler *ServiceInstance) error {
if tags == nil {
tags = make([]string, 0)
}
ky := CommandInfoKvPrefix + nex.GetCommandKey(id, method)
command := &Command{
ID: id,
Method: method,
Tags: tags,
Handler: []*ServiceInstance{handler},
}
command.Handler = lo.UniqBy(command.Handler, func(item *ServiceInstance) string {
return item.ID
})
commandJSON, err := json.Marshal(command)
if err != nil {
log.Printf("Error marshaling command: %v", err)
return nil
}
_, err = kv.Kv.Put(context.Background(), ky, string(commandJSON))
return err
}
func GetCommandHandler(id, method string) *ServiceInstance {
ky := CommandInfoKvPrefix + nex.GetCommandKey(id, method)
resp, err := kv.Kv.Get(context.Background(), ky)
if err != nil {
return nil
}
if len(resp.Kvs) == 0 {
return nil
}
var command Command
if err := json.Unmarshal(resp.Kvs[0].Value, &command); err != nil {
return nil
}
if len(command.Handler) == 0 {
return nil
}
idx := command.RobinIndex % uint(len(command.Handler))
command.RobinIndex = idx + 1
raw, err := json.Marshal(&command)
if err == nil {
_, _ = kv.Kv.Put(context.Background(), ky, string(raw))
}
return command.Handler[idx]
}
func RemoveCommand(id, method string) error {
ky := CommandInfoKvPrefix + nex.GetCommandKey(id, method)
_, err := kv.Kv.Delete(context.Background(), ky)
return err
}

View File

@@ -1,115 +0,0 @@
package directory
import (
"context"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"io"
"net/http"
"time"
)
type CommandRpcServer struct {
proto.UnimplementedCommandProviderServer
}
func (c *CommandRpcServer) AddCommand(ctx context.Context, info *proto.CommandInfo) (*proto.AddCommandResponse, error) {
clientId, err := GetClientId(ctx)
if err != nil {
return nil, err
}
service := GetServiceInstance(clientId)
if service == nil {
return nil, status.Errorf(codes.NotFound, "service not found")
}
AddCommand(info.GetId(), info.GetMethod(), info.GetTags(), service)
return &proto.AddCommandResponse{
IsSuccess: true,
}, nil
}
func (c *CommandRpcServer) RemoveCommand(ctx context.Context, request *proto.CommandLookupRequest) (*proto.RemoveCommandResponse, error) {
RemoveCommand(request.GetId(), request.GetMethod())
return &proto.RemoveCommandResponse{
IsSuccess: true,
}, nil
}
func (c *CommandRpcServer) SendCommand(ctx context.Context, argument *proto.CommandArgument) (*proto.CommandReturn, error) {
id := argument.GetCommand()
method := argument.GetMethod()
handler := GetCommandHandler(id, method)
if handler == nil {
return &proto.CommandReturn{
IsDelivered: false,
Status: http.StatusNotFound,
ContentType: "text/plain+error",
Payload: []byte("command not found"),
}, nil
}
conn, err := handler.GetGrpcConn()
if err != nil {
return &proto.CommandReturn{
IsDelivered: false,
Status: http.StatusServiceUnavailable,
ContentType: "text/plain+error",
Payload: []byte("service unavailable"),
}, nil
}
ctx, cancel := context.WithTimeout(ctx, time.Second*10)
defer cancel()
out, err := proto.NewCommandProviderClient(conn).SendCommand(ctx, argument)
if err != nil {
return &proto.CommandReturn{
IsDelivered: true,
Status: http.StatusInternalServerError,
ContentType: "text/plain+error",
Payload: []byte(err.Error()),
}, nil
}
out.IsDelivered = true
return out, nil
}
func (c *CommandRpcServer) SendStreamCommand(g proto.CommandProvider_SendStreamCommandServer) error {
for {
pck, err := g.Recv()
if err == io.EOF {
return nil
} else if err != nil {
return err
}
id := pck.GetCommand()
method := pck.GetMethod()
handler := GetCommandHandler(id, method)
if handler == nil {
return status.Errorf(codes.NotFound, "command not found")
}
conn, err := handler.GetGrpcConn()
ctx, cancel := context.WithTimeout(g.Context(), time.Second*10)
out, err := proto.NewCommandProviderClient(conn).SendCommand(ctx, pck)
cancel()
if err != nil {
_ = g.Send(&proto.CommandReturn{
IsDelivered: false,
Status: http.StatusInternalServerError,
ContentType: "text/plain+error",
Payload: []byte(err.Error()),
})
} else {
_ = g.Send(out)
}
}
}

View File

@@ -2,14 +2,15 @@ package directory
import (
"context"
"math/rand"
"time"
"git.solsynth.dev/hypernet/nexus/pkg/internal/kv"
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
"github.com/goccy/go-json"
"github.com/rs/zerolog/log"
clientv3 "go.etcd.io/etcd/client/v3"
"math/rand"
"time"
)
const ServiceInfoKvPrefix = "nexus.service/"
@@ -22,6 +23,7 @@ func AddServiceInstance(in *ServiceInstance) error {
}
_, err = kv.Kv.Put(context.Background(), key, string(data))
SetServiceStatus(in.Type, true)
return err
}

View File

@@ -1,8 +1,42 @@
package directory
import "github.com/rs/zerolog/log"
import (
"sync"
"github.com/rs/zerolog/log"
)
var (
statusOfServices = make(map[string]bool)
statusLock sync.Mutex
)
func GetServiceStatus() map[string]bool {
out := make(map[string]bool)
for k, v := range statusOfServices {
out[k] = v
}
services := ListServiceInstance()
for _, service := range services {
if _, ok := out[service.Type]; !ok {
out[service.Type] = false
}
}
return out
}
func SetServiceStatus(t string, status bool) {
statusLock.Lock()
defer statusLock.Unlock()
statusOfServices[t] = status
}
func ValidateServices() {
statusLock.Lock()
defer statusLock.Unlock()
services := ListServiceInstance()
if len(services) == 0 {
return
@@ -19,9 +53,12 @@ func ValidateServices() {
}
// Directly use the connect method to skip cache
if _, err := ConnectService(service); err != nil {
statusOfServices[service.Type] = false
_ = RemoveServiceInstance(service.ID)
log.Warn().Err(err).Str("id", service.ID).Str("addr", service.GrpcAddr).Msg("Unable connect to service, dropped...")
continue
} else {
statusOfServices[service.Type] = true
}
successCount++

View File

@@ -2,6 +2,8 @@ package grpc
import (
"context"
"git.solsynth.dev/hypernet/nexus/pkg/internal/cache"
"git.solsynth.dev/hypernet/nexus/pkg/internal/kv"
"git.solsynth.dev/hypernet/nexus/pkg/internal/mq"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
@@ -31,3 +33,16 @@ func (v *Server) AllocKv(ctx context.Context, request *proto.AllocKvRequest) (*p
Endpoints: viper.GetStringSlice("kv.endpoints"),
}, nil
}
func (v *Server) AllocCache(ctx context.Context, request *proto.AllocCacheRequest) (*proto.AllocCacheResponse, error) {
if cache.Rdb == nil {
return &proto.AllocCacheResponse{IsSuccess: false}, status.Error(codes.Unavailable, "cache wasn't configured")
}
return &proto.AllocCacheResponse{
IsSuccess: true,
Addr: viper.GetString("cache.addr"),
Password: viper.GetString("cache.password"),
Db: request.GetDb(),
}, nil
}

View File

@@ -0,0 +1,14 @@
package grpc
import (
"context"
"git.solsynth.dev/hypernet/nexus/pkg/internal/captcha"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
)
func (v *Server) CheckCaptcha(_ context.Context, req *proto.CheckCaptchaRequest) (*proto.CheckCaptchaResponse, error) {
return &proto.CheckCaptchaResponse{
IsValid: captcha.Validate(req.Token, req.RemoteIp),
}, nil
}

View File

@@ -1,9 +1,10 @@
package grpc
import (
"git.solsynth.dev/hypernet/nexus/pkg/internal/directory"
"net"
"git.solsynth.dev/hypernet/nexus/pkg/internal/directory"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
"google.golang.org/grpc/reflection"
@@ -18,6 +19,7 @@ type Server struct {
proto.UnimplementedDatabaseServiceServer
proto.UnimplementedStreamServiceServer
proto.UnimplementedAllocatorServiceServer
proto.UnimplementedCaptchaServiceServer
health.UnimplementedHealthServer
srv *grpc.Server
@@ -29,10 +31,10 @@ func NewServer() *Server {
}
proto.RegisterDirectoryServiceServer(server.srv, &directory.ServiceRpcServer{})
proto.RegisterCommandProviderServer(server.srv, &directory.CommandRpcServer{})
proto.RegisterDatabaseServiceServer(server.srv, server)
proto.RegisterStreamServiceServer(server.srv, server)
proto.RegisterAllocatorServiceServer(server.srv, server)
proto.RegisterCaptchaServiceServer(server.srv, server)
health.RegisterHealthServer(server.srv, server)
reflection.Register(server.srv)

View File

@@ -3,8 +3,8 @@ package grpc
import (
"context"
"fmt"
"git.solsynth.dev/hypernet/nexus/pkg/internal/http/ws"
"github.com/rs/zerolog/log"
"git.solsynth.dev/hypernet/nexus/pkg/internal/web/ws"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
"github.com/samber/lo"
@@ -19,30 +19,24 @@ func (v *Server) CountStreamConnection(ctx context.Context, request *proto.Count
func (v *Server) PushStream(ctx context.Context, request *proto.PushStreamRequest) (*proto.PushStreamResponse, error) {
var cnt int
var success int
var successes []string
var errs []error
if request.UserId != nil {
cnt, success, errs = ws.WebsocketPush(uint(request.GetUserId()), request.GetBody())
cnt, successes, errs = ws.WebsocketPush(uint(request.GetUserId()), request.GetBody())
} else if request.ClientId != nil {
cnt, success, errs = ws.WebsocketPushDirect(request.GetClientId(), request.GetBody())
cnt, successes, errs = ws.WebsocketPushDirect(request.GetClientId(), request.GetBody())
} else {
return nil, fmt.Errorf("you must give one of the user id or client id")
}
log.Debug().
Uint64("client_id", request.GetClientId()).
Uint64("user_id", request.GetUserId()).
Int("count", cnt).
Int("success", success).
Int("failed", len(errs)).
Msgf("Pushed a websocket package to client / user...")
success := len(successes)
if len(errs) > 0 {
// Partial fail
return &proto.PushStreamResponse{
IsAllSuccess: false,
AffectedCount: int64(success),
FailedCount: int64(cnt - success),
SuccessList: successes,
}, nil
} else if cnt > 0 && success == 0 {
// All fail
@@ -50,7 +44,7 @@ func (v *Server) PushStream(ctx context.Context, request *proto.PushStreamReques
}
return &proto.PushStreamResponse{
IsAllSuccess: true,
IsAllSuccess: cnt == success,
AffectedCount: int64(success),
FailedCount: int64(cnt - success),
}, nil
@@ -58,10 +52,10 @@ func (v *Server) PushStream(ctx context.Context, request *proto.PushStreamReques
func (v *Server) PushStreamBatch(ctx context.Context, request *proto.PushStreamBatchRequest) (*proto.PushStreamResponse, error) {
var cnt int
var success int
var successes []string
var errs []error
if len(request.UserId) != 0 {
cnt, success, errs = ws.WebsocketPushBatch(
cnt, successes, errs = ws.WebsocketPushBatch(
lo.Map(request.GetUserId(), func(item uint64, idx int) uint {
return uint(item)
},
@@ -71,18 +65,11 @@ func (v *Server) PushStreamBatch(ctx context.Context, request *proto.PushStreamB
if len(request.ClientId) != 0 {
cCnt, cSuccess, cErrs := ws.WebsocketPushBatchDirect(request.GetClientId(), request.GetBody())
cnt += cCnt
success += cSuccess
successes = append(successes, cSuccess...)
errs = append(errs, cErrs...)
}
log.Debug().
Any("client_id", request.GetClientId()).
Any("user_id", request.GetUserId()).
Int("count", cnt).
Int("success", success).
Int("failed", len(errs)).
Msgf("Pushed a websocket package to client / user...")
success := len(successes)
if len(errs) > 0 {
// Partial fail
return &proto.PushStreamResponse{
@@ -96,8 +83,9 @@ func (v *Server) PushStreamBatch(ctx context.Context, request *proto.PushStreamB
}
return &proto.PushStreamResponse{
IsAllSuccess: true,
IsAllSuccess: cnt == success,
AffectedCount: int64(success),
FailedCount: int64(cnt - success),
SuccessList: successes,
}, nil
}

View File

@@ -1,67 +0,0 @@
package api
import (
"context"
"fmt"
"git.solsynth.dev/hypernet/nexus/pkg/internal/directory"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
"github.com/gofiber/fiber/v2"
"github.com/rs/zerolog/log"
"google.golang.org/grpc/metadata"
"strings"
"time"
)
func invokeCommand(c *fiber.Ctx) error {
command := c.Params("command")
method := strings.ToLower(c.Method())
handler := directory.GetCommandHandler(command, method)
if handler == nil {
return fiber.NewError(fiber.StatusNotFound, "command not found")
}
conn, err := handler.GetGrpcConn()
if err != nil {
return fiber.NewError(fiber.StatusServiceUnavailable, "service unavailable")
}
log.Debug().Str("id", command).Str("method", method).Msg("Invoking command from HTTP Gateway...")
var meta []string
meta = append(meta, "client_id", "http-gateway")
meta = append(meta, "net.ip", c.IP())
meta = append(meta, "http.user_agent", c.Get(fiber.HeaderUserAgent))
for k, v := range c.GetReqHeaders() {
meta = append(
meta,
strings.ToLower(fmt.Sprintf("header.%s", strings.ReplaceAll(k, "-", "_"))),
strings.Join(v, "\n"),
)
}
for k, v := range c.Queries() {
meta = append(
meta,
strings.ToLower(fmt.Sprintf("query.%s", strings.ReplaceAll(k, "-", "_"))),
v,
)
}
ctx := metadata.AppendToOutgoingContext(c.Context(), meta...)
ctx, cancel := context.WithTimeout(ctx, time.Second*10)
defer cancel()
out, err := proto.NewCommandProviderClient(conn).SendCommand(ctx, &proto.CommandArgument{
Command: command,
Method: method,
Payload: c.Body(),
})
if err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
} else {
c.Set(fiber.HeaderContentType, out.ContentType)
return c.Status(int(out.Status)).Send(out.Payload)
}
}

View File

@@ -1,57 +0,0 @@
package server
import (
"git.solsynth.dev/hypernet/nexus/pkg/internal/auth"
"git.solsynth.dev/hypernet/nexus/pkg/internal/http/api"
"github.com/goccy/go-json"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/idempotency"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
)
type HTTPApp struct {
app *fiber.App
}
func NewServer() *HTTPApp {
app := fiber.New(fiber.Config{
DisableStartupMessage: true,
EnableIPValidation: true,
ServerHeader: "Hypernet.Nexus",
AppName: "Hypernet.Nexus",
ProxyHeader: fiber.HeaderXForwardedFor,
JSONEncoder: json.Marshal,
JSONDecoder: json.Unmarshal,
BodyLimit: 512 * 1024 * 1024 * 1024, // 512 TiB
EnablePrintRoutes: viper.GetBool("debug.print_routes"),
})
app.Use(idempotency.New())
app.Use(cors.New(cors.Config{
AllowCredentials: true,
AllowMethods: "GET,POST,HEAD,PUT,DELETE,PATCH",
AllowOriginsFunc: func(origin string) bool {
return true
},
}))
app.Use(logger.New(logger.Config{
Format: "${status} | ${latency} | ${method} ${path}\n",
Output: log.Logger,
}))
app.Use(auth.ContextMiddleware)
api.MapAPIs(app)
return &HTTPApp{app}
}
func (v *HTTPApp) Listen() {
if err := v.app.Listen(viper.GetString("bind")); err != nil {
log.Fatal().Err(err).Msg("An error occurred when starting server...")
}
}

View File

@@ -0,0 +1,154 @@
package watchtower
import (
"bytes"
"fmt"
"os"
"os/exec"
"os/user"
"path/filepath"
"strings"
"time"
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
"gorm.io/driver/postgres"
"gorm.io/gorm"
)
var dbWatchlist []string
func AddWatchDb(dsn string) {
dbWatchlist = append(dbWatchlist, dsn)
}
func BackupDb() error {
backupPath := viper.GetString("watchtower.database_backups")
if err := os.MkdirAll(backupPath, 0775); err != nil {
return fmt.Errorf("failed to create backup path: %v", err)
}
outFile := filepath.Join(
backupPath,
fmt.Sprintf("watchtower_db_backup_%s", time.Now().Format("2006-01-02_15:04:05")),
)
// Reading config
var password string
var username string
var host string
var port string
dsnParts := strings.Split(viper.GetString("database.dsn"), " ")
for _, part := range dsnParts {
if strings.HasPrefix(part, "password=") {
password = strings.Replace(part, "password=", "", 1)
} else if strings.HasPrefix(part, "user=") {
username = strings.Replace(part, "user=", "", 1)
} else if strings.HasPrefix(part, "host=") {
host = strings.Replace(part, "host=", "", 1)
} else if strings.HasPrefix(part, "port=") {
port = strings.Replace(part, "port=", "", 1)
}
}
// Creating ~/.pgpass
usr, err := user.Current()
if err != nil {
return fmt.Errorf("unable to get current user: %v", err)
}
homeDir := usr.HomeDir
pgpassFile := filepath.Join(homeDir, ".pgpass")
pgpassString := fmt.Sprintf("%s:%s:%s:%s:%s\n", host, port, "*", username, password)
// Open the .pgpass pgpass for writing (create if it doesn't exist)
pgpass, err := os.OpenFile(pgpassFile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) // Set file permissions to 0600
if err != nil {
log.Error().Err(err).Str("path", pgpassFile).Msg("Failed to open .pgpass file...")
return fmt.Errorf("failed to open .pgpass file: %v", err)
}
if _, err = pgpass.WriteString(pgpassString); err != nil {
log.Error().Err(err).Msg("Failed to write to .pgpass file...")
return fmt.Errorf("failed to write to .pgpass file: %v", err)
} else {
pgpass.Close()
}
log.Info().Msg("Wrote to .pgpass file...")
// Backing up
log.Info().
Str("password", password).Str("user", username).
Str("host", host).Str("port", port).
Msg("Starting backup database...")
cmd := exec.Command("pg_dumpall",
"-h", host,
"-p", port,
"-U", username,
"-f", outFile,
"-w",
)
cmd.Env = os.Environ()
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
start := time.Now()
if err := cmd.Run(); err != nil {
log.Error().
Err(err).Str("stdout", stdout.String()).Str("stderr", stderr.String()).
Msg("Failed to backup the database...")
return err
}
took := time.Since(start)
log.Info().
Str("out", outFile).Dur("took", took).
Str("stdout", stdout.String()).Str("stderr", stderr.String()).
Msg("Backed up database successfully!")
return nil
}
func CleanDb(dsn string) error {
conn, err := gorm.Open(postgres.Open(dsn))
if err != nil {
return fmt.Errorf("failed to open database: %v", err)
}
var tables []string
if err := conn.Raw("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'").Scan(&tables).Error; err != nil {
return fmt.Errorf("failed to scan tables: %v", err)
}
deadline := time.Now().Add(-7 * 24 * time.Hour) // 7 days before
for _, table := range tables {
sql := fmt.Sprintf("DELETE FROM %s WHERE deleted_at < ?", table)
if tx := conn.Raw(sql, deadline); tx.Error != nil {
log.Warn().Err(err).Str("table", table).Str("dsn", dsn).Msg("Unable to clean soft deleted records in this table...")
} else {
log.Info().Str("table", table).Str("dsn", dsn).Int64("rows", tx.RowsAffected).Msg("Cleaned soft deleted records in this table...")
}
}
return nil
}
func CleanAllDb() {
for _, database := range dbWatchlist {
if err := CleanDb(database); err != nil {
log.Error().Err(err).Msg("Failed to clean up a database...")
}
}
}
func RunDbMaintenance() {
if err := BackupDb(); err != nil {
return
}
CleanAllDb()
}

View File

@@ -0,0 +1,25 @@
package api
import (
"git.solsynth.dev/hypernet/nexus/pkg/internal/captcha"
"git.solsynth.dev/hypernet/nexus/pkg/internal/web/exts"
"github.com/gofiber/fiber/v2"
)
func renderCaptcha(c *fiber.Ctx) error {
return c.Render("captcha", captcha.GetTemplateData())
}
func validateCaptcha(c *fiber.Ctx) error {
var body struct {
CaptchaToken string `json:"captcha_tk"`
}
if err := exts.BindAndValidate(c, &body); err != nil {
return err
}
if !captcha.Validate(body.CaptchaToken, c.IP()) {
return c.SendStatus(fiber.StatusNotAcceptable)
}
return c.SendStatus(fiber.StatusOK)
}

View File

@@ -2,14 +2,39 @@ package api
import (
"fmt"
"strings"
"git.solsynth.dev/hypernet/nexus/pkg/internal/directory"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/proxy"
"github.com/spf13/viper"
"github.com/valyala/fasthttp"
"strings"
)
func forwardWebfinger(c *fiber.Ctx) error {
service := directory.GetServiceInstanceByType("co")
if service == nil || service.HttpAddr == nil {
return fiber.ErrNotFound
}
url := c.OriginalURL()
url = strings.Replace(url, "/.well-known", "", 1)
url = *service.HttpAddr + url
if tk, ok := c.Locals("nex_token").(string); ok {
c.Request().Header.Set(fiber.HeaderAuthorization, fmt.Sprintf("Bearer %s", tk))
} else {
c.Request().Header.Del(fiber.HeaderAuthorization)
}
return proxy.Do(c, url, &fasthttp.Client{
NoDefaultUserAgentHeader: true,
DisablePathNormalizing: true,
StreamResponseBody: true,
})
}
func forwardService(c *fiber.Ctx) error {
serviceType := c.Params("service")
ogKeyword := serviceType

View File

@@ -4,27 +4,32 @@ import (
pkg "git.solsynth.dev/hypernet/nexus/pkg/internal"
"git.solsynth.dev/hypernet/nexus/pkg/internal/auth"
"git.solsynth.dev/hypernet/nexus/pkg/internal/directory"
"git.solsynth.dev/hypernet/nexus/pkg/internal/http/ws"
"git.solsynth.dev/hypernet/nexus/pkg/internal/web/ws"
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"github.com/gofiber/contrib/websocket"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/proxy"
)
func MapAPIs(app *fiber.App) {
func MapControllers(app *fiber.App) {
app.Get("/meet/:channel", renderMeetRoom)
app.Get("/captcha", renderCaptcha)
app.Post("/captcha", validateCaptcha)
app.Get("/check-ip", getClientIP)
app.Get("/", func(c *fiber.Ctx) error {
return c.JSON(fiber.Map{
"api_level": pkg.ApiLevel,
"version": pkg.AppVersion,
"status": true,
})
})
app.Get("/directory/status", getServicesStatus)
app.Get("/directory/services", listExistsService)
// Some built-in public-accessible APIs
wellKnown := app.Group("/.well-known").Name("Well Known")
{
wellKnown.Get("/", func(c *fiber.Ctx) error {
return c.JSON(fiber.Map{
"api_level": pkg.ApiLevel,
"version": pkg.AppVersion,
"status": true,
})
})
wellKnown.Get("/check-ip", getClientIP)
wellKnown.Get("/directory/services", listExistsService)
wellKnown.Get("/webfinger", forwardWebfinger) // Forward webfinger to Interactive
wellKnown.Get("/openid-configuration", func(c *fiber.Ctx) error {
service := directory.GetServiceInstanceByType(nex.ServiceTypeAuth)
if service == nil || service.HttpAddr == nil {
@@ -41,9 +46,14 @@ func MapAPIs(app *fiber.App) {
})
}
// WatchTower administration APIs
wt := app.Group("/wt").Name("WatchTower").Use(auth.ValidatorMiddleware)
{
wt.Post("/maintenance/database", watchRunDbMaintenance)
}
// Common websocket gateway
app.Get("/ws", auth.ValidatorMiddleware, websocket.New(ws.Listen))
app.All("/inv/:command", invokeCommand)
app.All("/cgi/:service/*", forwardService)
}

View File

@@ -0,0 +1,55 @@
package api
import (
"fmt"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"github.com/gofiber/fiber/v2"
"github.com/spf13/viper"
"strings"
)
type meetRoomArgs struct {
RoomName string `json:"room_name"`
User meetRoomUser `json:"user"`
}
type meetRoomUser struct {
Avatar string `json:"avatar"`
Nick string `json:"nick"`
}
func renderMeetRoom(c *fiber.Ctx) error {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("nex_user").(*sec.UserInfo)
channel := c.Params("channel")
var nick string
if val, ok := user.Metadata["nick"].(string); ok {
nick = val
} else {
nick = user.Name
}
var avatar string
if val, ok := user.Metadata["avatar"].(string); ok {
if strings.HasPrefix(val, "http") {
avatar = val
} else {
endpoint := viper.GetString("resources_endpoint")
avatar = fmt.Sprintf("%s/attachments/%s", endpoint, val)
}
avatar = fmt.Sprintf("\"%s\"", avatar) // Make the avatar a string to embed into the js
} else {
avatar = "undefined"
}
return c.Render("meet", meetRoomArgs{
RoomName: fmt.Sprintf("%s-%s", "sn-chat", channel),
User: meetRoomUser{
Avatar: avatar,
Nick: nick,
},
})
}

View File

@@ -0,0 +1,10 @@
package api
import (
"git.solsynth.dev/hypernet/nexus/pkg/internal/directory"
"github.com/gofiber/fiber/v2"
)
func getServicesStatus(c *fiber.Ctx) error {
return c.JSON(directory.GetServiceStatus())
}

View File

@@ -0,0 +1,15 @@
package api
import (
"git.solsynth.dev/hypernet/nexus/pkg/internal/watchtower"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"github.com/gofiber/fiber/v2"
)
func watchRunDbMaintenance(c *fiber.Ctx) error {
if err := sec.EnsureGrantedPerm(c, "AdminOperateWatchTower", true); err != nil {
return err
}
go watchtower.RunDbMaintenance()
return c.SendStatus(fiber.StatusOK)
}

View File

@@ -0,0 +1,34 @@
package web
import (
"bufio"
"os"
"github.com/rs/zerolog/log"
)
var ipBlocklist []string
func AddBlockIP(ip string) {
ipBlocklist = append(ipBlocklist, ip)
}
func ParseBlockIPList(path string) error {
file, err := os.Open(path)
if err != nil {
return err
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
ipBlocklist = append(ipBlocklist, scanner.Text())
}
if err := scanner.Err(); err != nil {
return err
}
log.Info().Int("count", len(ipBlocklist)).Msg("Block IP list parsed successfully.")
return nil
}

View File

@@ -0,0 +1,89 @@
package web
import (
"time"
"git.solsynth.dev/hypernet/nexus/pkg/internal/auth"
"git.solsynth.dev/hypernet/nexus/pkg/internal/web/api"
"github.com/goccy/go-json"
"github.com/gofiber/contrib/fiberzerolog"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/idempotency"
"github.com/gofiber/fiber/v2/middleware/limiter"
"github.com/gofiber/template/html/v2"
"github.com/rs/zerolog/log"
"github.com/samber/lo"
"github.com/spf13/viper"
)
type WebApp struct {
app *fiber.App
}
func NewServer() *WebApp {
engine := html.New(viper.GetString("templates_dir"), ".tmpl")
app := fiber.New(fiber.Config{
DisableStartupMessage: true,
EnableIPValidation: true,
ServerHeader: "HyperNet.Nexus",
AppName: "HyperNet.Nexus",
ProxyHeader: fiber.HeaderXForwardedFor,
JSONEncoder: json.Marshal,
JSONDecoder: json.Unmarshal,
BodyLimit: 512 * 1024 * 1024 * 1024, // 512 TiB
ReadBufferSize: 5 * 1024 * 1024, // 5MB for large JWT
EnablePrintRoutes: viper.GetBool("debug.print_routes"),
Views: engine,
})
app.Use(fiberzerolog.New(fiberzerolog.Config{
Logger: &log.Logger,
}))
app.Use(idempotency.New())
app.Use(cors.New(cors.Config{
AllowCredentials: true,
AllowMethods: "GET,POST,HEAD,PUT,DELETE,PATCH",
AllowOriginsFunc: func(origin string) bool {
return true
},
}))
app.Use(func(c *fiber.Ctx) error {
if lo.Contains(ipBlocklist, c.IP()) {
return fiber.NewError(fiber.StatusForbidden, "your ip has been listed in the blacklist")
}
return c.Next()
})
app.Use(limiter.New(limiter.Config{
Max: viper.GetInt("rate_limit"),
Expiration: 60 * time.Second,
LimiterMiddleware: limiter.SlidingWindow{},
Next: func(c *fiber.Ctx) bool {
return lo.Contains([]string{"POST", "PUT", "DELETE", "PATCH"}, c.Method())
},
}))
app.Use(limiter.New(limiter.Config{
Max: viper.GetInt("rate_limit_advance"),
Expiration: 60 * time.Second,
LimiterMiddleware: limiter.SlidingWindow{},
Next: func(c *fiber.Ctx) bool {
return lo.Contains([]string{"GET", "HEAD", "OPTIONS", "CONNECT", "TRACE"}, c.Method())
},
}))
app.Use(auth.ContextMiddleware)
api.MapControllers(app)
return &WebApp{app}
}
func (v *WebApp) Listen() {
if err := v.app.Listen(viper.GetString("bind")); err != nil {
log.Fatal().Err(err).Msg("An error occurred when starting server...")
}
}

View File

@@ -1,31 +1,41 @@
package ws
import (
"fmt"
"sync"
"git.solsynth.dev/hypernet/nexus/pkg/internal/directory"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"github.com/google/uuid"
"github.com/rs/zerolog/log"
"math/rand"
"sync"
"github.com/gofiber/contrib/websocket"
)
var (
wsMutex sync.Mutex
wsConn = make(map[uint]map[uint64]*websocket.Conn)
wsConn = make(map[uint]map[string]*websocket.Conn)
)
func ClientRegister(user sec.UserInfo, conn *websocket.Conn) uint64 {
func ClientRegister(user sec.UserInfo, conn *websocket.Conn) (string, error) {
wsMutex.Lock()
if wsConn[user.ID] == nil {
wsConn[user.ID] = make(map[uint64]*websocket.Conn)
wsConn[user.ID] = make(map[string]*websocket.Conn)
}
var clientId string
if userDefinedId := conn.Query("clientId"); len(userDefinedId) > 0 && len(userDefinedId) <= 16 {
clientId = userDefinedId
} else {
clientId = uuid.NewString()
}
if _, ok := wsConn[user.ID][clientId]; ok {
return clientId, fmt.Errorf("client already conncted")
}
clientId := rand.Uint64()
wsConn[user.ID][clientId] = conn
wsMutex.Unlock()
log.Debug().
Uint64("client_id", clientId).
Str("client_id", clientId).
Uint("user_id", user.ID).
Msg("An client connected to stream endpoint...")
@@ -34,19 +44,19 @@ func ClientRegister(user sec.UserInfo, conn *websocket.Conn) uint64 {
"id": clientId,
})
return clientId
return clientId, nil
}
func ClientUnregister(user sec.UserInfo, id uint64) {
func ClientUnregister(user sec.UserInfo, id string) {
wsMutex.Lock()
if wsConn[user.ID] == nil {
wsConn[user.ID] = make(map[uint64]*websocket.Conn)
wsConn[user.ID] = make(map[string]*websocket.Conn)
}
delete(wsConn[user.ID], id)
wsMutex.Unlock()
log.Debug().
Uint64("client_id", id).
Str("client_id", id).
Uint("user_id", user.ID).
Msg("An client disconnected from stream endpoint...")
@@ -60,25 +70,25 @@ func ClientCount(uid uint) int {
return len(wsConn[uid])
}
func WebsocketPush(uid uint, body []byte) (count int, success int, errs []error) {
func WebsocketPush(uid uint, body []byte) (count int, successes []string, errs []error) {
for _, conn := range wsConn[uid] {
if err := conn.WriteMessage(1, body); err != nil {
errs = append(errs, err)
} else {
success++
successes = append(successes, fmt.Sprintf("%d", uid))
}
count++
}
return
}
func WebsocketPushDirect(clientId uint64, body []byte) (count int, success int, errs []error) {
func WebsocketPushDirect(clientId string, body []byte) (count int, successes []string, errs []error) {
for _, m := range wsConn {
if conn, ok := m[clientId]; ok {
if err := conn.WriteMessage(1, body); err != nil {
errs = append(errs, err)
} else {
success++
successes = append(successes, clientId)
}
count++
}
@@ -86,13 +96,13 @@ func WebsocketPushDirect(clientId uint64, body []byte) (count int, success int,
return
}
func WebsocketPushBatch(uidList []uint, body []byte) (count int, success int, errs []error) {
func WebsocketPushBatch(uidList []uint, body []byte) (count int, successes []string, errs []error) {
for _, uid := range uidList {
for _, conn := range wsConn[uid] {
if err := conn.WriteMessage(1, body); err != nil {
errs = append(errs, err)
} else {
success++
successes = append(successes, fmt.Sprintf("%d", uid))
}
count++
}
@@ -100,14 +110,14 @@ func WebsocketPushBatch(uidList []uint, body []byte) (count int, success int, er
return
}
func WebsocketPushBatchDirect(clientIdList []uint64, body []byte) (count int, success int, errs []error) {
func WebsocketPushBatchDirect(clientIdList []string, body []byte) (count int, successes []string, errs []error) {
for _, clientId := range clientIdList {
for _, m := range wsConn {
if conn, ok := m[clientId]; ok {
if err := conn.WriteMessage(1, body); err != nil {
errs = append(errs, err)
} else {
success++
successes = append(successes, clientId)
}
count++
}

View File

@@ -11,24 +11,34 @@ import (
"github.com/gofiber/contrib/websocket"
jsoniter "github.com/json-iterator/go"
"github.com/samber/lo"
"github.com/spf13/viper"
)
func Listen(c *websocket.Conn) {
user, ok := c.Locals("nex_user").(sec.UserInfo)
user, ok := c.Locals("nex_user").(*sec.UserInfo)
if !ok {
_ = c.WriteMessage(1, nex.WebSocketPackage{
Action: "error",
Message: "unauthorized",
}.Marshal())
c.Close()
return
}
// Push connection
clientId := ClientRegister(user, c)
var err error
clientId, err := ClientRegister(*user, c)
if err != nil {
_ = c.WriteMessage(1, nex.WebSocketPackage{
Action: "error",
Message: "client with this id already connected",
}.Marshal())
c.Close()
return
}
// Event loop
var mt int
var data []byte
var err error
var packet nex.WebSocketPackage
for {
@@ -42,11 +52,6 @@ func Listen(c *websocket.Conn) {
continue
}
aliasingMap := viper.GetStringMapString("services.aliases")
if val, ok := aliasingMap[packet.Endpoint]; ok {
packet.Endpoint = val
}
service := directory.GetServiceInstanceByType(packet.Endpoint)
if service == nil {
_ = c.WriteMessage(mt, nex.WebSocketPackage{
@@ -80,5 +85,5 @@ func Listen(c *websocket.Conn) {
}
// Pop connection
ClientUnregister(user, clientId)
ClientUnregister(*user, clientId)
}

View File

@@ -2,18 +2,21 @@ package main
import (
"fmt"
"git.solsynth.dev/hypernet/nexus/pkg/internal/auth"
"git.solsynth.dev/hypernet/nexus/pkg/internal/database"
"git.solsynth.dev/hypernet/nexus/pkg/internal/directory"
"git.solsynth.dev/hypernet/nexus/pkg/internal/http"
"git.solsynth.dev/hypernet/nexus/pkg/internal/kv"
"git.solsynth.dev/hypernet/nexus/pkg/internal/mq"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"github.com/fatih/color"
"os"
"os/signal"
"syscall"
"git.solsynth.dev/hypernet/nexus/pkg/internal/auth"
"git.solsynth.dev/hypernet/nexus/pkg/internal/cache"
"git.solsynth.dev/hypernet/nexus/pkg/internal/database"
"git.solsynth.dev/hypernet/nexus/pkg/internal/directory"
"git.solsynth.dev/hypernet/nexus/pkg/internal/kv"
"git.solsynth.dev/hypernet/nexus/pkg/internal/mq"
"git.solsynth.dev/hypernet/nexus/pkg/internal/watchtower"
"git.solsynth.dev/hypernet/nexus/pkg/internal/web"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"github.com/fatih/color"
pkg "git.solsynth.dev/hypernet/nexus/pkg/internal"
"git.solsynth.dev/hypernet/nexus/pkg/internal/grpc"
"github.com/robfig/cron/v3"
@@ -48,6 +51,8 @@ func main() {
// Load settings
if err := viper.ReadInConfig(); err != nil {
log.Panic().Err(err).Msg("An error occurred when loading settings.")
} else if err := web.ParseBlockIPList(viper.GetString("ip_block_path")); err != nil {
log.Error().Err(err).Msg("An error occurred when parsing block IP list.")
}
// Connect to kv (etcd)
@@ -67,6 +72,14 @@ func main() {
log.Info().Msg("Connected to MQ (nats)!")
}
// Connect to cache (redis)
log.Info().Msg("Connecting to cache (redis)...")
if err := cache.ConnectRedis(viper.GetString("cache.addr"), viper.GetString("cache.password"), 0); err != nil {
log.Error().Err(err).Msg("An error occurred when connecting to cache (redis). Cache related features will be disabled.")
} else {
log.Info().Msg("Connected to cache (redis)!")
}
// Connect to database
log.Info().Msg("Connecting to database...")
if db, err := database.Connect(viper.GetString("database.dsn")); err != nil {
@@ -107,13 +120,15 @@ func main() {
go directory.ValidateServices()
// Server
go server.NewServer().Listen()
go web.NewServer().Listen()
// Grpc Server
go grpc.NewServer().Listen()
// Configure timed tasks
quartz := cron.New(cron.WithLogger(cron.VerbosePrintfLogger(&log.Logger)))
quartz.AddFunc("@midnight", watchtower.RunDbMaintenance)
quartz.AddFunc("@every 5m", directory.ValidateServices)
quartz.Start()
// Messages

View File

@@ -2,14 +2,17 @@ package nex
import (
"context"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
"github.com/redis/go-redis/v9"
)
type AllocatableResourceType = string
const (
AllocatableResourceMq = AllocatableResourceType("mq")
AllocatableResourceKv = AllocatableResourceType("kv")
AllocatableResourceMq = AllocatableResourceType("mq")
AllocatableResourceKv = AllocatableResourceType("kv")
AllocatableResourceCache = AllocatableResourceType("cache")
)
func (v *Conn) AllocResource(t AllocatableResourceType) any {
@@ -28,6 +31,19 @@ func (v *Conn) AllocResource(t AllocatableResourceType) any {
return nil
}
return resp.Endpoints
case AllocatableResourceCache:
conn := v.GetNexusGrpcConn()
resp, err := proto.NewAllocatorServiceClient(conn).AllocCache(context.Background(), &proto.AllocCacheRequest{
Db: 0,
})
if err != nil || !resp.IsSuccess {
return nil
}
return redis.NewClient(&redis.Options{
Addr: resp.GetAddr(),
Password: resp.GetPassword(),
DB: int(resp.GetDb()),
})
default:
return nil
}

View File

@@ -0,0 +1,9 @@
package cachekit
import (
redis_store "github.com/eko/gocache/store/redis/v4"
)
func (c *Conn) GoCache() *redis_store.RedisStore {
return redis_store.NewRedis(c.Rd)
}

View File

@@ -0,0 +1,15 @@
package cachekit
import "fmt"
// Those constants are used to directly get the cached data from redis
// Formatted like {prefix}#{key}
const (
DAAttachment = "attachment"
DAUser = "account"
DARealm = "realm"
)
func FKey(prefix string, key any) string {
return fmt.Sprintf("%s#%v", prefix, key)
}

75
pkg/nex/cachekit/io.go Normal file
View File

@@ -0,0 +1,75 @@
package cachekit
import (
"fmt"
"time"
"github.com/eko/gocache/lib/v4/cache"
"github.com/eko/gocache/lib/v4/store"
"github.com/goccy/go-json"
)
// The functions below are operating the redis via the gocache
// Provide a advanced tagging experience
// At the same time, the advanced cache using client side marshaling to handle the advance data types
func Set[T any](c *Conn, key string, value T, ttl time.Duration, tags ...string) error {
raw, err := json.Marshal(value)
if err != nil {
return fmt.Errorf("unable to marshal value during caching: %v", err)
}
ctx, cancel := c.withTimeout()
defer cancel()
cm := cache.New[string](c.GoCache())
return cm.Set(ctx, key, string(raw), store.WithTags(tags), store.WithExpiration(ttl))
}
// SetKA stands for Set Keep Alive
// Don't set a TTL for the value set via this function
func SetKA[T any](c *Conn, key string, value T, tags ...string) error {
raw, err := json.Marshal(value)
if err != nil {
return fmt.Errorf("unable to marshal value during caching: %v", err)
}
ctx, cancel := c.withTimeout()
defer cancel()
cm := cache.New[string](c.GoCache())
return cm.Set(ctx, key, string(raw), store.WithTags(tags))
}
func Get[T any](c *Conn, key string) (T, error) {
var out T
ctx, cancel := c.withTimeout()
defer cancel()
cm := cache.New[string](c.GoCache())
raw, err := cm.Get(ctx, key)
if err != nil {
return out, err
}
if err := json.Unmarshal([]byte(raw), &out); err != nil {
return out, fmt.Errorf("unable to unmarshal value during caching: %v", err)
}
return out, nil
}
func Delete(c *Conn, key string) error {
ctx, cancel := c.withTimeout()
defer cancel()
cm := cache.New[[]byte](c.GoCache())
return cm.Delete(ctx, key)
}
func DeleteByTags(c *Conn, tags ...string) error {
if len(tags) == 0 {
return nil
}
ctx, cancel := c.withTimeout()
defer cancel()
cm := cache.New[[]byte](c.GoCache())
return cm.Invalidate(ctx, store.WithInvalidateTags(tags))
}

View File

@@ -0,0 +1,54 @@
package cachekit
import "time"
// The functions below are directly using the redis connection to operaete the redis
// Set stores a key-value pair in Redis with an optional expiration time
func (c *Conn) RSet(key string, value any, ttl time.Duration) error {
ctx, cancel := c.withTimeout()
defer cancel()
return c.Rd.Set(ctx, key, value, ttl).Err()
}
// Get retrieves a value from Redis by key
func (c *Conn) RGet(key string) (string, error) {
ctx, cancel := c.withTimeout()
defer cancel()
return c.Rd.Get(ctx, key).Result()
}
// Delete removes a key from Redis
func (c *Conn) RDelete(key string) error {
ctx, cancel := c.withTimeout()
defer cancel()
return c.Rd.Del(ctx, key).Err()
}
// Exists checks if a key exists in Redis
func (c *Conn) RExists(key string) (bool, error) {
ctx, cancel := c.withTimeout()
defer cancel()
exists, err := c.Rd.Exists(ctx, key).Result()
if err != nil {
return false, err
}
return exists > 0, nil
}
// ClearCacheByPrefix deletes all keys matching a given prefix
func (c *Conn) RDeleteByPrefix(prefix string) error {
ctx, cancel := c.withTimeout()
defer cancel()
iter := c.Rd.Scan(ctx, 0, prefix+"*", 0).Iterator()
for iter.Next(ctx) {
if err := c.Rd.Del(ctx, iter.Val()).Err(); err != nil {
return err
}
}
if err := iter.Err(); err != nil {
return err
}
return nil
}

56
pkg/nex/cachekit/rdb.go Normal file
View File

@@ -0,0 +1,56 @@
package cachekit
import (
"context"
"fmt"
"sync"
"time"
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"github.com/redis/go-redis/v9"
)
// The global variable below is used to keep there will only be one redis client exist in a single instance
// Prevent if other DirectAccess™ SDK creating too many redis clients
// And able to recreate the conn with different options
var (
rdc *redis.Client
rdl sync.Mutex
)
type Conn struct {
n *nex.Conn
Rd *redis.Client
Timeout time.Duration
}
func NewConn(conn *nex.Conn, timeout time.Duration) (*Conn, error) {
rdl.Lock()
defer rdl.Unlock()
c := &Conn{
n: conn,
Timeout: timeout,
}
if rdc != nil {
c.Rd = rdc
return c, nil
}
rdb := conn.AllocResource(nex.AllocatableResourceCache)
if rdb == nil {
return nil, fmt.Errorf("unable to allocate resource: cache")
} else if client, ok := rdb.(*redis.Client); !ok {
return nil, fmt.Errorf("allocated cache resource is not a redis client")
} else {
c.Rd = client
rdc = client
}
return c, nil
}
func (c *Conn) withTimeout() (context.Context, context.CancelFunc) {
return context.WithTimeout(context.Background(), c.Timeout)
}

19
pkg/nex/captcha.go Normal file
View File

@@ -0,0 +1,19 @@
package nex
import (
"context"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
)
func (v *Conn) ValidateCaptcha(token, ip string) bool {
client := proto.NewCaptchaServiceClient(v.nexusConn)
resp, err := client.CheckCaptcha(context.Background(), &proto.CheckCaptchaRequest{
Token: token,
RemoteIp: ip,
})
if err != nil {
return false
}
return resp.GetIsValid()
}

View File

@@ -1,150 +0,0 @@
package nex
import (
"context"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
"google.golang.org/grpc"
health "google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/reflection"
"net"
"net/http"
"strconv"
"strings"
"time"
)
type CommandHandler func(ctx *CommandCtx) error
func GetCommandKey(id, method string) string {
return id + ":" + method
}
func (v *Conn) AddCommand(id, method string, tags []string, fn CommandHandler) error {
method = strings.ToLower(method)
dir := proto.NewCommandProviderClient(v.nexusConn)
ctx := context.Background()
ctx = metadata.AppendToOutgoingContext(ctx, "client_id", v.Info.Id)
var addingMethodQueue []string
if method == "all" {
addingMethodQueue = []string{"get", "post", "put", "patch", "delete"}
} else {
addingMethodQueue = append(addingMethodQueue, method)
}
for _, method := range addingMethodQueue {
ky := GetCommandKey(id, method)
_, err := dir.AddCommand(ctx, &proto.CommandInfo{
Id: id,
Method: method,
Tags: tags,
})
if err == nil {
v.commandHandlers[ky] = fn
} else {
return err
}
}
return nil
}
type localCommandRpcServer struct {
conn *Conn
proto.UnimplementedCommandProviderServer
health.UnimplementedHealthServer
}
func (v localCommandRpcServer) SendCommand(ctx context.Context, argument *proto.CommandArgument) (*proto.CommandReturn, error) {
ky := GetCommandKey(argument.GetCommand(), argument.GetMethod())
if handler, ok := v.conn.commandHandlers[ky]; !ok {
return &proto.CommandReturn{
Status: http.StatusNotFound,
Payload: []byte(argument.GetCommand() + " not found"),
}, nil
} else {
cc := &CommandCtx{
requestBody: argument.GetPayload(),
statusCode: http.StatusOK,
}
if md, ok := metadata.FromIncomingContext(ctx); ok {
for k, v := range md {
var val any = nil
if len(v) == 1 {
if len(v[0]) != 0 {
if i, err := strconv.ParseInt(v[0], 10, 64); err == nil {
val = i
} else if b, err := strconv.ParseBool(v[0]); err == nil {
val = b
} else if f, err := strconv.ParseFloat(v[0], 64); err == nil {
val = f
}
layouts := []string{
time.RFC3339,
"2006-01-02 15:04:05", // Example: 2024-10-20 14:55:05
"2006-01-02", // Example: 2024-10-20
}
for _, layout := range layouts {
if t, err := time.Parse(layout, v[0]); err == nil {
val = t
}
}
if val == nil {
val = v[0]
}
} else {
val = v[0]
}
} else if len(v) > 1 {
val = v
}
cc.values.Store(k, val)
}
}
if err := handler(cc); err != nil {
return nil, err
} else {
return &proto.CommandReturn{
Status: int32(cc.statusCode),
ContentType: cc.contentType,
Payload: cc.responseBody,
}, nil
}
}
}
func (v localCommandRpcServer) Check(ctx context.Context, request *health.HealthCheckRequest) (*health.HealthCheckResponse, error) {
return &health.HealthCheckResponse{
Status: health.HealthCheckResponse_SERVING,
}, nil
}
func (v localCommandRpcServer) Watch(request *health.HealthCheckRequest, server health.Health_WatchServer) error {
for {
if server.Send(&health.HealthCheckResponse{
Status: health.HealthCheckResponse_SERVING,
}) != nil {
break
}
time.Sleep(1000 * time.Millisecond)
}
return nil
}
func (v *Conn) RunCommands(addr string) error {
v.commandServer = grpc.NewServer()
service := &localCommandRpcServer{conn: v}
proto.RegisterCommandProviderServer(v.commandServer, service)
health.RegisterHealthServer(v.commandServer, service)
reflection.Register(v.commandServer)
listener, err := net.Listen("tcp", addr)
if err != nil {
return err
}
return v.commandServer.Serve(listener)
}

View File

@@ -1,90 +0,0 @@
package nex
import (
"fmt"
"github.com/goccy/go-json"
"net/http"
"sync"
)
type CommandCtx struct {
requestBody []byte
responseBody []byte
contentType string
statusCode int
values sync.Map
}
func CtxValueMustBe[T any](c *CommandCtx, key string) (T, error) {
if val, ok := c.values.Load(key); ok {
if v, ok := val.(T); ok {
return v, nil
}
}
var out T
if err := c.Write([]byte(fmt.Sprintf("value %s not found in type %T", key, out)), "text/plain+error", http.StatusBadRequest); err != nil {
return out, err
}
return out, fmt.Errorf("value %s not found", key)
}
func CtxValueShouldBe[T any](c *CommandCtx, key string, defaultValue T) T {
if val, ok := c.values.Load(key); ok {
if v, ok := val.(T); ok {
return v
}
}
return defaultValue
}
func (c *CommandCtx) Values() map[string]any {
duplicate := make(map[string]any)
c.values.Range(func(key, value any) bool {
duplicate[key.(string)] = value
return true
})
return duplicate
}
func (c *CommandCtx) ValueOrElse(key string, defaultValue any) any {
val, _ := c.values.Load(key)
if val == nil {
return defaultValue
}
return val
}
func (c *CommandCtx) Value(key string, newValue ...any) any {
if len(newValue) > 0 {
c.values.Store(key, newValue[0])
}
val, _ := c.values.Load(key)
return val
}
func (c *CommandCtx) Read() []byte {
return c.requestBody
}
func (c *CommandCtx) ReadJSON(out any) error {
return json.Unmarshal(c.requestBody, out)
}
func (c *CommandCtx) Write(data []byte, contentType string, statusCode ...int) error {
c.responseBody = data
c.contentType = contentType
if len(statusCode) > 0 {
c.statusCode = statusCode[0]
}
return nil
}
func (c *CommandCtx) JSON(data any, statusCode ...int) error {
raw, err := json.Marshal(data)
if err != nil {
return err
}
return c.Write(raw, "application/json", statusCode...)
}

View File

@@ -1,60 +0,0 @@
package nex_test
import (
"fmt"
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
"net/http"
"testing"
"time"
)
func TestHandleCommand(t *testing.T) {
conn, err := nex.NewNexusConn("127.0.0.1:7001", &proto.ServiceInfo{
Id: "echo01",
Type: "echo",
Label: "Echo",
GrpcAddr: "127.0.0.1:6001",
HttpAddr: nil,
})
if err != nil {
t.Fatal(fmt.Errorf("unable to connect nexus: %v", err))
}
if err := conn.RegisterService(); err != nil {
t.Fatal(fmt.Errorf("unable to register service: %v", err))
}
err = conn.AddCommand("say.hi", "all", nil, func(ctx *nex.CommandCtx) error {
return ctx.Write([]byte("Hello, World!"), "text/plain", http.StatusOK)
})
if err != nil {
t.Fatal(fmt.Errorf("unable to add command: %v", err))
return
}
err = conn.AddCommand("echo", "all", nil, func(ctx *nex.CommandCtx) error {
t.Log("Received command: ", string(ctx.Read()))
return ctx.Write(ctx.Read(), "text/plain", http.StatusOK)
})
err = conn.AddCommand("echo.details", "all", nil, func(ctx *nex.CommandCtx) error {
return ctx.JSON(map[string]any{
"values": ctx.Values(),
"body": ctx.Read(),
}, http.StatusOK)
})
if err != nil {
t.Fatal(fmt.Errorf("unable to add command: %v", err))
return
}
go func() {
err := conn.RunCommands("0.0.0.0:6001")
if err != nil {
t.Error(fmt.Errorf("unable to run commands: %v", err))
return
}
}()
t.Log("Waiting 60 seconds for calling command...")
time.Sleep(time.Second * 60)
}

View File

@@ -2,9 +2,10 @@ package nex
import (
"context"
"google.golang.org/grpc/metadata"
"time"
"google.golang.org/grpc/metadata"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
@@ -15,9 +16,6 @@ type Conn struct {
Addr string
Info *proto.ServiceInfo
commandServer *grpc.Server
commandHandlers map[string]CommandHandler
nexusConn *grpc.ClientConn
clientConn map[string]*grpc.ClientConn
}
@@ -35,8 +33,6 @@ func NewNexusConn(addr string, info *proto.ServiceInfo) (*Conn, error) {
Addr: addr,
Info: info,
commandHandlers: make(map[string]CommandHandler),
nexusConn: conn,
clientConn: make(map[string]*grpc.ClientConn),
}, nil

View File

@@ -1,130 +0,0 @@
package cruda
import (
"errors"
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"github.com/go-playground/validator/v10"
"gorm.io/gorm"
"net/http"
)
type CrudAction func(v *CrudConn) nex.CommandHandler
func AddModel[T any](v *CrudConn, model T, id, prefix string, tags []string) error {
funcList := []CrudAction{cmdList[T], cmdGet[T], cmdCreate[T], cmdUpdate[T], cmdDelete[T]}
funcCmds := []string{".list", "", "", "", ""}
funcMethods := []string{"get", "get", "put", "patch", "delete"}
for idx, fn := range funcList {
if err := v.n.AddCommand(prefix+id+funcCmds[idx], funcMethods[idx], tags, fn(v)); err != nil {
return err
}
}
return nil
}
var validate = validator.New(validator.WithRequiredStructEnabled())
func cmdList[T any](c *CrudConn) nex.CommandHandler {
return func(ctx *nex.CommandCtx) error {
take := int(nex.CtxValueShouldBe[int64](ctx, "query.take", 10))
skip := int(nex.CtxValueShouldBe[int64](ctx, "query.skip", 0))
var str T
var count int64
if err := c.Db.Model(str).Count(&count).Error; err != nil {
return err
}
var out []T
if err := c.Db.Offset(skip).Limit(take).Find(&out).Error; err != nil {
return err
}
return ctx.JSON(map[string]any{
"count": count,
"data": out,
}, http.StatusOK)
}
}
func cmdGet[T any](c *CrudConn) nex.CommandHandler {
return func(ctx *nex.CommandCtx) error {
id, err := nex.CtxValueMustBe[int64](ctx, "query.id")
if err != nil {
return err
}
var out T
if err := c.Db.First(&out, "id = ?", id).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return ctx.Write([]byte(err.Error()), "text/plain", http.StatusNotFound)
}
return err
}
return ctx.JSON(out, http.StatusOK)
}
}
func cmdCreate[T any](c *CrudConn) nex.CommandHandler {
return func(ctx *nex.CommandCtx) error {
var payload T
if err := ctx.ReadJSON(&payload); err != nil {
return err
} else if err := validate.Struct(payload); err != nil {
return ctx.Write([]byte(err.Error()), "text/plain+error", http.StatusBadRequest)
}
if err := c.Db.Create(&payload).Error; err != nil {
return err
}
return ctx.JSON(payload, http.StatusOK)
}
}
func cmdUpdate[T any](c *CrudConn) nex.CommandHandler {
return func(ctx *nex.CommandCtx) error {
id, err := nex.CtxValueMustBe[int64](ctx, "query.id")
if err != nil {
return err
}
var payload T
if err := ctx.ReadJSON(&payload); err != nil {
return err
} else if err := validate.Struct(payload); err != nil {
return ctx.Write([]byte(err.Error()), "text/plain+error", http.StatusBadRequest)
}
var out T
if err := c.Db.Model(out).Where("id = ?", id).Updates(&payload).Error; err != nil {
return err
}
if err := c.Db.First(&out, "id = ?", id).Error; err != nil {
return err
}
return ctx.JSON(out, http.StatusOK)
}
}
func cmdDelete[T any](c *CrudConn) nex.CommandHandler {
return func(ctx *nex.CommandCtx) error {
id, err := nex.CtxValueMustBe[int64](ctx, "query.id")
if err != nil {
return err
}
var out T
if err := c.Db.Delete(&out, "id = ?", id).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return ctx.Write([]byte(err.Error()), "text/plain", http.StatusNotFound)
}
return err
}
return ctx.Write(nil, "text/plain", http.StatusOK)
}
}

View File

@@ -1,58 +0,0 @@
package cruda_test
import (
"fmt"
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"git.solsynth.dev/hypernet/nexus/pkg/nex/cruda"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
"testing"
"time"
)
type Test struct {
cruda.BaseModel
Content string `json:"content" validate:"required"`
}
func TestCrudaCommand(t *testing.T) {
conn, err := nex.NewNexusConn("127.0.0.1:7001", &proto.ServiceInfo{
Id: "cruda01",
Type: "cruda",
Label: "CRUD Accelerator",
GrpcAddr: "127.0.0.1:6001",
HttpAddr: nil,
})
if err != nil {
t.Fatal(fmt.Errorf("unable to connect nexus: %v", err))
}
if err := conn.RegisterService(); err != nil {
t.Fatal(fmt.Errorf("unable to register service: %v", err))
}
cc := cruda.NewCrudaConn(conn)
dsn, err := cc.AllocDatabase("test")
if err != nil {
t.Fatal(fmt.Errorf("unable to allocate database: %v", err))
}
t.Log(fmt.Sprintf("Allocated database: %s", dsn))
if err := cruda.MigrateModel(cc, Test{}); err != nil {
t.Fatal(fmt.Errorf("unable to migrate database: %v", err))
}
if err := cruda.AddModel(cc, Test{}, "tm", "test.", nil); err != nil {
t.Fatal(fmt.Errorf("unable to add commands: %v", err))
}
go func() {
err := conn.RunCommands("0.0.0.0:6001")
if err != nil {
t.Error(fmt.Errorf("unable to run commands: %v", err))
return
}
}()
t.Log("Waiting 180 seconds for calling command...")
time.Sleep(time.Second * 180)
}

139
pkg/nex/localize/bundle.go Normal file
View File

@@ -0,0 +1,139 @@
package localize
import (
"errors"
"fmt"
"github.com/goccy/go-json"
"github.com/nicksnyder/go-i18n/v2/i18n"
"github.com/rs/zerolog/log"
"golang.org/x/text/language"
htmpl "html/template"
"os"
"path/filepath"
"strings"
"text/template"
)
type Bundle struct {
Bundle *i18n.Bundle
LocalesPath string
TemplatesPath string
}
const FallbackLanguage = "en-US"
var L *Bundle
func LoadLocalization(localesPath string, templatesPath ...string) error {
L = &Bundle{
LocalesPath: localesPath,
}
if len(templatesPath) > 0 {
L.TemplatesPath = templatesPath[0]
}
L.Bundle = i18n.NewBundle(language.AmericanEnglish)
L.Bundle.RegisterUnmarshalFunc("json", json.Unmarshal)
var count int
basePath := localesPath
if entries, err := os.ReadDir(basePath); err != nil {
return fmt.Errorf("unable to read locales directory: %v", err)
} else {
for _, entry := range entries {
if entry.IsDir() {
continue
}
if _, err := L.Bundle.LoadMessageFile(filepath.Join(basePath, entry.Name())); err != nil {
return fmt.Errorf("unable to load localization file %s: %v", entry.Name(), err)
} else {
count++
}
}
}
log.Info().Int("locales", count).Msg("Loaded localization files...")
return nil
}
func (v *Bundle) GetLocalizer(lang string) *i18n.Localizer {
return i18n.NewLocalizer(v.Bundle, lang)
}
func (v *Bundle) GetLocalizedString(name string, lang string) string {
localizer := v.GetLocalizer(lang)
msg, err := localizer.LocalizeMessage(&i18n.Message{
ID: name,
})
if err != nil {
log.Warn().Err(err).Str("lang", lang).Str("name", name).Msg("Failed to localize string...")
return name
}
return msg
}
func (v *Bundle) GetLocalizedTemplatePath(name string, lang string) string {
basePath := v.TemplatesPath
filePath := filepath.Join(basePath, lang, name)
if _, err := os.Stat(filePath); errors.Is(err, os.ErrNotExist) {
// Fallback to English
filePath = filepath.Join(basePath, FallbackLanguage, name)
return filePath
}
return filePath
}
func (v *Bundle) GetLocalizedTemplate(name string, lang string) *template.Template {
path := v.GetLocalizedTemplatePath(name, lang)
tmpl, err := template.ParseFiles(path)
if err != nil {
log.Warn().Err(err).Str("lang", lang).Str("name", name).Msg("Failed to load localized template...")
return nil
}
return tmpl
}
func (v *Bundle) GetLocalizedTemplateHTML(name string, lang string) *htmpl.Template {
path := v.GetLocalizedTemplatePath(name, lang)
tmpl, err := htmpl.ParseFiles(path)
if err != nil {
log.Warn().Err(err).Str("lang", lang).Str("name", name).Msg("Failed to load localized template...")
return nil
}
return tmpl
}
func (v *Bundle) RenderLocalizedTemplateHTML(name string, lang string, data any) string {
tmpl := v.GetLocalizedTemplate(name, lang)
if tmpl == nil {
return ""
}
buf := new(strings.Builder)
err := tmpl.Execute(buf, data)
if err != nil {
log.Warn().Err(err).Str("lang", lang).Str("name", name).Msg("Failed to render localized template...")
return ""
}
return buf.String()
}
func (v *Bundle) RenderLocalizedTemplate(name string, lang string, data any) string {
tmpl := v.GetLocalizedTemplate(name, lang)
if tmpl == nil {
return ""
}
buf := new(strings.Builder)
err := tmpl.Execute(buf, data)
if err != nil {
log.Warn().Err(err).Str("lang", lang).Str("name", name).Msg("Failed to render localized template...")
return ""
}
return buf.String()
}

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc v5.28.2
// protoc-gen-go v1.36.6
// protoc v5.29.3
// source: allocator.proto
package proto
@@ -11,6 +11,7 @@ import (
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
@@ -21,18 +22,16 @@ const (
)
type AllocMqRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AllocMqRequest) Reset() {
*x = AllocMqRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_allocator_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_allocator_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AllocMqRequest) String() string {
@@ -43,7 +42,7 @@ func (*AllocMqRequest) ProtoMessage() {}
func (x *AllocMqRequest) ProtoReflect() protoreflect.Message {
mi := &file_allocator_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -59,21 +58,18 @@ func (*AllocMqRequest) Descriptor() ([]byte, []int) {
}
type AllocMqResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
IsSuccess bool `protobuf:"varint,1,opt,name=is_success,json=isSuccess,proto3" json:"is_success,omitempty"`
Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"`
unknownFields protoimpl.UnknownFields
IsSuccess bool `protobuf:"varint,1,opt,name=is_success,json=isSuccess,proto3" json:"is_success,omitempty"`
Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *AllocMqResponse) Reset() {
*x = AllocMqResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_allocator_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_allocator_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AllocMqResponse) String() string {
@@ -84,7 +80,7 @@ func (*AllocMqResponse) ProtoMessage() {}
func (x *AllocMqResponse) ProtoReflect() protoreflect.Message {
mi := &file_allocator_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -114,18 +110,16 @@ func (x *AllocMqResponse) GetAddr() string {
}
type AllocKvRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AllocKvRequest) Reset() {
*x = AllocKvRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_allocator_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_allocator_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AllocKvRequest) String() string {
@@ -136,7 +130,7 @@ func (*AllocKvRequest) ProtoMessage() {}
func (x *AllocKvRequest) ProtoReflect() protoreflect.Message {
mi := &file_allocator_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -152,21 +146,18 @@ func (*AllocKvRequest) Descriptor() ([]byte, []int) {
}
type AllocKvResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
IsSuccess bool `protobuf:"varint,1,opt,name=is_success,json=isSuccess,proto3" json:"is_success,omitempty"`
Endpoints []string `protobuf:"bytes,2,rep,name=endpoints,proto3" json:"endpoints,omitempty"`
unknownFields protoimpl.UnknownFields
IsSuccess bool `protobuf:"varint,1,opt,name=is_success,json=isSuccess,proto3" json:"is_success,omitempty"`
Endpoints []string `protobuf:"bytes,2,rep,name=endpoints,proto3" json:"endpoints,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *AllocKvResponse) Reset() {
*x = AllocKvResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_allocator_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_allocator_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AllocKvResponse) String() string {
@@ -177,7 +168,7 @@ func (*AllocKvResponse) ProtoMessage() {}
func (x *AllocKvResponse) ProtoReflect() protoreflect.Message {
mi := &file_allocator_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -206,61 +197,177 @@ func (x *AllocKvResponse) GetEndpoints() []string {
return nil
}
type AllocCacheRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Db int32 `protobuf:"varint,1,opt,name=db,proto3" json:"db,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AllocCacheRequest) Reset() {
*x = AllocCacheRequest{}
mi := &file_allocator_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AllocCacheRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AllocCacheRequest) ProtoMessage() {}
func (x *AllocCacheRequest) ProtoReflect() protoreflect.Message {
mi := &file_allocator_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 AllocCacheRequest.ProtoReflect.Descriptor instead.
func (*AllocCacheRequest) Descriptor() ([]byte, []int) {
return file_allocator_proto_rawDescGZIP(), []int{4}
}
func (x *AllocCacheRequest) GetDb() int32 {
if x != nil {
return x.Db
}
return 0
}
type AllocCacheResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
IsSuccess bool `protobuf:"varint,1,opt,name=is_success,json=isSuccess,proto3" json:"is_success,omitempty"`
Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"`
Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"`
Db int32 `protobuf:"varint,4,opt,name=db,proto3" json:"db,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AllocCacheResponse) Reset() {
*x = AllocCacheResponse{}
mi := &file_allocator_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AllocCacheResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AllocCacheResponse) ProtoMessage() {}
func (x *AllocCacheResponse) ProtoReflect() protoreflect.Message {
mi := &file_allocator_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 AllocCacheResponse.ProtoReflect.Descriptor instead.
func (*AllocCacheResponse) Descriptor() ([]byte, []int) {
return file_allocator_proto_rawDescGZIP(), []int{5}
}
func (x *AllocCacheResponse) GetIsSuccess() bool {
if x != nil {
return x.IsSuccess
}
return false
}
func (x *AllocCacheResponse) GetAddr() string {
if x != nil {
return x.Addr
}
return ""
}
func (x *AllocCacheResponse) GetPassword() string {
if x != nil {
return x.Password
}
return ""
}
func (x *AllocCacheResponse) GetDb() int32 {
if x != nil {
return x.Db
}
return 0
}
var File_allocator_proto protoreflect.FileDescriptor
var file_allocator_proto_rawDesc = []byte{
0x0a, 0x0f, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x10, 0x0a, 0x0e, 0x41, 0x6c, 0x6c, 0x6f,
0x63, 0x4d, 0x71, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x44, 0x0a, 0x0f, 0x41, 0x6c,
0x6c, 0x6f, 0x63, 0x4d, 0x71, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a,
0x0a, 0x69, 0x73, 0x5f, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28,
0x08, 0x52, 0x09, 0x69, 0x73, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04,
0x61, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x61, 0x64, 0x64, 0x72,
0x22, 0x10, 0x0a, 0x0e, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x4b, 0x76, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x22, 0x4e, 0x0a, 0x0f, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x4b, 0x76, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x73, 0x5f, 0x73, 0x75, 0x63, 0x63,
0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x53, 0x75, 0x63,
0x63, 0x65, 0x73, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74,
0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e,
0x74, 0x73, 0x32, 0x94, 0x01, 0x0a, 0x10, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72,
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x44, 0x0a, 0x11, 0x41, 0x6c, 0x6c, 0x6f, 0x63,
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x51, 0x75, 0x65, 0x75, 0x65, 0x12, 0x15, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x4d, 0x71, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x6c, 0x6c, 0x6f,
0x63, 0x4d, 0x71, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3a, 0x0a,
0x07, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x4b, 0x76, 0x12, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x2e, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x4b, 0x76, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x4b, 0x76, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x3b, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
const file_allocator_proto_rawDesc = "" +
"\n" +
"\x0fallocator.proto\x12\x05proto\"\x10\n" +
"\x0eAllocMqRequest\"D\n" +
"\x0fAllocMqResponse\x12\x1d\n" +
"\n" +
"is_success\x18\x01 \x01(\bR\tisSuccess\x12\x12\n" +
"\x04addr\x18\x02 \x01(\tR\x04addr\"\x10\n" +
"\x0eAllocKvRequest\"N\n" +
"\x0fAllocKvResponse\x12\x1d\n" +
"\n" +
"is_success\x18\x01 \x01(\bR\tisSuccess\x12\x1c\n" +
"\tendpoints\x18\x02 \x03(\tR\tendpoints\"#\n" +
"\x11AllocCacheRequest\x12\x0e\n" +
"\x02db\x18\x01 \x01(\x05R\x02db\"s\n" +
"\x12AllocCacheResponse\x12\x1d\n" +
"\n" +
"is_success\x18\x01 \x01(\bR\tisSuccess\x12\x12\n" +
"\x04addr\x18\x02 \x01(\tR\x04addr\x12\x1a\n" +
"\bpassword\x18\x03 \x01(\tR\bpassword\x12\x0e\n" +
"\x02db\x18\x04 \x01(\x05R\x02db2\xd9\x01\n" +
"\x10AllocatorService\x12D\n" +
"\x11AllocMessageQueue\x12\x15.proto.AllocMqRequest\x1a\x16.proto.AllocMqResponse\"\x00\x12:\n" +
"\aAllocKv\x12\x15.proto.AllocKvRequest\x1a\x16.proto.AllocKvResponse\"\x00\x12C\n" +
"\n" +
"AllocCache\x12\x18.proto.AllocCacheRequest\x1a\x19.proto.AllocCacheResponse\"\x00B\tZ\a.;protob\x06proto3"
var (
file_allocator_proto_rawDescOnce sync.Once
file_allocator_proto_rawDescData = file_allocator_proto_rawDesc
file_allocator_proto_rawDescData []byte
)
func file_allocator_proto_rawDescGZIP() []byte {
file_allocator_proto_rawDescOnce.Do(func() {
file_allocator_proto_rawDescData = protoimpl.X.CompressGZIP(file_allocator_proto_rawDescData)
file_allocator_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_allocator_proto_rawDesc), len(file_allocator_proto_rawDesc)))
})
return file_allocator_proto_rawDescData
}
var file_allocator_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_allocator_proto_goTypes = []interface{}{
(*AllocMqRequest)(nil), // 0: proto.AllocMqRequest
(*AllocMqResponse)(nil), // 1: proto.AllocMqResponse
(*AllocKvRequest)(nil), // 2: proto.AllocKvRequest
(*AllocKvResponse)(nil), // 3: proto.AllocKvResponse
var file_allocator_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_allocator_proto_goTypes = []any{
(*AllocMqRequest)(nil), // 0: proto.AllocMqRequest
(*AllocMqResponse)(nil), // 1: proto.AllocMqResponse
(*AllocKvRequest)(nil), // 2: proto.AllocKvRequest
(*AllocKvResponse)(nil), // 3: proto.AllocKvResponse
(*AllocCacheRequest)(nil), // 4: proto.AllocCacheRequest
(*AllocCacheResponse)(nil), // 5: proto.AllocCacheResponse
}
var file_allocator_proto_depIdxs = []int32{
0, // 0: proto.AllocatorService.AllocMessageQueue:input_type -> proto.AllocMqRequest
2, // 1: proto.AllocatorService.AllocKv:input_type -> proto.AllocKvRequest
1, // 2: proto.AllocatorService.AllocMessageQueue:output_type -> proto.AllocMqResponse
3, // 3: proto.AllocatorService.AllocKv:output_type -> proto.AllocKvResponse
2, // [2:4] is the sub-list for method output_type
0, // [0:2] is the sub-list for method input_type
4, // 2: proto.AllocatorService.AllocCache:input_type -> proto.AllocCacheRequest
1, // 3: proto.AllocatorService.AllocMessageQueue:output_type -> proto.AllocMqResponse
3, // 4: proto.AllocatorService.AllocKv:output_type -> proto.AllocKvResponse
5, // 5: proto.AllocatorService.AllocCache:output_type -> proto.AllocCacheResponse
3, // [3:6] is the sub-list for method output_type
0, // [0:3] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
@@ -271,63 +378,13 @@ func file_allocator_proto_init() {
if File_allocator_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_allocator_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AllocMqRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_allocator_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AllocMqResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_allocator_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AllocKvRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_allocator_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AllocKvResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_allocator_proto_rawDesc,
RawDescriptor: unsafe.Slice(unsafe.StringData(file_allocator_proto_rawDesc), len(file_allocator_proto_rawDesc)),
NumEnums: 0,
NumMessages: 4,
NumMessages: 6,
NumExtensions: 0,
NumServices: 1,
},
@@ -336,7 +393,6 @@ func file_allocator_proto_init() {
MessageInfos: file_allocator_proto_msgTypes,
}.Build()
File_allocator_proto = out.File
file_allocator_proto_rawDesc = nil
file_allocator_proto_goTypes = nil
file_allocator_proto_depIdxs = nil
}

View File

@@ -7,6 +7,7 @@ package proto;
service AllocatorService {
rpc AllocMessageQueue(AllocMqRequest) returns (AllocMqResponse) {}
rpc AllocKv(AllocKvRequest) returns (AllocKvResponse) {}
rpc AllocCache(AllocCacheRequest) returns (AllocCacheResponse) {}
}
message AllocMqRequest {
@@ -24,3 +25,14 @@ message AllocKvResponse {
bool is_success = 1;
repeated string endpoints = 2;
}
message AllocCacheRequest {
int32 db = 1;
}
message AllocCacheResponse {
bool is_success = 1;
string addr = 2;
string password = 3;
int32 db = 4;
}

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v5.28.2
// - protoc-gen-go-grpc v1.5.1
// - protoc v5.29.3
// source: allocator.proto
package proto
@@ -15,8 +15,14 @@ import (
// 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.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
AllocatorService_AllocMessageQueue_FullMethodName = "/proto.AllocatorService/AllocMessageQueue"
AllocatorService_AllocKv_FullMethodName = "/proto.AllocatorService/AllocKv"
AllocatorService_AllocCache_FullMethodName = "/proto.AllocatorService/AllocCache"
)
// AllocatorServiceClient is the client API for AllocatorService service.
//
@@ -24,6 +30,7 @@ const _ = grpc.SupportPackageIsVersion7
type AllocatorServiceClient interface {
AllocMessageQueue(ctx context.Context, in *AllocMqRequest, opts ...grpc.CallOption) (*AllocMqResponse, error)
AllocKv(ctx context.Context, in *AllocKvRequest, opts ...grpc.CallOption) (*AllocKvResponse, error)
AllocCache(ctx context.Context, in *AllocCacheRequest, opts ...grpc.CallOption) (*AllocCacheResponse, error)
}
type allocatorServiceClient struct {
@@ -35,8 +42,9 @@ func NewAllocatorServiceClient(cc grpc.ClientConnInterface) AllocatorServiceClie
}
func (c *allocatorServiceClient) AllocMessageQueue(ctx context.Context, in *AllocMqRequest, opts ...grpc.CallOption) (*AllocMqResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(AllocMqResponse)
err := c.cc.Invoke(ctx, "/proto.AllocatorService/AllocMessageQueue", in, out, opts...)
err := c.cc.Invoke(ctx, AllocatorService_AllocMessageQueue_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -44,8 +52,19 @@ func (c *allocatorServiceClient) AllocMessageQueue(ctx context.Context, in *Allo
}
func (c *allocatorServiceClient) AllocKv(ctx context.Context, in *AllocKvRequest, opts ...grpc.CallOption) (*AllocKvResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(AllocKvResponse)
err := c.cc.Invoke(ctx, "/proto.AllocatorService/AllocKv", in, out, opts...)
err := c.cc.Invoke(ctx, AllocatorService_AllocKv_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *allocatorServiceClient) AllocCache(ctx context.Context, in *AllocCacheRequest, opts ...grpc.CallOption) (*AllocCacheResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(AllocCacheResponse)
err := c.cc.Invoke(ctx, AllocatorService_AllocCache_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -54,16 +73,20 @@ func (c *allocatorServiceClient) AllocKv(ctx context.Context, in *AllocKvRequest
// AllocatorServiceServer is the server API for AllocatorService service.
// All implementations must embed UnimplementedAllocatorServiceServer
// for forward compatibility
// for forward compatibility.
type AllocatorServiceServer interface {
AllocMessageQueue(context.Context, *AllocMqRequest) (*AllocMqResponse, error)
AllocKv(context.Context, *AllocKvRequest) (*AllocKvResponse, error)
AllocCache(context.Context, *AllocCacheRequest) (*AllocCacheResponse, error)
mustEmbedUnimplementedAllocatorServiceServer()
}
// UnimplementedAllocatorServiceServer must be embedded to have forward compatible implementations.
type UnimplementedAllocatorServiceServer struct {
}
// UnimplementedAllocatorServiceServer 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 UnimplementedAllocatorServiceServer struct{}
func (UnimplementedAllocatorServiceServer) AllocMessageQueue(context.Context, *AllocMqRequest) (*AllocMqResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method AllocMessageQueue not implemented")
@@ -71,7 +94,11 @@ func (UnimplementedAllocatorServiceServer) AllocMessageQueue(context.Context, *A
func (UnimplementedAllocatorServiceServer) AllocKv(context.Context, *AllocKvRequest) (*AllocKvResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method AllocKv not implemented")
}
func (UnimplementedAllocatorServiceServer) AllocCache(context.Context, *AllocCacheRequest) (*AllocCacheResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method AllocCache not implemented")
}
func (UnimplementedAllocatorServiceServer) mustEmbedUnimplementedAllocatorServiceServer() {}
func (UnimplementedAllocatorServiceServer) testEmbeddedByValue() {}
// UnsafeAllocatorServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to AllocatorServiceServer will
@@ -81,6 +108,13 @@ type UnsafeAllocatorServiceServer interface {
}
func RegisterAllocatorServiceServer(s grpc.ServiceRegistrar, srv AllocatorServiceServer) {
// If the following call pancis, it indicates UnimplementedAllocatorServiceServer 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(&AllocatorService_ServiceDesc, srv)
}
@@ -94,7 +128,7 @@ func _AllocatorService_AllocMessageQueue_Handler(srv interface{}, ctx context.Co
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.AllocatorService/AllocMessageQueue",
FullMethod: AllocatorService_AllocMessageQueue_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AllocatorServiceServer).AllocMessageQueue(ctx, req.(*AllocMqRequest))
@@ -112,7 +146,7 @@ func _AllocatorService_AllocKv_Handler(srv interface{}, ctx context.Context, dec
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.AllocatorService/AllocKv",
FullMethod: AllocatorService_AllocKv_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AllocatorServiceServer).AllocKv(ctx, req.(*AllocKvRequest))
@@ -120,6 +154,24 @@ func _AllocatorService_AllocKv_Handler(srv interface{}, ctx context.Context, dec
return interceptor(ctx, in, info, handler)
}
func _AllocatorService_AllocCache_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AllocCacheRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AllocatorServiceServer).AllocCache(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AllocatorService_AllocCache_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AllocatorServiceServer).AllocCache(ctx, req.(*AllocCacheRequest))
}
return interceptor(ctx, in, info, handler)
}
// AllocatorService_ServiceDesc is the grpc.ServiceDesc for AllocatorService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@@ -135,6 +187,10 @@ var AllocatorService_ServiceDesc = grpc.ServiceDesc{
MethodName: "AllocKv",
Handler: _AllocatorService_AllocKv_Handler,
},
{
MethodName: "AllocCache",
Handler: _AllocatorService_AllocCache_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "allocator.proto",

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc v5.28.2
// protoc-gen-go v1.36.6
// protoc v5.29.3
// source: authenticate.proto
package proto
@@ -11,6 +11,7 @@ import (
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
@@ -21,21 +22,18 @@ const (
)
type AuthInfo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
Info *UserInfo `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"`
SessionId uint64 `protobuf:"varint,3,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"`
unknownFields protoimpl.UnknownFields
Info *UserInfo `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"`
SessionId uint64 `protobuf:"varint,3,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *AuthInfo) Reset() {
*x = AuthInfo{}
if protoimpl.UnsafeEnabled {
mi := &file_authenticate_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_authenticate_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AuthInfo) String() string {
@@ -46,7 +44,7 @@ func (*AuthInfo) ProtoMessage() {}
func (x *AuthInfo) ProtoReflect() protoreflect.Message {
mi := &file_authenticate_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -76,20 +74,17 @@ func (x *AuthInfo) GetSessionId() uint64 {
}
type AuthRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
SessionId uint64 `protobuf:"varint,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"`
unknownFields protoimpl.UnknownFields
SessionId uint64 `protobuf:"varint,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *AuthRequest) Reset() {
*x = AuthRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_authenticate_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_authenticate_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AuthRequest) String() string {
@@ -100,7 +95,7 @@ func (*AuthRequest) ProtoMessage() {}
func (x *AuthRequest) ProtoReflect() protoreflect.Message {
mi := &file_authenticate_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -123,21 +118,18 @@ func (x *AuthRequest) GetSessionId() uint64 {
}
type AuthReply struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
IsValid bool `protobuf:"varint,1,opt,name=is_valid,json=isValid,proto3" json:"is_valid,omitempty"`
Info *AuthInfo `protobuf:"bytes,2,opt,name=info,proto3,oneof" json:"info,omitempty"`
unknownFields protoimpl.UnknownFields
IsValid bool `protobuf:"varint,1,opt,name=is_valid,json=isValid,proto3" json:"is_valid,omitempty"`
Info *AuthInfo `protobuf:"bytes,2,opt,name=info,proto3,oneof" json:"info,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *AuthReply) Reset() {
*x = AuthReply{}
if protoimpl.UnsafeEnabled {
mi := &file_authenticate_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_authenticate_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AuthReply) String() string {
@@ -148,7 +140,7 @@ func (*AuthReply) ProtoMessage() {}
func (x *AuthReply) ProtoReflect() protoreflect.Message {
mi := &file_authenticate_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -178,22 +170,19 @@ func (x *AuthReply) GetInfo() *AuthInfo {
}
type CheckPermRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
SessionId uint64 `protobuf:"varint,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"`
Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
Value []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"`
unknownFields protoimpl.UnknownFields
SessionId uint64 `protobuf:"varint,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"`
Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
Value []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *CheckPermRequest) Reset() {
*x = CheckPermRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_authenticate_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_authenticate_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CheckPermRequest) String() string {
@@ -204,7 +193,7 @@ func (*CheckPermRequest) ProtoMessage() {}
func (x *CheckPermRequest) ProtoReflect() protoreflect.Message {
mi := &file_authenticate_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -241,20 +230,17 @@ func (x *CheckPermRequest) GetValue() []byte {
}
type CheckPermResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
IsValid bool `protobuf:"varint,1,opt,name=is_valid,json=isValid,proto3" json:"is_valid,omitempty"`
unknownFields protoimpl.UnknownFields
IsValid bool `protobuf:"varint,1,opt,name=is_valid,json=isValid,proto3" json:"is_valid,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *CheckPermResponse) Reset() {
*x = CheckPermResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_authenticate_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_authenticate_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CheckPermResponse) String() string {
@@ -265,7 +251,7 @@ func (*CheckPermResponse) ProtoMessage() {}
func (x *CheckPermResponse) ProtoReflect() protoreflect.Message {
mi := &file_authenticate_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -288,23 +274,20 @@ func (x *CheckPermResponse) GetIsValid() bool {
}
type CheckUserPermRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
UserId uint64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
OtherId uint64 `protobuf:"varint,2,opt,name=other_id,json=otherId,proto3" json:"other_id,omitempty"`
Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"`
Value []byte `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"`
unknownFields protoimpl.UnknownFields
UserId uint64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
OtherId uint64 `protobuf:"varint,2,opt,name=other_id,json=otherId,proto3" json:"other_id,omitempty"`
Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"`
Value []byte `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *CheckUserPermRequest) Reset() {
*x = CheckUserPermRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_authenticate_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_authenticate_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CheckUserPermRequest) String() string {
@@ -315,7 +298,7 @@ func (*CheckUserPermRequest) ProtoMessage() {}
func (x *CheckUserPermRequest) ProtoReflect() protoreflect.Message {
mi := &file_authenticate_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -359,20 +342,17 @@ func (x *CheckUserPermRequest) GetValue() []byte {
}
type CheckUserPermResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
IsValid bool `protobuf:"varint,1,opt,name=is_valid,json=isValid,proto3" json:"is_valid,omitempty"`
unknownFields protoimpl.UnknownFields
IsValid bool `protobuf:"varint,1,opt,name=is_valid,json=isValid,proto3" json:"is_valid,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *CheckUserPermResponse) Reset() {
*x = CheckUserPermResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_authenticate_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_authenticate_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CheckUserPermResponse) String() string {
@@ -383,7 +363,7 @@ func (*CheckUserPermResponse) ProtoMessage() {}
func (x *CheckUserPermResponse) ProtoReflect() protoreflect.Message {
mi := &file_authenticate_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -407,74 +387,54 @@ func (x *CheckUserPermResponse) GetIsValid() bool {
var File_authenticate_proto protoreflect.FileDescriptor
var file_authenticate_proto_rawDesc = []byte{
0x0a, 0x12, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0a, 0x75, 0x73, 0x65,
0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x4e, 0x0a, 0x08, 0x41, 0x75, 0x74, 0x68, 0x49,
0x6e, 0x66, 0x6f, 0x12, 0x23, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e,
0x66, 0x6f, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x73, 0x73,
0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x73, 0x65,
0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x2c, 0x0a, 0x0b, 0x41, 0x75, 0x74, 0x68, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f,
0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x73, 0x65, 0x73, 0x73,
0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x59, 0x0a, 0x09, 0x41, 0x75, 0x74, 0x68, 0x52, 0x65, 0x70,
0x6c, 0x79, 0x12, 0x19, 0x0a, 0x08, 0x69, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x01,
0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x12, 0x28, 0x0a,
0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x48, 0x00, 0x52, 0x04,
0x69, 0x6e, 0x66, 0x6f, 0x88, 0x01, 0x01, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x69, 0x6e, 0x66, 0x6f,
0x22, 0x59, 0x0a, 0x10, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x65, 0x72, 0x6d, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f,
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f,
0x6e, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03,
0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x2e, 0x0a, 0x11, 0x43,
0x68, 0x65, 0x63, 0x6b, 0x50, 0x65, 0x72, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x19, 0x0a, 0x08, 0x69, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x22, 0x72, 0x0a, 0x14, 0x43,
0x68, 0x65, 0x63, 0x6b, 0x55, 0x73, 0x65, 0x72, 0x50, 0x65, 0x72, 0x6d, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01,
0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08,
0x6f, 0x74, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07,
0x6f, 0x74, 0x68, 0x65, 0x72, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x03,
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c,
0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22,
0x32, 0x0a, 0x15, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x55, 0x73, 0x65, 0x72, 0x50, 0x65, 0x72, 0x6d,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x69, 0x73, 0x5f, 0x76,
0x61, 0x6c, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x56, 0x61,
0x6c, 0x69, 0x64, 0x32, 0xe5, 0x01, 0x0a, 0x0b, 0x41, 0x75, 0x74, 0x68, 0x53, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x12, 0x36, 0x0a, 0x0c, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63,
0x61, 0x74, 0x65, 0x12, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x75, 0x74, 0x68,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
0x41, 0x75, 0x74, 0x68, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x48, 0x0a, 0x11, 0x45,
0x6e, 0x73, 0x75, 0x72, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x64,
0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x65,
0x72, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x65, 0x72, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x54, 0x0a, 0x15, 0x45, 0x6e, 0x73, 0x75, 0x72, 0x65, 0x55,
0x73, 0x65, 0x72, 0x50, 0x65, 0x72, 0x6d, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x64, 0x12, 0x1b,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x55, 0x73, 0x65, 0x72,
0x50, 0x65, 0x72, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x55, 0x73, 0x65, 0x72, 0x50, 0x65, 0x72,
0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x09, 0x5a, 0x07, 0x2e,
0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
const file_authenticate_proto_rawDesc = "" +
"\n" +
"\x12authenticate.proto\x12\x05proto\x1a\n" +
"user.proto\"N\n" +
"\bAuthInfo\x12#\n" +
"\x04info\x18\x01 \x01(\v2\x0f.proto.UserInfoR\x04info\x12\x1d\n" +
"\n" +
"session_id\x18\x03 \x01(\x04R\tsessionId\",\n" +
"\vAuthRequest\x12\x1d\n" +
"\n" +
"session_id\x18\x01 \x01(\x04R\tsessionId\"Y\n" +
"\tAuthReply\x12\x19\n" +
"\bis_valid\x18\x01 \x01(\bR\aisValid\x12(\n" +
"\x04info\x18\x02 \x01(\v2\x0f.proto.AuthInfoH\x00R\x04info\x88\x01\x01B\a\n" +
"\x05_info\"Y\n" +
"\x10CheckPermRequest\x12\x1d\n" +
"\n" +
"session_id\x18\x01 \x01(\x04R\tsessionId\x12\x10\n" +
"\x03key\x18\x02 \x01(\tR\x03key\x12\x14\n" +
"\x05value\x18\x03 \x01(\fR\x05value\".\n" +
"\x11CheckPermResponse\x12\x19\n" +
"\bis_valid\x18\x01 \x01(\bR\aisValid\"r\n" +
"\x14CheckUserPermRequest\x12\x17\n" +
"\auser_id\x18\x01 \x01(\x04R\x06userId\x12\x19\n" +
"\bother_id\x18\x02 \x01(\x04R\aotherId\x12\x10\n" +
"\x03key\x18\x03 \x01(\tR\x03key\x12\x14\n" +
"\x05value\x18\x04 \x01(\fR\x05value\"2\n" +
"\x15CheckUserPermResponse\x12\x19\n" +
"\bis_valid\x18\x01 \x01(\bR\aisValid2\xe5\x01\n" +
"\vAuthService\x126\n" +
"\fAuthenticate\x12\x12.proto.AuthRequest\x1a\x10.proto.AuthReply\"\x00\x12H\n" +
"\x11EnsurePermGranted\x12\x17.proto.CheckPermRequest\x1a\x18.proto.CheckPermResponse\"\x00\x12T\n" +
"\x15EnsureUserPermGranted\x12\x1b.proto.CheckUserPermRequest\x1a\x1c.proto.CheckUserPermResponse\"\x00B\tZ\a.;protob\x06proto3"
var (
file_authenticate_proto_rawDescOnce sync.Once
file_authenticate_proto_rawDescData = file_authenticate_proto_rawDesc
file_authenticate_proto_rawDescData []byte
)
func file_authenticate_proto_rawDescGZIP() []byte {
file_authenticate_proto_rawDescOnce.Do(func() {
file_authenticate_proto_rawDescData = protoimpl.X.CompressGZIP(file_authenticate_proto_rawDescData)
file_authenticate_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_authenticate_proto_rawDesc), len(file_authenticate_proto_rawDesc)))
})
return file_authenticate_proto_rawDescData
}
var file_authenticate_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_authenticate_proto_goTypes = []interface{}{
var file_authenticate_proto_goTypes = []any{
(*AuthInfo)(nil), // 0: proto.AuthInfo
(*AuthRequest)(nil), // 1: proto.AuthRequest
(*AuthReply)(nil), // 2: proto.AuthReply
@@ -506,98 +466,12 @@ func file_authenticate_proto_init() {
return
}
file_user_proto_init()
if !protoimpl.UnsafeEnabled {
file_authenticate_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AuthInfo); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_authenticate_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AuthRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_authenticate_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AuthReply); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_authenticate_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CheckPermRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_authenticate_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CheckPermResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_authenticate_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CheckUserPermRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_authenticate_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CheckUserPermResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
file_authenticate_proto_msgTypes[2].OneofWrappers = []interface{}{}
file_authenticate_proto_msgTypes[2].OneofWrappers = []any{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_authenticate_proto_rawDesc,
RawDescriptor: unsafe.Slice(unsafe.StringData(file_authenticate_proto_rawDesc), len(file_authenticate_proto_rawDesc)),
NumEnums: 0,
NumMessages: 7,
NumExtensions: 0,
@@ -608,7 +482,6 @@ func file_authenticate_proto_init() {
MessageInfos: file_authenticate_proto_msgTypes,
}.Build()
File_authenticate_proto = out.File
file_authenticate_proto_rawDesc = nil
file_authenticate_proto_goTypes = nil
file_authenticate_proto_depIdxs = nil
}

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v5.28.2
// - protoc-gen-go-grpc v1.5.1
// - protoc v5.29.3
// source: authenticate.proto
package proto
@@ -15,8 +15,14 @@ import (
// 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.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
AuthService_Authenticate_FullMethodName = "/proto.AuthService/Authenticate"
AuthService_EnsurePermGranted_FullMethodName = "/proto.AuthService/EnsurePermGranted"
AuthService_EnsureUserPermGranted_FullMethodName = "/proto.AuthService/EnsureUserPermGranted"
)
// AuthServiceClient is the client API for AuthService service.
//
@@ -36,8 +42,9 @@ func NewAuthServiceClient(cc grpc.ClientConnInterface) AuthServiceClient {
}
func (c *authServiceClient) Authenticate(ctx context.Context, in *AuthRequest, opts ...grpc.CallOption) (*AuthReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(AuthReply)
err := c.cc.Invoke(ctx, "/proto.AuthService/Authenticate", in, out, opts...)
err := c.cc.Invoke(ctx, AuthService_Authenticate_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -45,8 +52,9 @@ func (c *authServiceClient) Authenticate(ctx context.Context, in *AuthRequest, o
}
func (c *authServiceClient) EnsurePermGranted(ctx context.Context, in *CheckPermRequest, opts ...grpc.CallOption) (*CheckPermResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CheckPermResponse)
err := c.cc.Invoke(ctx, "/proto.AuthService/EnsurePermGranted", in, out, opts...)
err := c.cc.Invoke(ctx, AuthService_EnsurePermGranted_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -54,8 +62,9 @@ func (c *authServiceClient) EnsurePermGranted(ctx context.Context, in *CheckPerm
}
func (c *authServiceClient) EnsureUserPermGranted(ctx context.Context, in *CheckUserPermRequest, opts ...grpc.CallOption) (*CheckUserPermResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CheckUserPermResponse)
err := c.cc.Invoke(ctx, "/proto.AuthService/EnsureUserPermGranted", in, out, opts...)
err := c.cc.Invoke(ctx, AuthService_EnsureUserPermGranted_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -64,7 +73,7 @@ func (c *authServiceClient) EnsureUserPermGranted(ctx context.Context, in *Check
// AuthServiceServer is the server API for AuthService service.
// All implementations must embed UnimplementedAuthServiceServer
// for forward compatibility
// for forward compatibility.
type AuthServiceServer interface {
Authenticate(context.Context, *AuthRequest) (*AuthReply, error)
EnsurePermGranted(context.Context, *CheckPermRequest) (*CheckPermResponse, error)
@@ -72,9 +81,12 @@ type AuthServiceServer interface {
mustEmbedUnimplementedAuthServiceServer()
}
// UnimplementedAuthServiceServer must be embedded to have forward compatible implementations.
type UnimplementedAuthServiceServer struct {
}
// 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) Authenticate(context.Context, *AuthRequest) (*AuthReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Authenticate not implemented")
@@ -86,6 +98,7 @@ func (UnimplementedAuthServiceServer) EnsureUserPermGranted(context.Context, *Ch
return nil, status.Errorf(codes.Unimplemented, "method EnsureUserPermGranted 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
@@ -95,6 +108,13 @@ type UnsafeAuthServiceServer interface {
}
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)
}
@@ -108,7 +128,7 @@ func _AuthService_Authenticate_Handler(srv interface{}, ctx context.Context, dec
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.AuthService/Authenticate",
FullMethod: AuthService_Authenticate_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthServiceServer).Authenticate(ctx, req.(*AuthRequest))
@@ -126,7 +146,7 @@ func _AuthService_EnsurePermGranted_Handler(srv interface{}, ctx context.Context
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.AuthService/EnsurePermGranted",
FullMethod: AuthService_EnsurePermGranted_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthServiceServer).EnsurePermGranted(ctx, req.(*CheckPermRequest))
@@ -144,7 +164,7 @@ func _AuthService_EnsureUserPermGranted_Handler(srv interface{}, ctx context.Con
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.AuthService/EnsureUserPermGranted",
FullMethod: AuthService_EnsureUserPermGranted_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthServiceServer).EnsureUserPermGranted(ctx, req.(*CheckUserPermRequest))

182
pkg/proto/captcha.pb.go Normal file
View File

@@ -0,0 +1,182 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.6
// protoc v5.29.3
// source: captcha.proto
package proto
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 CheckCaptchaRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
RemoteIp string `protobuf:"bytes,2,opt,name=remote_ip,json=remoteIp,proto3" json:"remote_ip,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *CheckCaptchaRequest) Reset() {
*x = CheckCaptchaRequest{}
mi := &file_captcha_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CheckCaptchaRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CheckCaptchaRequest) ProtoMessage() {}
func (x *CheckCaptchaRequest) ProtoReflect() protoreflect.Message {
mi := &file_captcha_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 CheckCaptchaRequest.ProtoReflect.Descriptor instead.
func (*CheckCaptchaRequest) Descriptor() ([]byte, []int) {
return file_captcha_proto_rawDescGZIP(), []int{0}
}
func (x *CheckCaptchaRequest) GetToken() string {
if x != nil {
return x.Token
}
return ""
}
func (x *CheckCaptchaRequest) GetRemoteIp() string {
if x != nil {
return x.RemoteIp
}
return ""
}
type CheckCaptchaResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
IsValid bool `protobuf:"varint,1,opt,name=is_valid,json=isValid,proto3" json:"is_valid,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *CheckCaptchaResponse) Reset() {
*x = CheckCaptchaResponse{}
mi := &file_captcha_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CheckCaptchaResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CheckCaptchaResponse) ProtoMessage() {}
func (x *CheckCaptchaResponse) ProtoReflect() protoreflect.Message {
mi := &file_captcha_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 CheckCaptchaResponse.ProtoReflect.Descriptor instead.
func (*CheckCaptchaResponse) Descriptor() ([]byte, []int) {
return file_captcha_proto_rawDescGZIP(), []int{1}
}
func (x *CheckCaptchaResponse) GetIsValid() bool {
if x != nil {
return x.IsValid
}
return false
}
var File_captcha_proto protoreflect.FileDescriptor
const file_captcha_proto_rawDesc = "" +
"\n" +
"\rcaptcha.proto\x12\x05proto\"H\n" +
"\x13CheckCaptchaRequest\x12\x14\n" +
"\x05token\x18\x01 \x01(\tR\x05token\x12\x1b\n" +
"\tremote_ip\x18\x02 \x01(\tR\bremoteIp\"1\n" +
"\x14CheckCaptchaResponse\x12\x19\n" +
"\bis_valid\x18\x01 \x01(\bR\aisValid2[\n" +
"\x0eCaptchaService\x12I\n" +
"\fCheckCaptcha\x12\x1a.proto.CheckCaptchaRequest\x1a\x1b.proto.CheckCaptchaResponse\"\x00B\tZ\a.;protob\x06proto3"
var (
file_captcha_proto_rawDescOnce sync.Once
file_captcha_proto_rawDescData []byte
)
func file_captcha_proto_rawDescGZIP() []byte {
file_captcha_proto_rawDescOnce.Do(func() {
file_captcha_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_captcha_proto_rawDesc), len(file_captcha_proto_rawDesc)))
})
return file_captcha_proto_rawDescData
}
var file_captcha_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_captcha_proto_goTypes = []any{
(*CheckCaptchaRequest)(nil), // 0: proto.CheckCaptchaRequest
(*CheckCaptchaResponse)(nil), // 1: proto.CheckCaptchaResponse
}
var file_captcha_proto_depIdxs = []int32{
0, // 0: proto.CaptchaService.CheckCaptcha:input_type -> proto.CheckCaptchaRequest
1, // 1: proto.CaptchaService.CheckCaptcha:output_type -> proto.CheckCaptchaResponse
1, // [1:2] is the sub-list for method output_type
0, // [0:1] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_captcha_proto_init() }
func file_captcha_proto_init() {
if File_captcha_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_captcha_proto_rawDesc), len(file_captcha_proto_rawDesc)),
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_captcha_proto_goTypes,
DependencyIndexes: file_captcha_proto_depIdxs,
MessageInfos: file_captcha_proto_msgTypes,
}.Build()
File_captcha_proto = out.File
file_captcha_proto_goTypes = nil
file_captcha_proto_depIdxs = nil
}

18
pkg/proto/captcha.proto Normal file
View File

@@ -0,0 +1,18 @@
syntax = "proto3";
option go_package = ".;proto";
package proto;
service CaptchaService {
rpc CheckCaptcha(CheckCaptchaRequest) returns (CheckCaptchaResponse) {}
}
message CheckCaptchaRequest {
string token = 1;
string remote_ip = 2;
}
message CheckCaptchaResponse {
bool is_valid = 1;
}

View File

@@ -0,0 +1,121 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v5.29.3
// source: captcha.proto
package proto
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 (
CaptchaService_CheckCaptcha_FullMethodName = "/proto.CaptchaService/CheckCaptcha"
)
// CaptchaServiceClient is the client API for CaptchaService 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 CaptchaServiceClient interface {
CheckCaptcha(ctx context.Context, in *CheckCaptchaRequest, opts ...grpc.CallOption) (*CheckCaptchaResponse, error)
}
type captchaServiceClient struct {
cc grpc.ClientConnInterface
}
func NewCaptchaServiceClient(cc grpc.ClientConnInterface) CaptchaServiceClient {
return &captchaServiceClient{cc}
}
func (c *captchaServiceClient) CheckCaptcha(ctx context.Context, in *CheckCaptchaRequest, opts ...grpc.CallOption) (*CheckCaptchaResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CheckCaptchaResponse)
err := c.cc.Invoke(ctx, CaptchaService_CheckCaptcha_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// CaptchaServiceServer is the server API for CaptchaService service.
// All implementations must embed UnimplementedCaptchaServiceServer
// for forward compatibility.
type CaptchaServiceServer interface {
CheckCaptcha(context.Context, *CheckCaptchaRequest) (*CheckCaptchaResponse, error)
mustEmbedUnimplementedCaptchaServiceServer()
}
// UnimplementedCaptchaServiceServer 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 UnimplementedCaptchaServiceServer struct{}
func (UnimplementedCaptchaServiceServer) CheckCaptcha(context.Context, *CheckCaptchaRequest) (*CheckCaptchaResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CheckCaptcha not implemented")
}
func (UnimplementedCaptchaServiceServer) mustEmbedUnimplementedCaptchaServiceServer() {}
func (UnimplementedCaptchaServiceServer) testEmbeddedByValue() {}
// UnsafeCaptchaServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to CaptchaServiceServer will
// result in compilation errors.
type UnsafeCaptchaServiceServer interface {
mustEmbedUnimplementedCaptchaServiceServer()
}
func RegisterCaptchaServiceServer(s grpc.ServiceRegistrar, srv CaptchaServiceServer) {
// If the following call pancis, it indicates UnimplementedCaptchaServiceServer 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(&CaptchaService_ServiceDesc, srv)
}
func _CaptchaService_CheckCaptcha_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CheckCaptchaRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CaptchaServiceServer).CheckCaptcha(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: CaptchaService_CheckCaptcha_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CaptchaServiceServer).CheckCaptcha(ctx, req.(*CheckCaptchaRequest))
}
return interceptor(ctx, in, info, handler)
}
// CaptchaService_ServiceDesc is the grpc.ServiceDesc for CaptchaService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var CaptchaService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "proto.CaptchaService",
HandlerType: (*CaptchaServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "CheckCaptcha",
Handler: _CaptchaService_CheckCaptcha_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "captcha.proto",
}

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc v5.28.2
// protoc-gen-go v1.36.6
// protoc v5.29.3
// source: command.proto
package proto
@@ -11,6 +11,7 @@ import (
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
@@ -21,22 +22,19 @@ const (
)
type CommandInfo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Method string `protobuf:"bytes,2,opt,name=method,proto3" json:"method,omitempty"`
Tags []string `protobuf:"bytes,3,rep,name=tags,proto3" json:"tags,omitempty"`
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Method string `protobuf:"bytes,2,opt,name=method,proto3" json:"method,omitempty"`
Tags []string `protobuf:"bytes,3,rep,name=tags,proto3" json:"tags,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *CommandInfo) Reset() {
*x = CommandInfo{}
if protoimpl.UnsafeEnabled {
mi := &file_command_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_command_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CommandInfo) String() string {
@@ -47,7 +45,7 @@ func (*CommandInfo) ProtoMessage() {}
func (x *CommandInfo) ProtoReflect() protoreflect.Message {
mi := &file_command_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -84,21 +82,18 @@ func (x *CommandInfo) GetTags() []string {
}
type CommandLookupRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Method string `protobuf:"bytes,2,opt,name=method,proto3" json:"method,omitempty"`
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Method string `protobuf:"bytes,2,opt,name=method,proto3" json:"method,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *CommandLookupRequest) Reset() {
*x = CommandLookupRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_command_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_command_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CommandLookupRequest) String() string {
@@ -109,7 +104,7 @@ func (*CommandLookupRequest) ProtoMessage() {}
func (x *CommandLookupRequest) ProtoReflect() protoreflect.Message {
mi := &file_command_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -139,20 +134,17 @@ func (x *CommandLookupRequest) GetMethod() string {
}
type AddCommandResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
IsSuccess bool `protobuf:"varint,1,opt,name=is_success,json=isSuccess,proto3" json:"is_success,omitempty"`
unknownFields protoimpl.UnknownFields
IsSuccess bool `protobuf:"varint,1,opt,name=is_success,json=isSuccess,proto3" json:"is_success,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *AddCommandResponse) Reset() {
*x = AddCommandResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_command_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_command_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AddCommandResponse) String() string {
@@ -163,7 +155,7 @@ func (*AddCommandResponse) ProtoMessage() {}
func (x *AddCommandResponse) ProtoReflect() protoreflect.Message {
mi := &file_command_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -186,20 +178,17 @@ func (x *AddCommandResponse) GetIsSuccess() bool {
}
type RemoveCommandResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
IsSuccess bool `protobuf:"varint,1,opt,name=is_success,json=isSuccess,proto3" json:"is_success,omitempty"`
unknownFields protoimpl.UnknownFields
IsSuccess bool `protobuf:"varint,1,opt,name=is_success,json=isSuccess,proto3" json:"is_success,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *RemoveCommandResponse) Reset() {
*x = RemoveCommandResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_command_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_command_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *RemoveCommandResponse) String() string {
@@ -210,7 +199,7 @@ func (*RemoveCommandResponse) ProtoMessage() {}
func (x *RemoveCommandResponse) ProtoReflect() protoreflect.Message {
mi := &file_command_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -233,22 +222,19 @@ func (x *RemoveCommandResponse) GetIsSuccess() bool {
}
type CommandArgument struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
Command string `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"`
Method string `protobuf:"bytes,2,opt,name=method,proto3" json:"method,omitempty"`
Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3,oneof" json:"payload,omitempty"`
unknownFields protoimpl.UnknownFields
Command string `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"`
Method string `protobuf:"bytes,2,opt,name=method,proto3" json:"method,omitempty"`
Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3,oneof" json:"payload,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *CommandArgument) Reset() {
*x = CommandArgument{}
if protoimpl.UnsafeEnabled {
mi := &file_command_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_command_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CommandArgument) String() string {
@@ -259,7 +245,7 @@ func (*CommandArgument) ProtoMessage() {}
func (x *CommandArgument) ProtoReflect() protoreflect.Message {
mi := &file_command_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -296,23 +282,20 @@ func (x *CommandArgument) GetPayload() []byte {
}
type CommandReturn struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
IsDelivered bool `protobuf:"varint,1,opt,name=is_delivered,json=isDelivered,proto3" json:"is_delivered,omitempty"`
Status int32 `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"`
ContentType string `protobuf:"bytes,3,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"`
Payload []byte `protobuf:"bytes,4,opt,name=payload,proto3,oneof" json:"payload,omitempty"`
unknownFields protoimpl.UnknownFields
IsDelivered bool `protobuf:"varint,1,opt,name=is_delivered,json=isDelivered,proto3" json:"is_delivered,omitempty"`
Status int32 `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"`
ContentType string `protobuf:"bytes,3,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"`
Payload []byte `protobuf:"bytes,4,opt,name=payload,proto3,oneof" json:"payload,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *CommandReturn) Reset() {
*x = CommandReturn{}
if protoimpl.UnsafeEnabled {
mi := &file_command_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_command_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CommandReturn) String() string {
@@ -323,7 +306,7 @@ func (*CommandReturn) ProtoMessage() {}
func (x *CommandReturn) ProtoReflect() protoreflect.Message {
mi := &file_command_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -368,77 +351,56 @@ func (x *CommandReturn) GetPayload() []byte {
var File_command_proto protoreflect.FileDescriptor
var file_command_proto_rawDesc = []byte{
0x0a, 0x0d, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x49, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e,
0x64, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a,
0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x61, 0x67,
0x73, 0x22, 0x3e, 0x0a, 0x14, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x4c, 0x6f, 0x6f, 0x6b,
0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74,
0x68, 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f,
0x64, 0x22, 0x33, 0x0a, 0x12, 0x41, 0x64, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x73, 0x5f, 0x73, 0x75,
0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x53,
0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x22, 0x36, 0x0a, 0x15, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65,
0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x1d, 0x0a, 0x0a, 0x69, 0x73, 0x5f, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20,
0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x22, 0x6e,
0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x41, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e,
0x74, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6d,
0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74,
0x68, 0x6f, 0x64, 0x12, 0x1d, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x03,
0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x88,
0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x98,
0x01, 0x0a, 0x0d, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e,
0x12, 0x21, 0x0a, 0x0c, 0x69, 0x73, 0x5f, 0x64, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x65, 0x64,
0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65,
0x72, 0x65, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20,
0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x63,
0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28,
0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1d,
0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x48,
0x00, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a,
0x08, 0x5f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x32, 0xa6, 0x02, 0x0a, 0x0f, 0x43, 0x6f,
0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x3d, 0x0a,
0x0a, 0x41, 0x64, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x12, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x1a,
0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61,
0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4c, 0x0a, 0x0d,
0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x1b, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x4c, 0x6f, 0x6f,
0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3d, 0x0a, 0x0b, 0x53, 0x65,
0x6e, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x41, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e,
0x74, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e,
0x64, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x22, 0x00, 0x12, 0x47, 0x0a, 0x11, 0x53, 0x65, 0x6e,
0x64, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x16,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x41, 0x72,
0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43,
0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x22, 0x00, 0x28, 0x01,
0x30, 0x01, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
const file_command_proto_rawDesc = "" +
"\n" +
"\rcommand.proto\x12\x05proto\"I\n" +
"\vCommandInfo\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\x12\x16\n" +
"\x06method\x18\x02 \x01(\tR\x06method\x12\x12\n" +
"\x04tags\x18\x03 \x03(\tR\x04tags\">\n" +
"\x14CommandLookupRequest\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\x12\x16\n" +
"\x06method\x18\x02 \x01(\tR\x06method\"3\n" +
"\x12AddCommandResponse\x12\x1d\n" +
"\n" +
"is_success\x18\x01 \x01(\bR\tisSuccess\"6\n" +
"\x15RemoveCommandResponse\x12\x1d\n" +
"\n" +
"is_success\x18\x01 \x01(\bR\tisSuccess\"n\n" +
"\x0fCommandArgument\x12\x18\n" +
"\acommand\x18\x01 \x01(\tR\acommand\x12\x16\n" +
"\x06method\x18\x02 \x01(\tR\x06method\x12\x1d\n" +
"\apayload\x18\x03 \x01(\fH\x00R\apayload\x88\x01\x01B\n" +
"\n" +
"\b_payload\"\x98\x01\n" +
"\rCommandReturn\x12!\n" +
"\fis_delivered\x18\x01 \x01(\bR\visDelivered\x12\x16\n" +
"\x06status\x18\x02 \x01(\x05R\x06status\x12!\n" +
"\fcontent_type\x18\x03 \x01(\tR\vcontentType\x12\x1d\n" +
"\apayload\x18\x04 \x01(\fH\x00R\apayload\x88\x01\x01B\n" +
"\n" +
"\b_payload2\xa6\x02\n" +
"\x0fCommandProvider\x12=\n" +
"\n" +
"AddCommand\x12\x12.proto.CommandInfo\x1a\x19.proto.AddCommandResponse\"\x00\x12L\n" +
"\rRemoveCommand\x12\x1b.proto.CommandLookupRequest\x1a\x1c.proto.RemoveCommandResponse\"\x00\x12=\n" +
"\vSendCommand\x12\x16.proto.CommandArgument\x1a\x14.proto.CommandReturn\"\x00\x12G\n" +
"\x11SendStreamCommand\x12\x16.proto.CommandArgument\x1a\x14.proto.CommandReturn\"\x00(\x010\x01B\tZ\a.;protob\x06proto3"
var (
file_command_proto_rawDescOnce sync.Once
file_command_proto_rawDescData = file_command_proto_rawDesc
file_command_proto_rawDescData []byte
)
func file_command_proto_rawDescGZIP() []byte {
file_command_proto_rawDescOnce.Do(func() {
file_command_proto_rawDescData = protoimpl.X.CompressGZIP(file_command_proto_rawDescData)
file_command_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_command_proto_rawDesc), len(file_command_proto_rawDesc)))
})
return file_command_proto_rawDescData
}
var file_command_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_command_proto_goTypes = []interface{}{
var file_command_proto_goTypes = []any{
(*CommandInfo)(nil), // 0: proto.CommandInfo
(*CommandLookupRequest)(nil), // 1: proto.CommandLookupRequest
(*AddCommandResponse)(nil), // 2: proto.AddCommandResponse
@@ -467,87 +429,13 @@ func file_command_proto_init() {
if File_command_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_command_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CommandInfo); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_command_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CommandLookupRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_command_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AddCommandResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_command_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RemoveCommandResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_command_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CommandArgument); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_command_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CommandReturn); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
file_command_proto_msgTypes[4].OneofWrappers = []interface{}{}
file_command_proto_msgTypes[5].OneofWrappers = []interface{}{}
file_command_proto_msgTypes[4].OneofWrappers = []any{}
file_command_proto_msgTypes[5].OneofWrappers = []any{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_command_proto_rawDesc,
RawDescriptor: unsafe.Slice(unsafe.StringData(file_command_proto_rawDesc), len(file_command_proto_rawDesc)),
NumEnums: 0,
NumMessages: 6,
NumExtensions: 0,
@@ -558,7 +446,6 @@ func file_command_proto_init() {
MessageInfos: file_command_proto_msgTypes,
}.Build()
File_command_proto = out.File
file_command_proto_rawDesc = nil
file_command_proto_goTypes = nil
file_command_proto_depIdxs = nil
}

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v5.28.2
// - protoc-gen-go-grpc v1.5.1
// - protoc v5.29.3
// source: command.proto
package proto
@@ -15,8 +15,15 @@ import (
// 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.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
CommandProvider_AddCommand_FullMethodName = "/proto.CommandProvider/AddCommand"
CommandProvider_RemoveCommand_FullMethodName = "/proto.CommandProvider/RemoveCommand"
CommandProvider_SendCommand_FullMethodName = "/proto.CommandProvider/SendCommand"
CommandProvider_SendStreamCommand_FullMethodName = "/proto.CommandProvider/SendStreamCommand"
)
// CommandProviderClient is the client API for CommandProvider service.
//
@@ -25,7 +32,7 @@ type CommandProviderClient interface {
AddCommand(ctx context.Context, in *CommandInfo, opts ...grpc.CallOption) (*AddCommandResponse, error)
RemoveCommand(ctx context.Context, in *CommandLookupRequest, opts ...grpc.CallOption) (*RemoveCommandResponse, error)
SendCommand(ctx context.Context, in *CommandArgument, opts ...grpc.CallOption) (*CommandReturn, error)
SendStreamCommand(ctx context.Context, opts ...grpc.CallOption) (CommandProvider_SendStreamCommandClient, error)
SendStreamCommand(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[CommandArgument, CommandReturn], error)
}
type commandProviderClient struct {
@@ -37,8 +44,9 @@ func NewCommandProviderClient(cc grpc.ClientConnInterface) CommandProviderClient
}
func (c *commandProviderClient) AddCommand(ctx context.Context, in *CommandInfo, opts ...grpc.CallOption) (*AddCommandResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(AddCommandResponse)
err := c.cc.Invoke(ctx, "/proto.CommandProvider/AddCommand", in, out, opts...)
err := c.cc.Invoke(ctx, CommandProvider_AddCommand_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -46,8 +54,9 @@ func (c *commandProviderClient) AddCommand(ctx context.Context, in *CommandInfo,
}
func (c *commandProviderClient) RemoveCommand(ctx context.Context, in *CommandLookupRequest, opts ...grpc.CallOption) (*RemoveCommandResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(RemoveCommandResponse)
err := c.cc.Invoke(ctx, "/proto.CommandProvider/RemoveCommand", in, out, opts...)
err := c.cc.Invoke(ctx, CommandProvider_RemoveCommand_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -55,59 +64,45 @@ func (c *commandProviderClient) RemoveCommand(ctx context.Context, in *CommandLo
}
func (c *commandProviderClient) SendCommand(ctx context.Context, in *CommandArgument, opts ...grpc.CallOption) (*CommandReturn, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CommandReturn)
err := c.cc.Invoke(ctx, "/proto.CommandProvider/SendCommand", in, out, opts...)
err := c.cc.Invoke(ctx, CommandProvider_SendCommand_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *commandProviderClient) SendStreamCommand(ctx context.Context, opts ...grpc.CallOption) (CommandProvider_SendStreamCommandClient, error) {
stream, err := c.cc.NewStream(ctx, &CommandProvider_ServiceDesc.Streams[0], "/proto.CommandProvider/SendStreamCommand", opts...)
func (c *commandProviderClient) SendStreamCommand(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[CommandArgument, CommandReturn], error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
stream, err := c.cc.NewStream(ctx, &CommandProvider_ServiceDesc.Streams[0], CommandProvider_SendStreamCommand_FullMethodName, cOpts...)
if err != nil {
return nil, err
}
x := &commandProviderSendStreamCommandClient{stream}
x := &grpc.GenericClientStream[CommandArgument, CommandReturn]{ClientStream: stream}
return x, nil
}
type CommandProvider_SendStreamCommandClient interface {
Send(*CommandArgument) error
Recv() (*CommandReturn, error)
grpc.ClientStream
}
type commandProviderSendStreamCommandClient struct {
grpc.ClientStream
}
func (x *commandProviderSendStreamCommandClient) Send(m *CommandArgument) error {
return x.ClientStream.SendMsg(m)
}
func (x *commandProviderSendStreamCommandClient) Recv() (*CommandReturn, error) {
m := new(CommandReturn)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type CommandProvider_SendStreamCommandClient = grpc.BidiStreamingClient[CommandArgument, CommandReturn]
// CommandProviderServer is the server API for CommandProvider service.
// All implementations must embed UnimplementedCommandProviderServer
// for forward compatibility
// for forward compatibility.
type CommandProviderServer interface {
AddCommand(context.Context, *CommandInfo) (*AddCommandResponse, error)
RemoveCommand(context.Context, *CommandLookupRequest) (*RemoveCommandResponse, error)
SendCommand(context.Context, *CommandArgument) (*CommandReturn, error)
SendStreamCommand(CommandProvider_SendStreamCommandServer) error
SendStreamCommand(grpc.BidiStreamingServer[CommandArgument, CommandReturn]) error
mustEmbedUnimplementedCommandProviderServer()
}
// UnimplementedCommandProviderServer must be embedded to have forward compatible implementations.
type UnimplementedCommandProviderServer struct {
}
// UnimplementedCommandProviderServer 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 UnimplementedCommandProviderServer struct{}
func (UnimplementedCommandProviderServer) AddCommand(context.Context, *CommandInfo) (*AddCommandResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method AddCommand not implemented")
@@ -118,10 +113,11 @@ func (UnimplementedCommandProviderServer) RemoveCommand(context.Context, *Comman
func (UnimplementedCommandProviderServer) SendCommand(context.Context, *CommandArgument) (*CommandReturn, error) {
return nil, status.Errorf(codes.Unimplemented, "method SendCommand not implemented")
}
func (UnimplementedCommandProviderServer) SendStreamCommand(CommandProvider_SendStreamCommandServer) error {
func (UnimplementedCommandProviderServer) SendStreamCommand(grpc.BidiStreamingServer[CommandArgument, CommandReturn]) error {
return status.Errorf(codes.Unimplemented, "method SendStreamCommand not implemented")
}
func (UnimplementedCommandProviderServer) mustEmbedUnimplementedCommandProviderServer() {}
func (UnimplementedCommandProviderServer) testEmbeddedByValue() {}
// UnsafeCommandProviderServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to CommandProviderServer will
@@ -131,6 +127,13 @@ type UnsafeCommandProviderServer interface {
}
func RegisterCommandProviderServer(s grpc.ServiceRegistrar, srv CommandProviderServer) {
// If the following call pancis, it indicates UnimplementedCommandProviderServer 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(&CommandProvider_ServiceDesc, srv)
}
@@ -144,7 +147,7 @@ func _CommandProvider_AddCommand_Handler(srv interface{}, ctx context.Context, d
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.CommandProvider/AddCommand",
FullMethod: CommandProvider_AddCommand_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CommandProviderServer).AddCommand(ctx, req.(*CommandInfo))
@@ -162,7 +165,7 @@ func _CommandProvider_RemoveCommand_Handler(srv interface{}, ctx context.Context
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.CommandProvider/RemoveCommand",
FullMethod: CommandProvider_RemoveCommand_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CommandProviderServer).RemoveCommand(ctx, req.(*CommandLookupRequest))
@@ -180,7 +183,7 @@ func _CommandProvider_SendCommand_Handler(srv interface{}, ctx context.Context,
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.CommandProvider/SendCommand",
FullMethod: CommandProvider_SendCommand_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CommandProviderServer).SendCommand(ctx, req.(*CommandArgument))
@@ -189,30 +192,11 @@ func _CommandProvider_SendCommand_Handler(srv interface{}, ctx context.Context,
}
func _CommandProvider_SendStreamCommand_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(CommandProviderServer).SendStreamCommand(&commandProviderSendStreamCommandServer{stream})
return srv.(CommandProviderServer).SendStreamCommand(&grpc.GenericServerStream[CommandArgument, CommandReturn]{ServerStream: stream})
}
type CommandProvider_SendStreamCommandServer interface {
Send(*CommandReturn) error
Recv() (*CommandArgument, error)
grpc.ServerStream
}
type commandProviderSendStreamCommandServer struct {
grpc.ServerStream
}
func (x *commandProviderSendStreamCommandServer) Send(m *CommandReturn) error {
return x.ServerStream.SendMsg(m)
}
func (x *commandProviderSendStreamCommandServer) Recv() (*CommandArgument, error) {
m := new(CommandArgument)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type CommandProvider_SendStreamCommandServer = grpc.BidiStreamingServer[CommandArgument, CommandReturn]
// CommandProvider_ServiceDesc is the grpc.ServiceDesc for CommandProvider service.
// It's only intended for direct use with grpc.RegisterService,

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc v5.28.2
// protoc-gen-go v1.36.6
// protoc v5.29.3
// source: database.proto
package proto
@@ -11,6 +11,7 @@ import (
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
@@ -21,20 +22,17 @@ const (
)
type AllocDatabaseRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *AllocDatabaseRequest) Reset() {
*x = AllocDatabaseRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_database_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_database_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AllocDatabaseRequest) String() string {
@@ -45,7 +43,7 @@ func (*AllocDatabaseRequest) ProtoMessage() {}
func (x *AllocDatabaseRequest) ProtoReflect() protoreflect.Message {
mi := &file_database_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -68,21 +66,18 @@ func (x *AllocDatabaseRequest) GetName() string {
}
type AllocDatabaseResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
IsSuccess bool `protobuf:"varint,1,opt,name=is_success,json=isSuccess,proto3" json:"is_success,omitempty"`
Dsn string `protobuf:"bytes,2,opt,name=dsn,proto3" json:"dsn,omitempty"`
unknownFields protoimpl.UnknownFields
IsSuccess bool `protobuf:"varint,1,opt,name=is_success,json=isSuccess,proto3" json:"is_success,omitempty"`
Dsn string `protobuf:"bytes,2,opt,name=dsn,proto3" json:"dsn,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *AllocDatabaseResponse) Reset() {
*x = AllocDatabaseResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_database_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_database_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AllocDatabaseResponse) String() string {
@@ -93,7 +88,7 @@ func (*AllocDatabaseResponse) ProtoMessage() {}
func (x *AllocDatabaseResponse) ProtoReflect() protoreflect.Message {
mi := &file_database_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -124,40 +119,32 @@ func (x *AllocDatabaseResponse) GetDsn() string {
var File_database_proto protoreflect.FileDescriptor
var file_database_proto_rawDesc = []byte{
0x0a, 0x0e, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2a, 0x0a, 0x14, 0x41, 0x6c, 0x6c, 0x6f, 0x63,
0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e,
0x61, 0x6d, 0x65, 0x22, 0x48, 0x0a, 0x15, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x44, 0x61, 0x74, 0x61,
0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a,
0x69, 0x73, 0x5f, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08,
0x52, 0x09, 0x69, 0x73, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x64,
0x73, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x64, 0x73, 0x6e, 0x32, 0x5f, 0x0a,
0x0f, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x12, 0x4c, 0x0a, 0x0d, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73,
0x65, 0x12, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x44,
0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x44, 0x61, 0x74, 0x61,
0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x09,
0x5a, 0x07, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
}
const file_database_proto_rawDesc = "" +
"\n" +
"\x0edatabase.proto\x12\x05proto\"*\n" +
"\x14AllocDatabaseRequest\x12\x12\n" +
"\x04name\x18\x01 \x01(\tR\x04name\"H\n" +
"\x15AllocDatabaseResponse\x12\x1d\n" +
"\n" +
"is_success\x18\x01 \x01(\bR\tisSuccess\x12\x10\n" +
"\x03dsn\x18\x02 \x01(\tR\x03dsn2_\n" +
"\x0fDatabaseService\x12L\n" +
"\rAllocDatabase\x12\x1b.proto.AllocDatabaseRequest\x1a\x1c.proto.AllocDatabaseResponse\"\x00B\tZ\a.;protob\x06proto3"
var (
file_database_proto_rawDescOnce sync.Once
file_database_proto_rawDescData = file_database_proto_rawDesc
file_database_proto_rawDescData []byte
)
func file_database_proto_rawDescGZIP() []byte {
file_database_proto_rawDescOnce.Do(func() {
file_database_proto_rawDescData = protoimpl.X.CompressGZIP(file_database_proto_rawDescData)
file_database_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_database_proto_rawDesc), len(file_database_proto_rawDesc)))
})
return file_database_proto_rawDescData
}
var file_database_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_database_proto_goTypes = []interface{}{
var file_database_proto_goTypes = []any{
(*AllocDatabaseRequest)(nil), // 0: proto.AllocDatabaseRequest
(*AllocDatabaseResponse)(nil), // 1: proto.AllocDatabaseResponse
}
@@ -176,37 +163,11 @@ func file_database_proto_init() {
if File_database_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_database_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AllocDatabaseRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_database_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AllocDatabaseResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_database_proto_rawDesc,
RawDescriptor: unsafe.Slice(unsafe.StringData(file_database_proto_rawDesc), len(file_database_proto_rawDesc)),
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
@@ -217,7 +178,6 @@ func file_database_proto_init() {
MessageInfos: file_database_proto_msgTypes,
}.Build()
File_database_proto = out.File
file_database_proto_rawDesc = nil
file_database_proto_goTypes = nil
file_database_proto_depIdxs = nil
}

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v5.28.2
// - protoc-gen-go-grpc v1.5.1
// - protoc v5.29.3
// source: database.proto
package proto
@@ -15,8 +15,12 @@ import (
// 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.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
DatabaseService_AllocDatabase_FullMethodName = "/proto.DatabaseService/AllocDatabase"
)
// DatabaseServiceClient is the client API for DatabaseService service.
//
@@ -34,8 +38,9 @@ func NewDatabaseServiceClient(cc grpc.ClientConnInterface) DatabaseServiceClient
}
func (c *databaseServiceClient) AllocDatabase(ctx context.Context, in *AllocDatabaseRequest, opts ...grpc.CallOption) (*AllocDatabaseResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(AllocDatabaseResponse)
err := c.cc.Invoke(ctx, "/proto.DatabaseService/AllocDatabase", in, out, opts...)
err := c.cc.Invoke(ctx, DatabaseService_AllocDatabase_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -44,20 +49,24 @@ func (c *databaseServiceClient) AllocDatabase(ctx context.Context, in *AllocData
// DatabaseServiceServer is the server API for DatabaseService service.
// All implementations must embed UnimplementedDatabaseServiceServer
// for forward compatibility
// for forward compatibility.
type DatabaseServiceServer interface {
AllocDatabase(context.Context, *AllocDatabaseRequest) (*AllocDatabaseResponse, error)
mustEmbedUnimplementedDatabaseServiceServer()
}
// UnimplementedDatabaseServiceServer must be embedded to have forward compatible implementations.
type UnimplementedDatabaseServiceServer struct {
}
// UnimplementedDatabaseServiceServer 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 UnimplementedDatabaseServiceServer struct{}
func (UnimplementedDatabaseServiceServer) AllocDatabase(context.Context, *AllocDatabaseRequest) (*AllocDatabaseResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method AllocDatabase not implemented")
}
func (UnimplementedDatabaseServiceServer) mustEmbedUnimplementedDatabaseServiceServer() {}
func (UnimplementedDatabaseServiceServer) testEmbeddedByValue() {}
// UnsafeDatabaseServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to DatabaseServiceServer will
@@ -67,6 +76,13 @@ type UnsafeDatabaseServiceServer interface {
}
func RegisterDatabaseServiceServer(s grpc.ServiceRegistrar, srv DatabaseServiceServer) {
// If the following call pancis, it indicates UnimplementedDatabaseServiceServer 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(&DatabaseService_ServiceDesc, srv)
}
@@ -80,7 +96,7 @@ func _DatabaseService_AllocDatabase_Handler(srv interface{}, ctx context.Context
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.DatabaseService/AllocDatabase",
FullMethod: DatabaseService_AllocDatabase_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DatabaseServiceServer).AllocDatabase(ctx, req.(*AllocDatabaseRequest))

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc v5.28.2
// protoc-gen-go v1.36.6
// protoc v5.29.3
// source: services.proto
package proto
@@ -11,6 +11,7 @@ import (
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
@@ -21,24 +22,21 @@ const (
)
type ServiceInfo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
Label string `protobuf:"bytes,3,opt,name=label,proto3" json:"label,omitempty"`
GrpcAddr string `protobuf:"bytes,4,opt,name=grpc_addr,json=grpcAddr,proto3" json:"grpc_addr,omitempty"`
HttpAddr *string `protobuf:"bytes,5,opt,name=http_addr,json=httpAddr,proto3,oneof" json:"http_addr,omitempty"`
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
Label string `protobuf:"bytes,3,opt,name=label,proto3" json:"label,omitempty"`
GrpcAddr string `protobuf:"bytes,4,opt,name=grpc_addr,json=grpcAddr,proto3" json:"grpc_addr,omitempty"`
HttpAddr *string `protobuf:"bytes,5,opt,name=http_addr,json=httpAddr,proto3,oneof" json:"http_addr,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *ServiceInfo) Reset() {
*x = ServiceInfo{}
if protoimpl.UnsafeEnabled {
mi := &file_services_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_services_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ServiceInfo) String() string {
@@ -49,7 +47,7 @@ func (*ServiceInfo) ProtoMessage() {}
func (x *ServiceInfo) ProtoReflect() protoreflect.Message {
mi := &file_services_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -100,21 +98,18 @@ func (x *ServiceInfo) GetHttpAddr() string {
}
type GetServiceRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
Id *string `protobuf:"bytes,1,opt,name=id,proto3,oneof" json:"id,omitempty"`
Type *string `protobuf:"bytes,2,opt,name=type,proto3,oneof" json:"type,omitempty"`
unknownFields protoimpl.UnknownFields
Id *string `protobuf:"bytes,1,opt,name=id,proto3,oneof" json:"id,omitempty"`
Type *string `protobuf:"bytes,2,opt,name=type,proto3,oneof" json:"type,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *GetServiceRequest) Reset() {
*x = GetServiceRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_services_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_services_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetServiceRequest) String() string {
@@ -125,7 +120,7 @@ func (*GetServiceRequest) ProtoMessage() {}
func (x *GetServiceRequest) ProtoReflect() protoreflect.Message {
mi := &file_services_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -155,20 +150,17 @@ func (x *GetServiceRequest) GetType() string {
}
type GetServiceResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
Data *ServiceInfo `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
unknownFields protoimpl.UnknownFields
Data *ServiceInfo `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *GetServiceResponse) Reset() {
*x = GetServiceResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_services_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_services_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetServiceResponse) String() string {
@@ -179,7 +171,7 @@ func (*GetServiceResponse) ProtoMessage() {}
func (x *GetServiceResponse) ProtoReflect() protoreflect.Message {
mi := &file_services_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -202,20 +194,17 @@ func (x *GetServiceResponse) GetData() *ServiceInfo {
}
type ListServiceRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
Type *string `protobuf:"bytes,1,opt,name=type,proto3,oneof" json:"type,omitempty"`
unknownFields protoimpl.UnknownFields
Type *string `protobuf:"bytes,1,opt,name=type,proto3,oneof" json:"type,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *ListServiceRequest) Reset() {
*x = ListServiceRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_services_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_services_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListServiceRequest) String() string {
@@ -226,7 +215,7 @@ func (*ListServiceRequest) ProtoMessage() {}
func (x *ListServiceRequest) ProtoReflect() protoreflect.Message {
mi := &file_services_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -249,20 +238,17 @@ func (x *ListServiceRequest) GetType() string {
}
type ListServiceResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
Data []*ServiceInfo `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
unknownFields protoimpl.UnknownFields
Data []*ServiceInfo `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *ListServiceResponse) Reset() {
*x = ListServiceResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_services_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_services_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListServiceResponse) String() string {
@@ -273,7 +259,7 @@ func (*ListServiceResponse) ProtoMessage() {}
func (x *ListServiceResponse) ProtoReflect() protoreflect.Message {
mi := &file_services_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -296,20 +282,17 @@ func (x *ListServiceResponse) GetData() []*ServiceInfo {
}
type AddServiceResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
IsSuccess bool `protobuf:"varint,1,opt,name=is_success,json=isSuccess,proto3" json:"is_success,omitempty"`
unknownFields protoimpl.UnknownFields
IsSuccess bool `protobuf:"varint,1,opt,name=is_success,json=isSuccess,proto3" json:"is_success,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *AddServiceResponse) Reset() {
*x = AddServiceResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_services_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_services_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AddServiceResponse) String() string {
@@ -320,7 +303,7 @@ func (*AddServiceResponse) ProtoMessage() {}
func (x *AddServiceResponse) ProtoReflect() protoreflect.Message {
mi := &file_services_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -343,20 +326,17 @@ func (x *AddServiceResponse) GetIsSuccess() bool {
}
type RemoveServiceRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *RemoveServiceRequest) Reset() {
*x = RemoveServiceRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_services_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_services_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *RemoveServiceRequest) String() string {
@@ -367,7 +347,7 @@ func (*RemoveServiceRequest) ProtoMessage() {}
func (x *RemoveServiceRequest) ProtoReflect() protoreflect.Message {
mi := &file_services_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -390,20 +370,17 @@ func (x *RemoveServiceRequest) GetId() string {
}
type RemoveServiceResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
IsSuccess bool `protobuf:"varint,1,opt,name=is_success,json=isSuccess,proto3" json:"is_success,omitempty"`
unknownFields protoimpl.UnknownFields
IsSuccess bool `protobuf:"varint,1,opt,name=is_success,json=isSuccess,proto3" json:"is_success,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *RemoveServiceResponse) Reset() {
*x = RemoveServiceResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_services_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_services_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *RemoveServiceResponse) String() string {
@@ -414,7 +391,7 @@ func (*RemoveServiceResponse) ProtoMessage() {}
func (x *RemoveServiceResponse) ProtoReflect() protoreflect.Message {
mi := &file_services_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -437,21 +414,18 @@ func (x *RemoveServiceResponse) GetIsSuccess() bool {
}
type EventInfo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
Event string `protobuf:"bytes,1,opt,name=event,proto3" json:"event,omitempty"`
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
unknownFields protoimpl.UnknownFields
Event string `protobuf:"bytes,1,opt,name=event,proto3" json:"event,omitempty"`
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *EventInfo) Reset() {
*x = EventInfo{}
if protoimpl.UnsafeEnabled {
mi := &file_services_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_services_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *EventInfo) String() string {
@@ -462,7 +436,7 @@ func (*EventInfo) ProtoMessage() {}
func (x *EventInfo) ProtoReflect() protoreflect.Message {
mi := &file_services_proto_msgTypes[8]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -492,18 +466,16 @@ func (x *EventInfo) GetData() []byte {
}
type EventResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *EventResponse) Reset() {
*x = EventResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_services_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_services_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *EventResponse) String() string {
@@ -514,7 +486,7 @@ func (*EventResponse) ProtoMessage() {}
func (x *EventResponse) ProtoReflect() protoreflect.Message {
mi := &file_services_proto_msgTypes[9]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -531,89 +503,64 @@ func (*EventResponse) Descriptor() ([]byte, []int) {
var File_services_proto protoreflect.FileDescriptor
var file_services_proto_rawDesc = []byte{
0x0a, 0x0e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x94, 0x01, 0x0a, 0x0b, 0x53, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6c,
0x61, 0x62, 0x65, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x61, 0x62, 0x65,
0x6c, 0x12, 0x1b, 0x0a, 0x09, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x04,
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x67, 0x72, 0x70, 0x63, 0x41, 0x64, 0x64, 0x72, 0x12, 0x20,
0x0a, 0x09, 0x68, 0x74, 0x74, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28,
0x09, 0x48, 0x00, 0x52, 0x08, 0x68, 0x74, 0x74, 0x70, 0x41, 0x64, 0x64, 0x72, 0x88, 0x01, 0x01,
0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x68, 0x74, 0x74, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x22, 0x51,
0x0a, 0x11, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x13, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48,
0x00, 0x52, 0x02, 0x69, 0x64, 0x88, 0x01, 0x01, 0x12, 0x17, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x88, 0x01,
0x01, 0x42, 0x05, 0x0a, 0x03, 0x5f, 0x69, 0x64, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x74, 0x79, 0x70,
0x65, 0x22, 0x3c, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18,
0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22,
0x36, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x88, 0x01, 0x01, 0x42, 0x07,
0x0a, 0x05, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3d, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x53,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26,
0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f,
0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x33, 0x0a, 0x12, 0x41, 0x64, 0x64, 0x53, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a,
0x69, 0x73, 0x5f, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08,
0x52, 0x09, 0x69, 0x73, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x22, 0x26, 0x0a, 0x14, 0x52,
0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x02, 0x69, 0x64, 0x22, 0x36, 0x0a, 0x15, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a,
0x69, 0x73, 0x5f, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08,
0x52, 0x09, 0x69, 0x73, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x22, 0x35, 0x0a, 0x09, 0x45,
0x76, 0x65, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e,
0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x12,
0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61,
0x74, 0x61, 0x22, 0x0f, 0x0a, 0x0d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x32, 0xe8, 0x02, 0x0a, 0x10, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72,
0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x43, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x53,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47,
0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x46, 0x0a,
0x0b, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x19, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3d, 0x0a, 0x0a, 0x41, 0x64, 0x64, 0x53, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x12, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x1a, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
0x41, 0x64, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x22, 0x00, 0x12, 0x4c, 0x0a, 0x0d, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65,
0x6d, 0x6f, 0x76, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76,
0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x12, 0x3a, 0x0a, 0x0e, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x45,
0x76, 0x65, 0x6e, 0x74, 0x12, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x76, 0x65,
0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45,
0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x09,
0x5a, 0x07, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
}
const file_services_proto_rawDesc = "" +
"\n" +
"\x0eservices.proto\x12\x05proto\"\x94\x01\n" +
"\vServiceInfo\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" +
"\x04type\x18\x02 \x01(\tR\x04type\x12\x14\n" +
"\x05label\x18\x03 \x01(\tR\x05label\x12\x1b\n" +
"\tgrpc_addr\x18\x04 \x01(\tR\bgrpcAddr\x12 \n" +
"\thttp_addr\x18\x05 \x01(\tH\x00R\bhttpAddr\x88\x01\x01B\f\n" +
"\n" +
"_http_addr\"Q\n" +
"\x11GetServiceRequest\x12\x13\n" +
"\x02id\x18\x01 \x01(\tH\x00R\x02id\x88\x01\x01\x12\x17\n" +
"\x04type\x18\x02 \x01(\tH\x01R\x04type\x88\x01\x01B\x05\n" +
"\x03_idB\a\n" +
"\x05_type\"<\n" +
"\x12GetServiceResponse\x12&\n" +
"\x04data\x18\x01 \x01(\v2\x12.proto.ServiceInfoR\x04data\"6\n" +
"\x12ListServiceRequest\x12\x17\n" +
"\x04type\x18\x01 \x01(\tH\x00R\x04type\x88\x01\x01B\a\n" +
"\x05_type\"=\n" +
"\x13ListServiceResponse\x12&\n" +
"\x04data\x18\x01 \x03(\v2\x12.proto.ServiceInfoR\x04data\"3\n" +
"\x12AddServiceResponse\x12\x1d\n" +
"\n" +
"is_success\x18\x01 \x01(\bR\tisSuccess\"&\n" +
"\x14RemoveServiceRequest\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\"6\n" +
"\x15RemoveServiceResponse\x12\x1d\n" +
"\n" +
"is_success\x18\x01 \x01(\bR\tisSuccess\"5\n" +
"\tEventInfo\x12\x14\n" +
"\x05event\x18\x01 \x01(\tR\x05event\x12\x12\n" +
"\x04data\x18\x02 \x01(\fR\x04data\"\x0f\n" +
"\rEventResponse2\xe8\x02\n" +
"\x10DirectoryService\x12C\n" +
"\n" +
"GetService\x12\x18.proto.GetServiceRequest\x1a\x19.proto.GetServiceResponse\"\x00\x12F\n" +
"\vListService\x12\x19.proto.ListServiceRequest\x1a\x1a.proto.ListServiceResponse\"\x00\x12=\n" +
"\n" +
"AddService\x12\x12.proto.ServiceInfo\x1a\x19.proto.AddServiceResponse\"\x00\x12L\n" +
"\rRemoveService\x12\x1b.proto.RemoveServiceRequest\x1a\x1c.proto.RemoveServiceResponse\"\x00\x12:\n" +
"\x0eBroadcastEvent\x12\x10.proto.EventInfo\x1a\x14.proto.EventResponse\"\x00B\tZ\a.;protob\x06proto3"
var (
file_services_proto_rawDescOnce sync.Once
file_services_proto_rawDescData = file_services_proto_rawDesc
file_services_proto_rawDescData []byte
)
func file_services_proto_rawDescGZIP() []byte {
file_services_proto_rawDescOnce.Do(func() {
file_services_proto_rawDescData = protoimpl.X.CompressGZIP(file_services_proto_rawDescData)
file_services_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_services_proto_rawDesc), len(file_services_proto_rawDesc)))
})
return file_services_proto_rawDescData
}
var file_services_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_services_proto_goTypes = []interface{}{
var file_services_proto_goTypes = []any{
(*ServiceInfo)(nil), // 0: proto.ServiceInfo
(*GetServiceRequest)(nil), // 1: proto.GetServiceRequest
(*GetServiceResponse)(nil), // 2: proto.GetServiceResponse
@@ -650,136 +597,14 @@ func file_services_proto_init() {
if File_services_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_services_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ServiceInfo); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_services_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetServiceRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_services_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetServiceResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_services_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListServiceRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_services_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListServiceResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_services_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AddServiceResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_services_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RemoveServiceRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_services_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RemoveServiceResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_services_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EventInfo); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_services_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EventResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
file_services_proto_msgTypes[0].OneofWrappers = []interface{}{}
file_services_proto_msgTypes[1].OneofWrappers = []interface{}{}
file_services_proto_msgTypes[3].OneofWrappers = []interface{}{}
file_services_proto_msgTypes[0].OneofWrappers = []any{}
file_services_proto_msgTypes[1].OneofWrappers = []any{}
file_services_proto_msgTypes[3].OneofWrappers = []any{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_services_proto_rawDesc,
RawDescriptor: unsafe.Slice(unsafe.StringData(file_services_proto_rawDesc), len(file_services_proto_rawDesc)),
NumEnums: 0,
NumMessages: 10,
NumExtensions: 0,
@@ -790,7 +615,6 @@ func file_services_proto_init() {
MessageInfos: file_services_proto_msgTypes,
}.Build()
File_services_proto = out.File
file_services_proto_rawDesc = nil
file_services_proto_goTypes = nil
file_services_proto_depIdxs = nil
}

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v5.28.2
// - protoc-gen-go-grpc v1.5.1
// - protoc v5.29.3
// source: services.proto
package proto
@@ -15,8 +15,16 @@ import (
// 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.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
DirectoryService_GetService_FullMethodName = "/proto.DirectoryService/GetService"
DirectoryService_ListService_FullMethodName = "/proto.DirectoryService/ListService"
DirectoryService_AddService_FullMethodName = "/proto.DirectoryService/AddService"
DirectoryService_RemoveService_FullMethodName = "/proto.DirectoryService/RemoveService"
DirectoryService_BroadcastEvent_FullMethodName = "/proto.DirectoryService/BroadcastEvent"
)
// DirectoryServiceClient is the client API for DirectoryService service.
//
@@ -38,8 +46,9 @@ func NewDirectoryServiceClient(cc grpc.ClientConnInterface) DirectoryServiceClie
}
func (c *directoryServiceClient) GetService(ctx context.Context, in *GetServiceRequest, opts ...grpc.CallOption) (*GetServiceResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetServiceResponse)
err := c.cc.Invoke(ctx, "/proto.DirectoryService/GetService", in, out, opts...)
err := c.cc.Invoke(ctx, DirectoryService_GetService_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -47,8 +56,9 @@ func (c *directoryServiceClient) GetService(ctx context.Context, in *GetServiceR
}
func (c *directoryServiceClient) ListService(ctx context.Context, in *ListServiceRequest, opts ...grpc.CallOption) (*ListServiceResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListServiceResponse)
err := c.cc.Invoke(ctx, "/proto.DirectoryService/ListService", in, out, opts...)
err := c.cc.Invoke(ctx, DirectoryService_ListService_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -56,8 +66,9 @@ func (c *directoryServiceClient) ListService(ctx context.Context, in *ListServic
}
func (c *directoryServiceClient) AddService(ctx context.Context, in *ServiceInfo, opts ...grpc.CallOption) (*AddServiceResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(AddServiceResponse)
err := c.cc.Invoke(ctx, "/proto.DirectoryService/AddService", in, out, opts...)
err := c.cc.Invoke(ctx, DirectoryService_AddService_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -65,8 +76,9 @@ func (c *directoryServiceClient) AddService(ctx context.Context, in *ServiceInfo
}
func (c *directoryServiceClient) RemoveService(ctx context.Context, in *RemoveServiceRequest, opts ...grpc.CallOption) (*RemoveServiceResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(RemoveServiceResponse)
err := c.cc.Invoke(ctx, "/proto.DirectoryService/RemoveService", in, out, opts...)
err := c.cc.Invoke(ctx, DirectoryService_RemoveService_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -74,8 +86,9 @@ func (c *directoryServiceClient) RemoveService(ctx context.Context, in *RemoveSe
}
func (c *directoryServiceClient) BroadcastEvent(ctx context.Context, in *EventInfo, opts ...grpc.CallOption) (*EventResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(EventResponse)
err := c.cc.Invoke(ctx, "/proto.DirectoryService/BroadcastEvent", in, out, opts...)
err := c.cc.Invoke(ctx, DirectoryService_BroadcastEvent_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -84,7 +97,7 @@ func (c *directoryServiceClient) BroadcastEvent(ctx context.Context, in *EventIn
// DirectoryServiceServer is the server API for DirectoryService service.
// All implementations must embed UnimplementedDirectoryServiceServer
// for forward compatibility
// for forward compatibility.
type DirectoryServiceServer interface {
GetService(context.Context, *GetServiceRequest) (*GetServiceResponse, error)
ListService(context.Context, *ListServiceRequest) (*ListServiceResponse, error)
@@ -94,9 +107,12 @@ type DirectoryServiceServer interface {
mustEmbedUnimplementedDirectoryServiceServer()
}
// UnimplementedDirectoryServiceServer must be embedded to have forward compatible implementations.
type UnimplementedDirectoryServiceServer struct {
}
// UnimplementedDirectoryServiceServer 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 UnimplementedDirectoryServiceServer struct{}
func (UnimplementedDirectoryServiceServer) GetService(context.Context, *GetServiceRequest) (*GetServiceResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetService not implemented")
@@ -114,6 +130,7 @@ func (UnimplementedDirectoryServiceServer) BroadcastEvent(context.Context, *Even
return nil, status.Errorf(codes.Unimplemented, "method BroadcastEvent not implemented")
}
func (UnimplementedDirectoryServiceServer) mustEmbedUnimplementedDirectoryServiceServer() {}
func (UnimplementedDirectoryServiceServer) testEmbeddedByValue() {}
// UnsafeDirectoryServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to DirectoryServiceServer will
@@ -123,6 +140,13 @@ type UnsafeDirectoryServiceServer interface {
}
func RegisterDirectoryServiceServer(s grpc.ServiceRegistrar, srv DirectoryServiceServer) {
// If the following call pancis, it indicates UnimplementedDirectoryServiceServer 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(&DirectoryService_ServiceDesc, srv)
}
@@ -136,7 +160,7 @@ func _DirectoryService_GetService_Handler(srv interface{}, ctx context.Context,
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.DirectoryService/GetService",
FullMethod: DirectoryService_GetService_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DirectoryServiceServer).GetService(ctx, req.(*GetServiceRequest))
@@ -154,7 +178,7 @@ func _DirectoryService_ListService_Handler(srv interface{}, ctx context.Context,
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.DirectoryService/ListService",
FullMethod: DirectoryService_ListService_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DirectoryServiceServer).ListService(ctx, req.(*ListServiceRequest))
@@ -172,7 +196,7 @@ func _DirectoryService_AddService_Handler(srv interface{}, ctx context.Context,
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.DirectoryService/AddService",
FullMethod: DirectoryService_AddService_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DirectoryServiceServer).AddService(ctx, req.(*ServiceInfo))
@@ -190,7 +214,7 @@ func _DirectoryService_RemoveService_Handler(srv interface{}, ctx context.Contex
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.DirectoryService/RemoveService",
FullMethod: DirectoryService_RemoveService_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DirectoryServiceServer).RemoveService(ctx, req.(*RemoveServiceRequest))
@@ -208,7 +232,7 @@ func _DirectoryService_BroadcastEvent_Handler(srv interface{}, ctx context.Conte
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.DirectoryService/BroadcastEvent",
FullMethod: DirectoryService_BroadcastEvent_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DirectoryServiceServer).BroadcastEvent(ctx, req.(*EventInfo))

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc v5.28.2
// protoc-gen-go v1.36.6
// protoc v5.29.3
// source: stream.proto
package proto
@@ -11,6 +11,7 @@ import (
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
@@ -21,20 +22,17 @@ const (
)
type CountConnectionRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
UserId uint64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
unknownFields protoimpl.UnknownFields
UserId uint64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *CountConnectionRequest) Reset() {
*x = CountConnectionRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_stream_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_stream_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CountConnectionRequest) String() string {
@@ -45,7 +43,7 @@ func (*CountConnectionRequest) ProtoMessage() {}
func (x *CountConnectionRequest) ProtoReflect() protoreflect.Message {
mi := &file_stream_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -68,20 +66,17 @@ func (x *CountConnectionRequest) GetUserId() uint64 {
}
type CountConnectionResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
Count int64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"`
unknownFields protoimpl.UnknownFields
Count int64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *CountConnectionResponse) Reset() {
*x = CountConnectionResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_stream_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_stream_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CountConnectionResponse) String() string {
@@ -92,7 +87,7 @@ func (*CountConnectionResponse) ProtoMessage() {}
func (x *CountConnectionResponse) ProtoReflect() protoreflect.Message {
mi := &file_stream_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -115,22 +110,19 @@ func (x *CountConnectionResponse) GetCount() int64 {
}
type PushStreamRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
UserId *uint64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3,oneof" json:"user_id,omitempty"`
ClientId *string `protobuf:"bytes,2,opt,name=client_id,json=clientId,proto3,oneof" json:"client_id,omitempty"`
Body []byte `protobuf:"bytes,3,opt,name=body,proto3" json:"body,omitempty"`
unknownFields protoimpl.UnknownFields
UserId *uint64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3,oneof" json:"user_id,omitempty"`
ClientId *uint64 `protobuf:"varint,2,opt,name=client_id,json=clientId,proto3,oneof" json:"client_id,omitempty"`
Body []byte `protobuf:"bytes,3,opt,name=body,proto3" json:"body,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *PushStreamRequest) Reset() {
*x = PushStreamRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_stream_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_stream_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *PushStreamRequest) String() string {
@@ -141,7 +133,7 @@ func (*PushStreamRequest) ProtoMessage() {}
func (x *PushStreamRequest) ProtoReflect() protoreflect.Message {
mi := &file_stream_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -163,11 +155,11 @@ func (x *PushStreamRequest) GetUserId() uint64 {
return 0
}
func (x *PushStreamRequest) GetClientId() uint64 {
func (x *PushStreamRequest) GetClientId() string {
if x != nil && x.ClientId != nil {
return *x.ClientId
}
return 0
return ""
}
func (x *PushStreamRequest) GetBody() []byte {
@@ -178,22 +170,19 @@ func (x *PushStreamRequest) GetBody() []byte {
}
type PushStreamBatchRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
UserId []uint64 `protobuf:"varint,1,rep,packed,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
ClientId []string `protobuf:"bytes,2,rep,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
Body []byte `protobuf:"bytes,3,opt,name=body,proto3" json:"body,omitempty"`
unknownFields protoimpl.UnknownFields
UserId []uint64 `protobuf:"varint,1,rep,packed,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
ClientId []uint64 `protobuf:"varint,2,rep,packed,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
Body []byte `protobuf:"bytes,3,opt,name=body,proto3" json:"body,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *PushStreamBatchRequest) Reset() {
*x = PushStreamBatchRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_stream_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_stream_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *PushStreamBatchRequest) String() string {
@@ -204,7 +193,7 @@ func (*PushStreamBatchRequest) ProtoMessage() {}
func (x *PushStreamBatchRequest) ProtoReflect() protoreflect.Message {
mi := &file_stream_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -226,7 +215,7 @@ func (x *PushStreamBatchRequest) GetUserId() []uint64 {
return nil
}
func (x *PushStreamBatchRequest) GetClientId() []uint64 {
func (x *PushStreamBatchRequest) GetClientId() []string {
if x != nil {
return x.ClientId
}
@@ -241,22 +230,20 @@ func (x *PushStreamBatchRequest) GetBody() []byte {
}
type PushStreamResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
IsAllSuccess bool `protobuf:"varint,1,opt,name=is_all_success,json=isAllSuccess,proto3" json:"is_all_success,omitempty"`
AffectedCount int64 `protobuf:"varint,2,opt,name=affected_count,json=affectedCount,proto3" json:"affected_count,omitempty"`
FailedCount int64 `protobuf:"varint,3,opt,name=failed_count,json=failedCount,proto3" json:"failed_count,omitempty"`
SuccessList []string `protobuf:"bytes,4,rep,name=success_list,json=successList,proto3" json:"success_list,omitempty"`
unknownFields protoimpl.UnknownFields
IsAllSuccess bool `protobuf:"varint,1,opt,name=is_all_success,json=isAllSuccess,proto3" json:"is_all_success,omitempty"`
AffectedCount int64 `protobuf:"varint,2,opt,name=affected_count,json=affectedCount,proto3" json:"affected_count,omitempty"`
FailedCount int64 `protobuf:"varint,3,opt,name=failed_count,json=failedCount,proto3" json:"failed_count,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *PushStreamResponse) Reset() {
*x = PushStreamResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_stream_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_stream_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *PushStreamResponse) String() string {
@@ -267,7 +254,7 @@ func (*PushStreamResponse) ProtoMessage() {}
func (x *PushStreamResponse) ProtoReflect() protoreflect.Message {
mi := &file_stream_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -303,24 +290,28 @@ func (x *PushStreamResponse) GetFailedCount() int64 {
return 0
}
type StreamEventRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
func (x *PushStreamResponse) GetSuccessList() []string {
if x != nil {
return x.SuccessList
}
return nil
}
Event string `protobuf:"bytes,1,opt,name=event,proto3" json:"event,omitempty"`
UserId uint64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
ClientId uint64 `protobuf:"varint,3,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
Payload []byte `protobuf:"bytes,4,opt,name=payload,proto3" json:"payload,omitempty"`
type StreamEventRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Event string `protobuf:"bytes,1,opt,name=event,proto3" json:"event,omitempty"`
UserId uint64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
ClientId string `protobuf:"bytes,3,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
Payload []byte `protobuf:"bytes,4,opt,name=payload,proto3" json:"payload,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *StreamEventRequest) Reset() {
*x = StreamEventRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_stream_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_stream_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *StreamEventRequest) String() string {
@@ -331,7 +322,7 @@ func (*StreamEventRequest) ProtoMessage() {}
func (x *StreamEventRequest) ProtoReflect() protoreflect.Message {
mi := &file_stream_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -360,11 +351,11 @@ func (x *StreamEventRequest) GetUserId() uint64 {
return 0
}
func (x *StreamEventRequest) GetClientId() uint64 {
func (x *StreamEventRequest) GetClientId() string {
if x != nil {
return x.ClientId
}
return 0
return ""
}
func (x *StreamEventRequest) GetPayload() []byte {
@@ -375,18 +366,16 @@ func (x *StreamEventRequest) GetPayload() []byte {
}
type StreamEventResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *StreamEventResponse) Reset() {
*x = StreamEventResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_stream_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_stream_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *StreamEventResponse) String() string {
@@ -397,7 +386,7 @@ func (*StreamEventResponse) ProtoMessage() {}
func (x *StreamEventResponse) ProtoReflect() protoreflect.Message {
mi := &file_stream_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -414,80 +403,56 @@ func (*StreamEventResponse) Descriptor() ([]byte, []int) {
var File_stream_proto protoreflect.FileDescriptor
var file_stream_proto_rawDesc = []byte{
0x0a, 0x0c, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x31, 0x0a, 0x16, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x43, 0x6f,
0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04,
0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x2f, 0x0a, 0x17, 0x43, 0x6f, 0x75, 0x6e,
0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01,
0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x81, 0x01, 0x0a, 0x11, 0x50, 0x75,
0x73, 0x68, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
0x1c, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04,
0x48, 0x00, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x88, 0x01, 0x01, 0x12, 0x20, 0x0a,
0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04,
0x48, 0x01, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x88, 0x01, 0x01, 0x12,
0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62,
0x6f, 0x64, 0x79, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x42,
0x0c, 0x0a, 0x0a, 0x5f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x22, 0x62, 0x0a,
0x16, 0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x42, 0x61, 0x74, 0x63, 0x68,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f,
0x69, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x04, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64,
0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20,
0x03, 0x28, 0x04, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a,
0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64,
0x79, 0x22, 0x84, 0x01, 0x0a, 0x12, 0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x69, 0x73, 0x5f, 0x61,
0x6c, 0x6c, 0x5f, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08,
0x52, 0x0c, 0x69, 0x73, 0x41, 0x6c, 0x6c, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x25,
0x0a, 0x0e, 0x61, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74,
0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x61, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64,
0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x5f,
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x66, 0x61, 0x69,
0x6c, 0x65, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x7a, 0x0a, 0x12, 0x53, 0x74, 0x72, 0x65,
0x61, 0x6d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14,
0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65,
0x76, 0x65, 0x6e, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18,
0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1b, 0x0a,
0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04,
0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61,
0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x79,
0x6c, 0x6f, 0x61, 0x64, 0x22, 0x15, 0x0a, 0x13, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x45, 0x76,
0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xfd, 0x01, 0x0a, 0x0d,
0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x58, 0x0a,
0x15, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, 0x6e, 0x6e,
0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43,
0x6f, 0x75, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x6f,
0x75, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0a, 0x50, 0x75, 0x73, 0x68, 0x53,
0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x75,
0x73, 0x68, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72, 0x65,
0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4d, 0x0a, 0x0f,
0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x42, 0x61, 0x74, 0x63, 0x68, 0x12,
0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72, 0x65,
0x61, 0x6d, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72, 0x65, 0x61,
0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x09, 0x5a, 0x07, 0x2e,
0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
const file_stream_proto_rawDesc = "" +
"\n" +
"\fstream.proto\x12\x05proto\"1\n" +
"\x16CountConnectionRequest\x12\x17\n" +
"\auser_id\x18\x01 \x01(\x04R\x06userId\"/\n" +
"\x17CountConnectionResponse\x12\x14\n" +
"\x05count\x18\x01 \x01(\x03R\x05count\"\x81\x01\n" +
"\x11PushStreamRequest\x12\x1c\n" +
"\auser_id\x18\x01 \x01(\x04H\x00R\x06userId\x88\x01\x01\x12 \n" +
"\tclient_id\x18\x02 \x01(\tH\x01R\bclientId\x88\x01\x01\x12\x12\n" +
"\x04body\x18\x03 \x01(\fR\x04bodyB\n" +
"\n" +
"\b_user_idB\f\n" +
"\n" +
"_client_id\"b\n" +
"\x16PushStreamBatchRequest\x12\x17\n" +
"\auser_id\x18\x01 \x03(\x04R\x06userId\x12\x1b\n" +
"\tclient_id\x18\x02 \x03(\tR\bclientId\x12\x12\n" +
"\x04body\x18\x03 \x01(\fR\x04body\"\xa7\x01\n" +
"\x12PushStreamResponse\x12$\n" +
"\x0eis_all_success\x18\x01 \x01(\bR\fisAllSuccess\x12%\n" +
"\x0eaffected_count\x18\x02 \x01(\x03R\raffectedCount\x12!\n" +
"\ffailed_count\x18\x03 \x01(\x03R\vfailedCount\x12!\n" +
"\fsuccess_list\x18\x04 \x03(\tR\vsuccessList\"z\n" +
"\x12StreamEventRequest\x12\x14\n" +
"\x05event\x18\x01 \x01(\tR\x05event\x12\x17\n" +
"\auser_id\x18\x02 \x01(\x04R\x06userId\x12\x1b\n" +
"\tclient_id\x18\x03 \x01(\tR\bclientId\x12\x18\n" +
"\apayload\x18\x04 \x01(\fR\apayload\"\x15\n" +
"\x13StreamEventResponse2\xfd\x01\n" +
"\rStreamService\x12X\n" +
"\x15CountStreamConnection\x12\x1d.proto.CountConnectionRequest\x1a\x1e.proto.CountConnectionResponse\"\x00\x12C\n" +
"\n" +
"PushStream\x12\x18.proto.PushStreamRequest\x1a\x19.proto.PushStreamResponse\"\x00\x12M\n" +
"\x0fPushStreamBatch\x12\x1d.proto.PushStreamBatchRequest\x1a\x19.proto.PushStreamResponse\"\x00B\tZ\a.;protob\x06proto3"
var (
file_stream_proto_rawDescOnce sync.Once
file_stream_proto_rawDescData = file_stream_proto_rawDesc
file_stream_proto_rawDescData []byte
)
func file_stream_proto_rawDescGZIP() []byte {
file_stream_proto_rawDescOnce.Do(func() {
file_stream_proto_rawDescData = protoimpl.X.CompressGZIP(file_stream_proto_rawDescData)
file_stream_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_stream_proto_rawDesc), len(file_stream_proto_rawDesc)))
})
return file_stream_proto_rawDescData
}
var file_stream_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_stream_proto_goTypes = []interface{}{
var file_stream_proto_goTypes = []any{
(*CountConnectionRequest)(nil), // 0: proto.CountConnectionRequest
(*CountConnectionResponse)(nil), // 1: proto.CountConnectionResponse
(*PushStreamRequest)(nil), // 2: proto.PushStreamRequest
@@ -515,98 +480,12 @@ func file_stream_proto_init() {
if File_stream_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_stream_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CountConnectionRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_stream_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CountConnectionResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_stream_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PushStreamRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_stream_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PushStreamBatchRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_stream_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PushStreamResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_stream_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StreamEventRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_stream_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StreamEventResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
file_stream_proto_msgTypes[2].OneofWrappers = []interface{}{}
file_stream_proto_msgTypes[2].OneofWrappers = []any{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_stream_proto_rawDesc,
RawDescriptor: unsafe.Slice(unsafe.StringData(file_stream_proto_rawDesc), len(file_stream_proto_rawDesc)),
NumEnums: 0,
NumMessages: 7,
NumExtensions: 0,
@@ -617,7 +496,6 @@ func file_stream_proto_init() {
MessageInfos: file_stream_proto_msgTypes,
}.Build()
File_stream_proto = out.File
file_stream_proto_rawDesc = nil
file_stream_proto_goTypes = nil
file_stream_proto_depIdxs = nil
}

View File

@@ -20,13 +20,13 @@ message CountConnectionResponse {
message PushStreamRequest {
optional uint64 user_id = 1;
optional uint64 client_id = 2;
optional string client_id = 2;
bytes body = 3;
}
message PushStreamBatchRequest {
repeated uint64 user_id = 1;
repeated uint64 client_id = 2;
repeated string client_id = 2;
bytes body = 3;
}
@@ -34,12 +34,13 @@ message PushStreamResponse {
bool is_all_success = 1;
int64 affected_count = 2;
int64 failed_count = 3;
repeated string success_list = 4;
}
message StreamEventRequest {
string event = 1;
uint64 user_id = 2;
uint64 client_id = 3;
string client_id = 3;
bytes payload = 4;
}

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v5.28.2
// - protoc-gen-go-grpc v1.5.1
// - protoc v5.29.3
// source: stream.proto
package proto
@@ -15,8 +15,14 @@ import (
// 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.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
StreamService_CountStreamConnection_FullMethodName = "/proto.StreamService/CountStreamConnection"
StreamService_PushStream_FullMethodName = "/proto.StreamService/PushStream"
StreamService_PushStreamBatch_FullMethodName = "/proto.StreamService/PushStreamBatch"
)
// StreamServiceClient is the client API for StreamService service.
//
@@ -36,8 +42,9 @@ func NewStreamServiceClient(cc grpc.ClientConnInterface) StreamServiceClient {
}
func (c *streamServiceClient) CountStreamConnection(ctx context.Context, in *CountConnectionRequest, opts ...grpc.CallOption) (*CountConnectionResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CountConnectionResponse)
err := c.cc.Invoke(ctx, "/proto.StreamService/CountStreamConnection", in, out, opts...)
err := c.cc.Invoke(ctx, StreamService_CountStreamConnection_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -45,8 +52,9 @@ func (c *streamServiceClient) CountStreamConnection(ctx context.Context, in *Cou
}
func (c *streamServiceClient) PushStream(ctx context.Context, in *PushStreamRequest, opts ...grpc.CallOption) (*PushStreamResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(PushStreamResponse)
err := c.cc.Invoke(ctx, "/proto.StreamService/PushStream", in, out, opts...)
err := c.cc.Invoke(ctx, StreamService_PushStream_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -54,8 +62,9 @@ func (c *streamServiceClient) PushStream(ctx context.Context, in *PushStreamRequ
}
func (c *streamServiceClient) PushStreamBatch(ctx context.Context, in *PushStreamBatchRequest, opts ...grpc.CallOption) (*PushStreamResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(PushStreamResponse)
err := c.cc.Invoke(ctx, "/proto.StreamService/PushStreamBatch", in, out, opts...)
err := c.cc.Invoke(ctx, StreamService_PushStreamBatch_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -64,7 +73,7 @@ func (c *streamServiceClient) PushStreamBatch(ctx context.Context, in *PushStrea
// StreamServiceServer is the server API for StreamService service.
// All implementations must embed UnimplementedStreamServiceServer
// for forward compatibility
// for forward compatibility.
type StreamServiceServer interface {
CountStreamConnection(context.Context, *CountConnectionRequest) (*CountConnectionResponse, error)
PushStream(context.Context, *PushStreamRequest) (*PushStreamResponse, error)
@@ -72,9 +81,12 @@ type StreamServiceServer interface {
mustEmbedUnimplementedStreamServiceServer()
}
// UnimplementedStreamServiceServer must be embedded to have forward compatible implementations.
type UnimplementedStreamServiceServer struct {
}
// UnimplementedStreamServiceServer 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 UnimplementedStreamServiceServer struct{}
func (UnimplementedStreamServiceServer) CountStreamConnection(context.Context, *CountConnectionRequest) (*CountConnectionResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CountStreamConnection not implemented")
@@ -86,6 +98,7 @@ func (UnimplementedStreamServiceServer) PushStreamBatch(context.Context, *PushSt
return nil, status.Errorf(codes.Unimplemented, "method PushStreamBatch not implemented")
}
func (UnimplementedStreamServiceServer) mustEmbedUnimplementedStreamServiceServer() {}
func (UnimplementedStreamServiceServer) testEmbeddedByValue() {}
// UnsafeStreamServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to StreamServiceServer will
@@ -95,6 +108,13 @@ type UnsafeStreamServiceServer interface {
}
func RegisterStreamServiceServer(s grpc.ServiceRegistrar, srv StreamServiceServer) {
// If the following call pancis, it indicates UnimplementedStreamServiceServer 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(&StreamService_ServiceDesc, srv)
}
@@ -108,7 +128,7 @@ func _StreamService_CountStreamConnection_Handler(srv interface{}, ctx context.C
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.StreamService/CountStreamConnection",
FullMethod: StreamService_CountStreamConnection_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(StreamServiceServer).CountStreamConnection(ctx, req.(*CountConnectionRequest))
@@ -126,7 +146,7 @@ func _StreamService_PushStream_Handler(srv interface{}, ctx context.Context, dec
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.StreamService/PushStream",
FullMethod: StreamService_PushStream_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(StreamServiceServer).PushStream(ctx, req.(*PushStreamRequest))
@@ -144,7 +164,7 @@ func _StreamService_PushStreamBatch_Handler(srv interface{}, ctx context.Context
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.StreamService/PushStreamBatch",
FullMethod: StreamService_PushStreamBatch_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(StreamServiceServer).PushStreamBatch(ctx, req.(*PushStreamBatchRequest))

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc v5.28.2
// protoc-gen-go v1.36.6
// protoc v5.29.3
// source: user.proto
package proto
@@ -11,6 +11,7 @@ import (
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
@@ -21,23 +22,21 @@ const (
)
type UserInfo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Language string `protobuf:"bytes,5,opt,name=language,proto3" json:"language,omitempty"`
PermNodes []byte `protobuf:"bytes,3,opt,name=perm_nodes,json=permNodes,proto3,oneof" json:"perm_nodes,omitempty"`
Metadata []byte `protobuf:"bytes,4,opt,name=metadata,proto3,oneof" json:"metadata,omitempty"`
unknownFields protoimpl.UnknownFields
Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
PermNodes []byte `protobuf:"bytes,3,opt,name=perm_nodes,json=permNodes,proto3,oneof" json:"perm_nodes,omitempty"`
Metadata []byte `protobuf:"bytes,4,opt,name=metadata,proto3,oneof" json:"metadata,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *UserInfo) Reset() {
*x = UserInfo{}
if protoimpl.UnsafeEnabled {
mi := &file_user_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_user_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *UserInfo) String() string {
@@ -48,7 +47,7 @@ func (*UserInfo) ProtoMessage() {}
func (x *UserInfo) ProtoReflect() protoreflect.Message {
mi := &file_user_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -77,6 +76,13 @@ func (x *UserInfo) GetName() string {
return ""
}
func (x *UserInfo) GetLanguage() string {
if x != nil {
return x.Language
}
return ""
}
func (x *UserInfo) GetPermNodes() []byte {
if x != nil {
return x.PermNodes
@@ -92,20 +98,17 @@ func (x *UserInfo) GetMetadata() []byte {
}
type MultipleUserInfo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
Data []*UserInfo `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
unknownFields protoimpl.UnknownFields
Data []*UserInfo `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *MultipleUserInfo) Reset() {
*x = MultipleUserInfo{}
if protoimpl.UnsafeEnabled {
mi := &file_user_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_user_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *MultipleUserInfo) String() string {
@@ -116,7 +119,7 @@ func (*MultipleUserInfo) ProtoMessage() {}
func (x *MultipleUserInfo) ProtoReflect() protoreflect.Message {
mi := &file_user_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -139,21 +142,18 @@ func (x *MultipleUserInfo) GetData() []*UserInfo {
}
type GetUserRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
UserId *uint64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3,oneof" json:"user_id,omitempty"`
Name *string `protobuf:"bytes,2,opt,name=name,proto3,oneof" json:"name,omitempty"`
unknownFields protoimpl.UnknownFields
UserId *uint64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3,oneof" json:"user_id,omitempty"`
Name *string `protobuf:"bytes,2,opt,name=name,proto3,oneof" json:"name,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *GetUserRequest) Reset() {
*x = GetUserRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_user_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_user_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetUserRequest) String() string {
@@ -164,7 +164,7 @@ func (*GetUserRequest) ProtoMessage() {}
func (x *GetUserRequest) ProtoReflect() protoreflect.Message {
mi := &file_user_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -194,20 +194,17 @@ func (x *GetUserRequest) GetName() string {
}
type ListUserRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
UserId []uint64 `protobuf:"varint,1,rep,packed,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
unknownFields protoimpl.UnknownFields
UserId []uint64 `protobuf:"varint,1,rep,packed,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *ListUserRequest) Reset() {
*x = ListUserRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_user_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_user_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListUserRequest) String() string {
@@ -218,7 +215,7 @@ func (*ListUserRequest) ProtoMessage() {}
func (x *ListUserRequest) ProtoReflect() protoreflect.Message {
mi := &file_user_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -241,22 +238,19 @@ func (x *ListUserRequest) GetUserId() []uint64 {
}
type ListUserRelativeRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
UserId uint64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Status int32 `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"`
IsRelated bool `protobuf:"varint,3,opt,name=is_related,json=isRelated,proto3" json:"is_related,omitempty"`
unknownFields protoimpl.UnknownFields
UserId uint64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Status int32 `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"`
IsRelated bool `protobuf:"varint,3,opt,name=is_related,json=isRelated,proto3" json:"is_related,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *ListUserRelativeRequest) Reset() {
*x = ListUserRelativeRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_user_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_user_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListUserRelativeRequest) String() string {
@@ -267,7 +261,7 @@ func (*ListUserRelativeRequest) ProtoMessage() {}
func (x *ListUserRelativeRequest) ProtoReflect() protoreflect.Message {
mi := &file_user_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -304,20 +298,17 @@ func (x *ListUserRelativeRequest) GetIsRelated() bool {
}
type ListUserRelativeResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
Data []*UserInfo `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
unknownFields protoimpl.UnknownFields
Data []*UserInfo `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
sizeCache protoimpl.SizeCache
}
func (x *ListUserRelativeResponse) Reset() {
*x = ListUserRelativeResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_user_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_user_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListUserRelativeResponse) String() string {
@@ -328,7 +319,7 @@ func (*ListUserRelativeResponse) ProtoMessage() {}
func (x *ListUserRelativeResponse) ProtoReflect() protoreflect.Message {
mi := &file_user_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@@ -352,72 +343,55 @@ func (x *ListUserRelativeResponse) GetData() []*UserInfo {
var File_user_proto protoreflect.FileDescriptor
var file_user_proto_rawDesc = []byte{
0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x22, 0x8f, 0x01, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f,
0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64,
0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
0x6e, 0x61, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x5f, 0x6e, 0x6f, 0x64,
0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x09, 0x70, 0x65, 0x72, 0x6d,
0x4e, 0x6f, 0x64, 0x65, 0x73, 0x88, 0x01, 0x01, 0x12, 0x1f, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61,
0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x01, 0x52, 0x08, 0x6d, 0x65,
0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x88, 0x01, 0x01, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x70, 0x65,
0x72, 0x6d, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x6d, 0x65, 0x74,
0x61, 0x64, 0x61, 0x74, 0x61, 0x22, 0x37, 0x0a, 0x10, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c,
0x65, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74,
0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x5c,
0x0a, 0x0e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x12, 0x1c, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
0x04, 0x48, 0x00, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x88, 0x01, 0x01, 0x12, 0x17,
0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x04,
0x6e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x75, 0x73, 0x65, 0x72,
0x5f, 0x69, 0x64, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x2a, 0x0a, 0x0f,
0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x04,
0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x69, 0x0a, 0x17, 0x4c, 0x69, 0x73, 0x74,
0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01,
0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06,
0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74,
0x61, 0x74, 0x75, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x73, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74,
0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x52, 0x65, 0x6c, 0x61,
0x74, 0x65, 0x64, 0x22, 0x3f, 0x0a, 0x18, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52,
0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04,
0x64, 0x61, 0x74, 0x61, 0x32, 0xd8, 0x01, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x12, 0x33, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12,
0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55,
0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x00, 0x12, 0x3d, 0x0a, 0x08, 0x4c, 0x69, 0x73,
0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69,
0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x55, 0x73,
0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x00, 0x12, 0x55, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74,
0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x12, 0x1e, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x6c,
0x61, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x6c,
0x61, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42,
0x09, 0x5a, 0x07, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
const file_user_proto_rawDesc = "" +
"\n" +
"\n" +
"user.proto\x12\x05proto\"\xab\x01\n" +
"\bUserInfo\x12\x0e\n" +
"\x02id\x18\x01 \x01(\x04R\x02id\x12\x12\n" +
"\x04name\x18\x02 \x01(\tR\x04name\x12\x1a\n" +
"\blanguage\x18\x05 \x01(\tR\blanguage\x12\"\n" +
"\n" +
"perm_nodes\x18\x03 \x01(\fH\x00R\tpermNodes\x88\x01\x01\x12\x1f\n" +
"\bmetadata\x18\x04 \x01(\fH\x01R\bmetadata\x88\x01\x01B\r\n" +
"\v_perm_nodesB\v\n" +
"\t_metadata\"7\n" +
"\x10MultipleUserInfo\x12#\n" +
"\x04data\x18\x01 \x03(\v2\x0f.proto.UserInfoR\x04data\"\\\n" +
"\x0eGetUserRequest\x12\x1c\n" +
"\auser_id\x18\x01 \x01(\x04H\x00R\x06userId\x88\x01\x01\x12\x17\n" +
"\x04name\x18\x02 \x01(\tH\x01R\x04name\x88\x01\x01B\n" +
"\n" +
"\b_user_idB\a\n" +
"\x05_name\"*\n" +
"\x0fListUserRequest\x12\x17\n" +
"\auser_id\x18\x01 \x03(\x04R\x06userId\"i\n" +
"\x17ListUserRelativeRequest\x12\x17\n" +
"\auser_id\x18\x01 \x01(\x04R\x06userId\x12\x16\n" +
"\x06status\x18\x02 \x01(\x05R\x06status\x12\x1d\n" +
"\n" +
"is_related\x18\x03 \x01(\bR\tisRelated\"?\n" +
"\x18ListUserRelativeResponse\x12#\n" +
"\x04data\x18\x01 \x03(\v2\x0f.proto.UserInfoR\x04data2\xd8\x01\n" +
"\vUserService\x123\n" +
"\aGetUser\x12\x15.proto.GetUserRequest\x1a\x0f.proto.UserInfo\"\x00\x12=\n" +
"\bListUser\x12\x16.proto.ListUserRequest\x1a\x17.proto.MultipleUserInfo\"\x00\x12U\n" +
"\x10ListUserRelative\x12\x1e.proto.ListUserRelativeRequest\x1a\x1f.proto.ListUserRelativeResponse\"\x00B\tZ\a.;protob\x06proto3"
var (
file_user_proto_rawDescOnce sync.Once
file_user_proto_rawDescData = file_user_proto_rawDesc
file_user_proto_rawDescData []byte
)
func file_user_proto_rawDescGZIP() []byte {
file_user_proto_rawDescOnce.Do(func() {
file_user_proto_rawDescData = protoimpl.X.CompressGZIP(file_user_proto_rawDescData)
file_user_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_user_proto_rawDesc), len(file_user_proto_rawDesc)))
})
return file_user_proto_rawDescData
}
var file_user_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_user_proto_goTypes = []interface{}{
var file_user_proto_goTypes = []any{
(*UserInfo)(nil), // 0: proto.UserInfo
(*MultipleUserInfo)(nil), // 1: proto.MultipleUserInfo
(*GetUserRequest)(nil), // 2: proto.GetUserRequest
@@ -446,87 +420,13 @@ func file_user_proto_init() {
if File_user_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_user_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UserInfo); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_user_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*MultipleUserInfo); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_user_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetUserRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_user_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListUserRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_user_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListUserRelativeRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_user_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListUserRelativeResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
file_user_proto_msgTypes[0].OneofWrappers = []interface{}{}
file_user_proto_msgTypes[2].OneofWrappers = []interface{}{}
file_user_proto_msgTypes[0].OneofWrappers = []any{}
file_user_proto_msgTypes[2].OneofWrappers = []any{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_user_proto_rawDesc,
RawDescriptor: unsafe.Slice(unsafe.StringData(file_user_proto_rawDesc), len(file_user_proto_rawDesc)),
NumEnums: 0,
NumMessages: 6,
NumExtensions: 0,
@@ -537,7 +437,6 @@ func file_user_proto_init() {
MessageInfos: file_user_proto_msgTypes,
}.Build()
File_user_proto = out.File
file_user_proto_rawDesc = nil
file_user_proto_goTypes = nil
file_user_proto_depIdxs = nil
}

View File

@@ -13,6 +13,7 @@ service UserService {
message UserInfo {
uint64 id = 1;
string name = 2;
string language = 5;
optional bytes perm_nodes = 3;
optional bytes metadata = 4;
}

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v5.28.2
// - protoc-gen-go-grpc v1.5.1
// - protoc v5.29.3
// source: user.proto
package proto
@@ -15,8 +15,14 @@ import (
// 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.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
UserService_GetUser_FullMethodName = "/proto.UserService/GetUser"
UserService_ListUser_FullMethodName = "/proto.UserService/ListUser"
UserService_ListUserRelative_FullMethodName = "/proto.UserService/ListUserRelative"
)
// UserServiceClient is the client API for UserService service.
//
@@ -36,8 +42,9 @@ func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient {
}
func (c *userServiceClient) GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*UserInfo, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(UserInfo)
err := c.cc.Invoke(ctx, "/proto.UserService/GetUser", in, out, opts...)
err := c.cc.Invoke(ctx, UserService_GetUser_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -45,8 +52,9 @@ func (c *userServiceClient) GetUser(ctx context.Context, in *GetUserRequest, opt
}
func (c *userServiceClient) ListUser(ctx context.Context, in *ListUserRequest, opts ...grpc.CallOption) (*MultipleUserInfo, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(MultipleUserInfo)
err := c.cc.Invoke(ctx, "/proto.UserService/ListUser", in, out, opts...)
err := c.cc.Invoke(ctx, UserService_ListUser_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -54,8 +62,9 @@ func (c *userServiceClient) ListUser(ctx context.Context, in *ListUserRequest, o
}
func (c *userServiceClient) ListUserRelative(ctx context.Context, in *ListUserRelativeRequest, opts ...grpc.CallOption) (*ListUserRelativeResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListUserRelativeResponse)
err := c.cc.Invoke(ctx, "/proto.UserService/ListUserRelative", in, out, opts...)
err := c.cc.Invoke(ctx, UserService_ListUserRelative_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
@@ -64,7 +73,7 @@ func (c *userServiceClient) ListUserRelative(ctx context.Context, in *ListUserRe
// UserServiceServer is the server API for UserService service.
// All implementations must embed UnimplementedUserServiceServer
// for forward compatibility
// for forward compatibility.
type UserServiceServer interface {
GetUser(context.Context, *GetUserRequest) (*UserInfo, error)
ListUser(context.Context, *ListUserRequest) (*MultipleUserInfo, error)
@@ -72,9 +81,12 @@ type UserServiceServer interface {
mustEmbedUnimplementedUserServiceServer()
}
// UnimplementedUserServiceServer must be embedded to have forward compatible implementations.
type UnimplementedUserServiceServer struct {
}
// UnimplementedUserServiceServer 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 UnimplementedUserServiceServer struct{}
func (UnimplementedUserServiceServer) GetUser(context.Context, *GetUserRequest) (*UserInfo, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetUser not implemented")
@@ -86,6 +98,7 @@ func (UnimplementedUserServiceServer) ListUserRelative(context.Context, *ListUse
return nil, status.Errorf(codes.Unimplemented, "method ListUserRelative not implemented")
}
func (UnimplementedUserServiceServer) mustEmbedUnimplementedUserServiceServer() {}
func (UnimplementedUserServiceServer) testEmbeddedByValue() {}
// UnsafeUserServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to UserServiceServer will
@@ -95,6 +108,13 @@ type UnsafeUserServiceServer interface {
}
func RegisterUserServiceServer(s grpc.ServiceRegistrar, srv UserServiceServer) {
// If the following call pancis, it indicates UnimplementedUserServiceServer 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(&UserService_ServiceDesc, srv)
}
@@ -108,7 +128,7 @@ func _UserService_GetUser_Handler(srv interface{}, ctx context.Context, dec func
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.UserService/GetUser",
FullMethod: UserService_GetUser_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).GetUser(ctx, req.(*GetUserRequest))
@@ -126,7 +146,7 @@ func _UserService_ListUser_Handler(srv interface{}, ctx context.Context, dec fun
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.UserService/ListUser",
FullMethod: UserService_ListUser_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).ListUser(ctx, req.(*ListUserRequest))
@@ -144,7 +164,7 @@ func _UserService_ListUserRelative_Handler(srv interface{}, ctx context.Context,
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.UserService/ListUserRelative",
FullMethod: UserService_ListUserRelative_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).ListUserRelative(ctx, req.(*ListUserRelativeRequest))

View File

@@ -2,6 +2,14 @@ bind = "0.0.0.0:8001"
grpc_bind = "0.0.0.0:7001"
domain = "localhost"
resources_endpoint = "https://api.sn.solsynth.dev/cgi/uc"
templates_dir = "./templates"
ip_block_path = "./ip_block.list"
rate_limit = 120
rate_limit_advance = 60
[debug]
database = false
print_routes = false
@@ -11,12 +19,24 @@ dsn = "host=localhost user=postgres dbname=postgres password=password port=5432
prefix = "sn_"
[mq]
addr = "localhost:4222"
addr = "nats.orb.local:4222"
[kv]
endpoints = ["localhost:2379"]
endpoints = ["etcd.orb.local:2379"]
[cache]
addr = "redis.orb.local:6379"
password = ""
[security]
public_key = "keys/public_key.pem"
internal_public_key = "keys/internal_public_key.pem"
internal_private_key = "keys/internal_private_key.pem"
[watchtower]
database_backups = "./backups"
[captcha]
provider = "turnstile"
api_key = ""
api_secret = ""

97
templates/captcha.tmpl Normal file
View File

@@ -0,0 +1,97 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Solar Network Captcha</title>
<link
href="https://fonts.googleapis.com/css2?family=Roboto+Mono&display=swap"
rel="stylesheet"
/>
<style>
body {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #2d2d2d;
font-family: "Roboto Mono", monospace;
color: #c9d1d9;
}
.parent {
padding: 20px;
max-width: 480px;
margin: 0 auto;
}
h2 {
font-size: 18px;
font-weight: 300;
color: #ffffff;
margin-bottom: 15px;
}
.footer {
margin-top: 20px;
font-size: 11px;
opacity: 0.6;
}
.footer-product {
font-size: 12px;
font-weight: bold;
margin-bottom: 5px;
opacity: 0.8;
}
</style>
<script
src="https://challenges.cloudflare.com/turnstile/v0/api.js"
async
defer
></script>
</head>
<body>
<div class="parent">
<div class="container">
<h1>reCaptcha</h1>
<div
class="cf-turnstile"
data-sitekey="{{ .ApiKey }}"
data-callback="onSuccess"
></div>
</div>
<div class="footer">
<div class="footer-product">Solar Network Captcha Gateway</div>
<a
href="https://solsynth.dev"
style="color: #c9d1d9; text-decoration: none"
>Solsynth LLC</a
>
&copy; 2025<br />
Powered by
<a href="https://www.cloudflare.com/turnstile/" style="color: #c9d1d9"
>Cloudflare Turnstile</a
>
<br />
Hosted by
<a
href="https://github.com/Solsynth/HyperNet.Nexus"
style="color: #c9d1d9"
>HyperNet.Nexus</a
>
</div>
</div>
<script>
function getQueryParam(name) {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get(name);
}
function onSuccess(token) {
window.parent.postMessage("captcha_tk=" + token, "*");
const redirectUri = getQueryParam("redirect_uri");
if (redirectUri) {
window.location.href = `${redirectUri}?captcha_tk=${encodeURIComponent(token)}`;
}
}
</script>
</body>
</html>

52
templates/meet.tmpl Normal file
View File

@@ -0,0 +1,52 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Solar Network Meet</title>
<link
href="https://fonts.googleapis.com/css2?family=Roboto+Mono&display=swap"
rel="stylesheet"
/>
<style>
body {
width: 100vw;
height: 100vh;
padding: 0;
margin: 0;
}
.container {
width: 100vw;
height: 100vh;
}
</style>
<script src='https://meet.element.io/external_api.js'></script>
</head>
<body>
<div class="parent">
<div class="container" id="meet">
</div>
</div>
<script>
function getQueryParam(name) {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get(name);
}
const node = document.querySelector('#meet');
const domain = 'meet.element.io';
const options = {
roomName: "{{ .RoomName }}",
width: '100%',
height: '100%',
parentNode: node,
userInfo: {
avatar: {{ .User.Avatar }},
displayName: "{{ .User.Nick }}"
}
};
const api = new JitsiMeetExternalAPI(domain, options)
</script>
</body>
</html>