diff --git a/.gitignore b/.gitignore index d89fb0f1..2f86e838 100644 --- a/.gitignore +++ b/.gitignore @@ -54,4 +54,6 @@ server/shopping-cart-confirmation/shopping-cart-confirmation server/upload/upload server/webset/webset -shared-state \ No newline at end of file +shared-state + +*.zip \ No newline at end of file diff --git a/fs_nacos_etc_pack.sh b/fs_nacos_etc_pack.sh new file mode 100755 index 00000000..6e8d6fcf --- /dev/null +++ b/fs_nacos_etc_pack.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +CURRENT_DIR=`pwd` +SOURCE_DIR="server" +TEMP_DIR="/tmp" +DEST_DIR="FS-SERVER-API" +ZIP_FILE="FS-SERVER-API.zip" + +mkdir -p $TEMP_DIR/$DEST_DIR + +# 查找并复制文件 +find "$SOURCE_DIR" -type d -name "etc" -exec sh -c 'cp "$0"/*.yaml "$1"' {} "$TEMP_DIR/$DEST_DIR" \; + +cd $TEMP_DIR +# 打包目标文件夹 +zip -r "$ZIP_FILE" "$DEST_DIR" + +#返回当前目录 +cd $CURRENT_DIR + +# 移动到当前目录 +mv "$TEMP_DIR/$ZIP_FILE" . + +# 清理临时文件夹 +rm "$TEMP_DIR/$DEST_DIR" -rf \ No newline at end of file diff --git a/go.mod b/go.mod index 01c94f65..8bf4cb92 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,7 @@ require ( github.com/gorilla/websocket v1.5.0 github.com/hashicorp/raft v1.5.0 github.com/lni/dragonboat/v4 v4.0.0-20230709075559-54497b9553be + github.com/nacos-group/nacos-sdk-go/v2 v2.2.3 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e github.com/streadway/amqp v1.1.0 @@ -31,14 +32,17 @@ require ( github.com/DataDog/zstd v1.4.5 // indirect github.com/HdrHistogram/hdrhistogram-go v1.1.2 // indirect github.com/VictoriaMetrics/metrics v1.18.1 // indirect + github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704 // indirect github.com/andybalholm/brotli v1.0.5 // indirect github.com/armon/go-metrics v0.4.1 // indirect + github.com/buger/jsonparser v1.1.1 // indirect github.com/cockroachdb/errors v1.9.0 // indirect github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f // indirect github.com/cockroachdb/pebble v0.0.0-20221207173255-0f086d933dac // indirect github.com/cockroachdb/redact v1.1.3 // indirect github.com/getsentry/sentry-go v0.12.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/mock v1.6.0 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.0.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect @@ -50,12 +54,15 @@ require ( github.com/hashicorp/golang-lru v0.5.1 // indirect github.com/hashicorp/memberlist v0.3.1 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.15.15 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/lni/goutils v1.3.1-0.20220604063047-388d67b4dbc4 // indirect github.com/lni/vfs v0.2.1-0.20220616104132-8852fd867376 // indirect github.com/miekg/dns v1.1.26 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pierrec/lz4/v4 v4.1.17 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/rogpeppe/go-internal v1.9.0 // indirect @@ -64,11 +71,18 @@ require ( github.com/valyala/fastrand v1.1.0 // indirect github.com/valyala/histogram v1.2.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.14.0 // indirect + go.uber.org/atomic v1.10.0 // indirect + go.uber.org/multierr v1.9.0 // indirect + go.uber.org/zap v1.24.0 // indirect golang.org/x/crypto v0.11.0 // indirect golang.org/x/exp v0.0.0-20230728194245-b0cb94b80691 // indirect + golang.org/x/sync v0.2.0 // indirect + golang.org/x/time v0.3.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect + gopkg.in/ini.v1 v1.66.2 // indirect + gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect ) require ( diff --git a/go.sum b/go.sum index 67d9f1b0..06dd5c40 100644 --- a/go.sum +++ b/go.sum @@ -41,6 +41,7 @@ github.com/474420502/random v0.4.1 h1:HUUyLXRWMijVb7CJoEC16f0aFQOW25Lkr80Mut6PoK github.com/474420502/requests v1.42.0 h1:aUj0rWhfldbOOlGHDIcqT9zgXEoSlK4IBmRF3LxI1+Y= github.com/474420502/requests v1.42.0/go.mod h1:2SCVzim0ONFYG09g/GrM7RTeJIC6qTyZfnohsjnG5C8= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a/go.mod h1:EFZQ978U7x8IRnstaskI3IysnWY5Ao3QgZUKOXlsAdw= @@ -69,6 +70,8 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a h1:HbKu58rmZpUGpz5+4FfNmIU+FmZg2P3Xaj2v2bfNWmk= github.com/alicebob/miniredis/v2 v2.30.4 h1:8S4/o1/KoUArAGbGwPxcwf0krlzceva2XVOSchFS7Eo= +github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704 h1:PpfENOj/vPfhhy9N2OFRjpue0hjM5XqAp2thFmkXXIk= +github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704/go.mod h1:RcDobYh8k5VP6TNybz9m++gL3ijVI5wueVr0EM10VsU= github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= @@ -79,10 +82,13 @@ github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+ github.com/aws/aws-sdk-go v1.44.295 h1:SGjU1+MqttXfRiWHD6WU0DRhaanJgAFY+xIhEaugV8Y= github.com/aws/aws-sdk-go v1.44.295/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= +github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= 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/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= +github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0= github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE= github.com/cenkalti/backoff/v4 v4.2.0 h1:HN5dHm3WBOgndBH6E8V0q2jIYIR3s9yglV8k/+MN3u4= @@ -202,6 +208,7 @@ github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXP github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM= +github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= @@ -220,6 +227,8 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +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.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -330,12 +339,16 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= @@ -413,11 +426,16 @@ github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKju github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/nacos-group/nacos-sdk-go/v2 v2.2.3 h1:sUQx4f1bXDeeOOEQZjGAitzxYApbYY9fVDbxVCaBW+I= +github.com/nacos-group/nacos-sdk-go/v2 v2.2.3/go.mod h1:UL4U89WYdnyajgKJUMpuT1Rr6iNmbjrxOO40JRgtA00= github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= github.com/nats-io/nats.go v1.8.1/go.mod h1:BrFz9vVn0fU3AcH9Vn4Kd7W0NpJ651tD5omQ3M8LwxM= github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= @@ -598,9 +616,15 @@ go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+go go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.19.0 h1:IVN6GR+mhC4s5yfcTbmzHYODqvWAp3ZedA2SJPI1Nnw= go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= +go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= +go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/automaxprocs v1.5.2 h1:2LxUOGiR3O6tw8ui5sZa2LAaHnsviZdVOUZw4fvbnME= go.uber.org/automaxprocs v1.5.2/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0= go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= +go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= +go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= +go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= +go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -721,6 +745,7 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= +golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -798,6 +823,8 @@ golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -847,6 +874,7 @@ golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= 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/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -969,7 +997,11 @@ gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8 gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY= gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI= +gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= +gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= +gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/goctl_template/api/etc.tpl b/goctl_template/api/etc.tpl index 86e74e0a..c2409e1f 100644 --- a/goctl_template/api/etc.tpl +++ b/goctl_template/api/etc.tpl @@ -3,7 +3,7 @@ Host: {{.host}} Port: {{.port}} Timeout: 15000 #服务超时时间(毫秒) SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen -SourceRabbitMq: amqp://rabbit001:rabbit001129@110.41.19.98:5672 +SourceRabbitMq: "" Auth: AccessSecret: fusen2023 AccessExpire: 2592000 diff --git a/server/auth/internal/logic/websocket_test.go b/server/auth/internal/logic/websocket_test.go index c74a5736..17f6ba2a 100644 --- a/server/auth/internal/logic/websocket_test.go +++ b/server/auth/internal/logic/websocket_test.go @@ -143,7 +143,7 @@ func TestSql(t *testing.T) { } conn := initalize.InitMysql("fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen") - log.Println(conn.Model(&gmodel.FsUser{})) + log.Println() log.Println(conn.NamingStrategy.TableName(reflect.TypeOf(gmodel.FsUser{}).Name())) updatesql := `UPDATE %s diff --git a/server/base/etc/base.yaml b/server/base/etc/base.yaml index 4de0596c..36054478 100644 --- a/server/base/etc/base.yaml +++ b/server/base/etc/base.yaml @@ -10,4 +10,4 @@ Auth: AccessSecret: fusen2023 AccessExpire: 2592000 RefreshAfter: 1592000 -SourceRabbitMq: "amqp://rabbit001:rabbit001129@110.41.19.98:5672" \ No newline at end of file +SourceRabbitMq: "" \ No newline at end of file diff --git a/server/info/etc/info.yaml b/server/info/etc/info.yaml index 24d7b2ad..3fa5aea3 100644 --- a/server/info/etc/info.yaml +++ b/server/info/etc/info.yaml @@ -4,7 +4,7 @@ Port: 9988 Timeout: 15000 #服务超时时间(毫秒) ReplicaId: 200 SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen -SourceRabbitMq: amqp://rabbit001:rabbit001129@110.41.19.98:5672 +SourceRabbitMq: Log: Stat: false Auth: diff --git a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go index c0384d90..828f3ab5 100644 --- a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go +++ b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go @@ -36,6 +36,16 @@ func NewGetProductTemplateTagsLogic(ctx context.Context, svcCtx *svc.ServiceCont // func (l *GetProductTemplateTagsLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) { // // httpx.OkJsonCtx(r.Context(), w, resp) // } +type logoSelect struct { + LogoSelected struct { + LogoSelectedId int `json:"logo_selected_id"` + TemplateTagSelected struct { + TemplateTag string `json:"template_tag"` + Color [][]string `json:"color"` + SelectedIndex int `json:"selected_index"` + } `json:"template_tag_selected"` + } `json:"logo_selected"` +} func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProductTemplateTagsReq, userinfo *auth.UserInfo) (resp *basic.Response) { if req.Limit <= 0 || req.Limit > 100 { @@ -54,34 +64,45 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu logx.Error(err) return } - var colors interface{} if logoInfo.Metadata == nil || *logoInfo.Metadata == "" { - // 返回固定模板A1a - productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTagNames(l.ctx, []string{"A1"}, req.Limit, 1, "`id` DESC") - if err != nil { + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "logo info`s metadata is not set") + } + //解析用户素材元数据 + var metaData map[string]interface{} + if err = json.Unmarshal([]byte(*logoInfo.Metadata), &metaData); err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse user metadata") + } + var mapTemplateTag map[string][][]string + b, _ := json.Marshal(metaData["template_tag"]) + if err = json.Unmarshal(b, &mapTemplateTag); err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeJsonErr, "invalid format of metadata`s template_tag") + } + //从用户元数据获取选中的颜色数据 + mapSelectColor := make(map[string]int) //key是模板标签val是选中的索引 + if logoInfo.UserInfoMetadata != nil && *logoInfo.UserInfoMetadata != "" { + //解析用户信息元数据 + var logoSelectInfo logoSelect + if err = json.Unmarshal([]byte(*logoInfo.UserInfoMetadata), &logoSelectInfo); err != nil { logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template tags") + return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse user info metadata") } - } else { - //解析元数据 - var metaData map[string]interface{} - if err = json.Unmarshal([]byte(*logoInfo.Metadata), &metaData); err != nil { - logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse user metadata") - } - colors = metaData["colors"] - var templateTagNameList []string - b, _ := json.Marshal(metaData["template_tagid"]) - if err = json.Unmarshal(b, &templateTagNameList); err != nil { - logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeJsonErr, "invalid format of metadata`s template_tagid") - } - productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTagNames(l.ctx, templateTagNameList, req.Limit, 1, "id DESC") - if err != nil { - logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template tags") + //设置选中 + key := logoSelectInfo.LogoSelected.TemplateTagSelected.TemplateTag + if _, ok := mapTemplateTag[key]; ok { + mapSelectColor[key] = logoSelectInfo.LogoSelected.TemplateTagSelected.SelectedIndex } } + var templateTagNameList []string + for templateTag, _ := range mapTemplateTag { + templateTagNameList = append(templateTagNameList, templateTag) + } + productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTagNames(l.ctx, templateTagNameList, req.Limit, 1, "id DESC") + if err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template tags") + } //资源id集合 resourceIds := make([]string, 0, 5) for _, v := range productTemplateTags { @@ -102,13 +123,24 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu mapResourceMetadata[*v.ResourceUrl] = metadata } list := make([]types.GetProductTemplateTagsRsp, 0, len(productTemplateTags)) - for _, v := range productTemplateTags { + for _, templateInfo := range productTemplateTags { + colors := make([]types.ColorsItem, 0, 10) + SelectedIndex := 0 + for _, colorsSet := range mapTemplateTag[*templateInfo.TemplateTag] { + if selectIndex, ok := mapSelectColor[*templateInfo.TemplateTag]; ok { + SelectedIndex = selectIndex + } + colors = append(colors, types.ColorsItem{ + Color: colorsSet, + }) + } list = append(list, types.GetProductTemplateTagsRsp{ - Id: v.Id, - TemplateTag: *v.TemplateTag, - Cover: *v.Cover, - CoverMetadata: mapResourceMetadata[*v.Cover], + Id: templateInfo.Id, + TemplateTag: *templateInfo.TemplateTag, + Cover: *templateInfo.Cover, + CoverMetadata: mapResourceMetadata[*templateInfo.Cover], Colors: colors, + SelectedIndex: SelectedIndex, }) } return resp.SetStatusWithMessage(basic.CodeOK, "success", list) diff --git a/server/product-template-tag/internal/types/types.go b/server/product-template-tag/internal/types/types.go index e81cb040..7474e8da 100644 --- a/server/product-template-tag/internal/types/types.go +++ b/server/product-template-tag/internal/types/types.go @@ -10,11 +10,16 @@ type GetProductTemplateTagsReq struct { } type GetProductTemplateTagsRsp struct { - Id int64 `json:"id"` - TemplateTag string `json:"template_tag"` - Cover string `json:"cover"` - CoverMetadata interface{} `json:"cover_metadata"` - Colors interface{} `json:"colors"` + Id int64 `json:"id"` + TemplateTag string `json:"template_tag"` + Cover string `json:"cover"` + CoverMetadata interface{} `json:"cover_metadata"` + Colors []ColorsItem `json:"colors"` + SelectedIndex int `json:"selected_index"` +} + +type ColorsItem struct { + Color []string `json:"color"` } type Request struct { diff --git a/server/resource/etc/resource.yaml b/server/resource/etc/resource.yaml index e03a9f70..3353fd9f 100644 --- a/server/resource/etc/resource.yaml +++ b/server/resource/etc/resource.yaml @@ -10,7 +10,7 @@ Auth: AccessSecret: fusen2023 AccessExpire: 2592000 RefreshAfter: 1592000 -SourceRabbitMq: "amqp://rabbit001:rabbit001129@110.41.19.98:5672" +SourceRabbitMq: "" AWS: S3: Credentials: diff --git a/server/shopping-cart/etc/shopping-cart.yaml b/server/shopping-cart/etc/shopping-cart.yaml index 2b0db3dd..2fb861be 100644 --- a/server/shopping-cart/etc/shopping-cart.yaml +++ b/server/shopping-cart/etc/shopping-cart.yaml @@ -3,7 +3,7 @@ Host: 0.0.0.0 Port: 9918 Timeout: 15000 #服务超时时间(毫秒) SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen -SourceRabbitMq: amqp://rabbit001:rabbit001129@110.41.19.98:5672 +SourceRabbitMq: Log: Stat: false Auth: diff --git a/server/websocket/etc/websocket.yaml b/server/websocket/etc/websocket.yaml index e7b4197d..85f9ed0b 100644 --- a/server/websocket/etc/websocket.yaml +++ b/server/websocket/etc/websocket.yaml @@ -12,7 +12,7 @@ Auth: AccessSecret: fusen2023 AccessExpire: 2592000 RefreshAfter: 1592000 -SourceRabbitMq: "amqp://rabbit001:rabbit001129@110.41.19.98:5672" +SourceRabbitMq: "" AWS: S3: Credentials: diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 9c7f1548..65a3121c 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -195,9 +195,9 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo *auth.Use guestId: userInfo.GuestId, extendRenderProperty: extendRenderProperty{ //renderImageTask: make(map[string]*renderTask), - renderImageTaskCtlChan: make(chan renderImageControlChanItem, renderImageTaskCtlChanLen), - renderChan: make(chan []byte, renderChanLen), - renderConsumeTickTime: 1, //默认1纳秒,后面需要根据不同用户不同触发速度 + //renderImageTaskCtlChan: make(chan renderImageControlChanItem, renderImageTaskCtlChanLen), + renderChan: make(chan []byte, renderChanLen), + renderConsumeTickTime: 1, //默认1纳秒,后面需要根据不同用户不同触发速度 }, } //保存连接 diff --git a/server/websocket/internal/logic/ws_allocation_processing_factory.go b/server/websocket/internal/logic/ws_allocation_processing_factory.go index 18cce02b..68cf7e49 100644 --- a/server/websocket/internal/logic/ws_allocation_processing_factory.go +++ b/server/websocket/internal/logic/ws_allocation_processing_factory.go @@ -6,6 +6,7 @@ import ( // 消息分发工厂 type allocationProcessorFactory interface { + //分配数据到缓冲队列 allocationMessage(w *wsConnectItem, data []byte) } diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index 3b1f6c28..a8f86d2f 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -33,27 +33,27 @@ type renderProcessor struct { // 云渲染属性 type extendRenderProperty struct { //renderImageTask map[string]*renderTask //需要渲染的图片任务 key是taskId val 是renderId - renderImageTaskCtlChan chan renderImageControlChanItem //渲染任务新增/回调结果移除任务/更新渲染耗时属性的控制通道(由于任务map无法读写并发) - renderChan chan []byte //渲染消息入口的缓冲队列 - renderConsumeTickTime time.Duration //消费渲染消息时钟间隔(纳秒),用于后期控制不同类型用户渲染速度限制 + //renderImageTaskCtlChan chan renderImageControlChanItem //渲染任务新增/回调结果移除任务/更新渲染耗时属性的控制通道(由于任务map无法读写并发) + renderChan chan []byte //渲染消息入口的缓冲队列 + renderConsumeTickTime time.Duration //消费渲染消息时钟间隔(纳秒),用于后期控制不同类型用户渲染速度限制 } // 渲染任务新增移除的控制通道的数据 -type renderImageControlChanItem struct { +/*type renderImageControlChanItem struct { option int // 0删除 1添加 2修改耗时属性 taskId string //map的key(必须传) renderId string // map的val(增加任务时候传) renderNotifyImageUrl string //渲染回调数据(删除任务时候传) taskProperty renderTask //渲染任务的属性 -} +}*/ // 渲染任务属性 -type renderTask struct { +/*type renderTask struct { renderId string //渲染id(新增任务传) unityRenderBeginTime int64 //发送给unity时间 unityRenderEndTime int64 //unity回调结果时间 uploadUnityRenderImageTakesTime int64 //上传unity渲染结果图时间 -} +}*/ // 处理分发到这里的数据 func (r *renderProcessor) allocationMessage(w *wsConnectItem, data []byte) { @@ -96,7 +96,7 @@ func (w *wsConnectItem) renderImage(data []byte) { //logx.Info("消费渲染数据:", string(data)) var renderImageData websocket_data.RenderImageReqMsg if err := json.Unmarshal(data, &renderImageData); err != nil { - w.incomeDataFormatErrResponse("invalid format of render data:" + string(data)) + w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "数据格式错误", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0) logx.Error("invalid format of websocket render image message", err) return } diff --git a/server_api/product-template-tag.api b/server_api/product-template-tag.api index d663e109..6c88a573 100644 --- a/server_api/product-template-tag.api +++ b/server_api/product-template-tag.api @@ -20,9 +20,13 @@ type GetProductTemplateTagsReq { Limit int `form:"limit"` } type GetProductTemplateTagsRsp { - Id int64 `json:"id"` - TemplateTag string `json:"template_tag"` - Cover string `json:"cover"` - CoverMetadata interface{} `json:"cover_metadata"` - Colors interface{} `json:"colors"` + Id int64 `json:"id"` + TemplateTag string `json:"template_tag"` + Cover string `json:"cover"` + CoverMetadata interface{} `json:"cover_metadata"` + Colors []ColorsItem `json:"colors"` + SelectedIndex int `json:"selected_index"` +} +type ColorsItem { + Color []string `json:"color"` } \ No newline at end of file diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index a18c70de..642f590d 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -54,15 +54,16 @@ type ( GuestId int64 `json:"guest_id"` } LogoInfoRes struct { - Metadata *string `json:"metadata"` - LogoUrl *string `json:"logo_url"` + Metadata *string `json:"metadata"` + LogoUrl *string `json:"logo_url"` + UserInfoMetadata *string `json:"user_info_metadata"` } ) func (l *defaultImageHandle) LogoInfo(ctx context.Context, in *LogoInfoReq) (*LogoInfoRes, error) { var metadata *string var logoUrl *string - + var userInfoMetadata *string // 更新用户信息 var module = "profile" userInfoGorm := l.MysqlConn.Where("module = ?", module) @@ -82,6 +83,10 @@ func (l *defaultImageHandle) LogoInfo(ctx context.Context, in *LogoInfoReq) (*Lo return nil, err } } + if userInfo.Id != 0 { + tmp := string(*userInfo.Metadata) + userInfoMetadata = &tmp + } var userMaterialInfo gmodel.FsUserMaterial userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn) @@ -134,8 +139,9 @@ func (l *defaultImageHandle) LogoInfo(ctx context.Context, in *LogoInfoReq) (*Lo logoUrl = userMaterialInfo.ResourceUrl } return &LogoInfoRes{ - Metadata: metadata, - LogoUrl: logoUrl, + Metadata: metadata, + LogoUrl: logoUrl, + UserInfoMetadata: userInfoMetadata, }, nil } @@ -302,6 +308,7 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq combineParam["phone"] = in.Phone combineParam["address"] = in.Address combineParam["qrcode"] = in.Qrcode + //combineParam["template_tag_selected"] = var postMap = make(map[string]interface{}, 2) postMap["module_data"] = moduleDataMap diff --git a/utils/fsconfig/.gitignore b/utils/fsconfig/.gitignore new file mode 100644 index 00000000..fbf828d6 --- /dev/null +++ b/utils/fsconfig/.gitignore @@ -0,0 +1 @@ +log \ No newline at end of file diff --git a/utils/fsconfig/config.go b/utils/fsconfig/config.go new file mode 100644 index 00000000..116043dc --- /dev/null +++ b/utils/fsconfig/config.go @@ -0,0 +1,53 @@ +package fsconfig + +import ( + "fmt" + "log" + "os" + + "gopkg.in/yaml.v2" +) + +type EnvConfig struct { + Host string `yaml:"host"` + Port uint64 `yaml:"port"` + + UserName string `yaml:"username"` + Password string `yaml:"password"` + NamespaceId string `yaml:"namespace"` + DataId string `yaml:"dataid"` + Group string `yaml:"group"` +} + +var OptPathDir = "/opt" + +var nacosConfig *EnvConfig + +func GetEnvCofing() *EnvConfig { + return nacosConfig +} + +func init() { + if OptPathDir[len(OptPathDir)-1] != '/' { + OptPathDir = OptPathDir + "/" + } + + for _, yname := range []string{"env.yaml", "env.yml"} { + f, err := os.Open(OptPathDir + "/" + yname) + if err != nil { + log.Println(err) + continue + } + cfg := &EnvConfig{} + err = yaml.NewDecoder(f).Decode(&cfg) + if err != nil { + log.Println(err) + continue + } + + nacosConfig = cfg + return + } + + panic(fmt.Sprintf("can't find %s(env.yaml|env.yml) ", OptPathDir)) +} diff --git a/utils/fsconfig/config_test.go b/utils/fsconfig/config_test.go new file mode 100644 index 00000000..f285c6bb --- /dev/null +++ b/utils/fsconfig/config_test.go @@ -0,0 +1,70 @@ +package fsconfig_test + +import ( + "fusenapi/utils/fsconfig" + "log" + "testing" + + "github.com/nacos-group/nacos-sdk-go/v2/clients" + "github.com/nacos-group/nacos-sdk-go/v2/common/constant" + "github.com/nacos-group/nacos-sdk-go/v2/vo" +) + +func TestCase1(t *testing.T) { + + env := fsconfig.GetEnvCofing() + + // 创建serverConfig + // 支持多个;至少一个ServerConfig + serverConfig := []constant.ServerConfig{ + { + IpAddr: env.Host, + Port: uint64(env.Port), + }, + } + + // 创建clientConfig + clientConfig := constant.ClientConfig{ + NamespaceId: env.NamespaceId, // 如果需要支持多namespace,我们可以场景多个client,它们有不同的NamespaceId。当namespace是public时,此处填空字符串。 + TimeoutMs: 50000, + NotLoadCacheAtStart: true, + LogLevel: "debug", + LogDir: "/tmp/nacos", + CacheDir: "/tmp/nacos", + Username: env.UserName, + Password: env.Password, + } + + // 创建服务发现客户端的另一种方式 (推荐) + // namingClient, err := clients.NewNamingClient( + // vo.NacosClientParam{ + // ClientConfig: &clientConfig, + // ServerConfigs: serverConfig, + // }, + // ) + // if err != nil { + // log.Fatalf("初始化nacos失败: %s", err.Error()) + // } + + // log.Println(namingClient) + + // 创建 Nacos 配置客户端 + configClient, err := clients.CreateConfigClient(map[string]interface{}{ + "clientConfig": clientConfig, + "serverConfigs": serverConfig, + }) + if err != nil { + log.Fatalf("Failed to create Nacos config client: %v", err) + } + + // 获取配置 + content, err := configClient.GetConfig(vo.ConfigParam{ + DataId: "auth.yaml", + Group: env.Group, + }) + if err != nil { + log.Fatalf("Failed to get config from Nacos: %v", err) + } + log.Println(content) + +}