diff --git a/cmd/fibr/fibr.go b/cmd/fibr/fibr.go index d8dac7bc..73e1fce9 100644 --- a/cmd/fibr/fibr.go +++ b/cmd/fibr/fibr.go @@ -120,16 +120,17 @@ func main() { fibrApp := fibr.New(&crudApp, rendererApp, shareApp, webhookApp, middlewareApp) handler := rendererApp.Handler(fibrApp.TemplateFunc) - ctx := context.Background() - - go amqpThumbnailApp.Start(ctx, client.health.Done()) - go amqpExifApp.Start(ctx, client.health.Done()) - go amqpShareApp.Start(ctx, client.health.Done()) - go amqpWebhookApp.Start(ctx, client.health.Done()) - go webhookApp.Start(client.health.Done()) - go shareApp.Start(client.health.Done()) - go crudApp.Start(client.health.Done()) - go eventBus.Start(client.health.Done(), storageProvider, []provider.Renamer{thumbnailApp.Rename, exifApp.Rename}, shareApp.EventConsumer, thumbnailApp.EventConsumer, exifApp.EventConsumer, webhookApp.EventConsumer) + amqpCtx := context.Background() + ctx := client.health.Context() + + go amqpThumbnailApp.Start(amqpCtx, client.health.Done()) + go amqpExifApp.Start(amqpCtx, client.health.Done()) + go amqpShareApp.Start(amqpCtx, client.health.Done()) + go amqpWebhookApp.Start(amqpCtx, client.health.Done()) + go webhookApp.Start(ctx) + go shareApp.Start(ctx) + go crudApp.Start(ctx) + go eventBus.Start(ctx, storageProvider, []provider.Renamer{thumbnailApp.Rename, exifApp.Rename}, shareApp.EventConsumer, thumbnailApp.EventConsumer, exifApp.EventConsumer, webhookApp.EventConsumer) go promServer.Start("prometheus", client.health.End(), client.prometheus.Handler()) go appServer.Start("http", client.health.End(), httputils.Handler(handler, client.health, recoverer.Middleware, client.prometheus.Middleware, client.tracer.Middleware, owasp.New(config.owasp).Middleware)) diff --git a/go.mod b/go.mod index e5017268..df812e48 100644 --- a/go.mod +++ b/go.mod @@ -3,19 +3,19 @@ module github.com/ViBiOh/fibr go 1.19 require ( - github.com/ViBiOh/ChatPotte v0.2.14 - github.com/ViBiOh/absto v1.0.5 - github.com/ViBiOh/auth/v2 v2.14.10 - github.com/ViBiOh/exas v0.5.2 + github.com/ViBiOh/ChatPotte v0.2.15 + github.com/ViBiOh/absto v1.0.6 + github.com/ViBiOh/auth/v2 v2.14.11 + github.com/ViBiOh/exas v0.5.3 github.com/ViBiOh/flags v1.2.0 - github.com/ViBiOh/httputils/v4 v4.47.9 - github.com/ViBiOh/vith v0.5.2 + github.com/ViBiOh/httputils/v4 v4.48.0 + github.com/ViBiOh/vith v0.5.3 github.com/golang/mock v1.6.0 github.com/prometheus/client_golang v1.13.0 github.com/streadway/amqp v1.0.0 go.opentelemetry.io/otel v1.10.0 go.opentelemetry.io/otel/trace v1.10.0 - golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 + golang.org/x/crypto v0.0.0-20220924013350-4ba4fb4dd9e7 golang.org/x/text v0.3.7 ) @@ -31,11 +31,11 @@ require ( github.com/golang/protobuf v1.5.2 // indirect github.com/google/uuid v1.3.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.15.9 // indirect + github.com/klauspost/compress v1.15.10 // indirect github.com/klauspost/cpuid/v2 v2.1.1 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/minio/md5-simd v1.1.2 // indirect - github.com/minio/minio-go/v7 v7.0.36 // indirect + github.com/minio/minio-go/v7 v7.0.37 // indirect github.com/minio/sha256-simd v1.0.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect @@ -46,13 +46,13 @@ require ( github.com/sirupsen/logrus v1.9.0 // indirect github.com/tdewolff/minify/v2 v2.12.1 // indirect github.com/tdewolff/parse/v2 v2.6.3 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.35.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.36.0 // indirect go.opentelemetry.io/otel/exporters/jaeger v1.10.0 // indirect - go.opentelemetry.io/otel/metric v0.31.0 // indirect + go.opentelemetry.io/otel/metric v0.32.0 // indirect go.opentelemetry.io/otel/sdk v1.10.0 // indirect - golang.org/x/net v0.0.0-20220909164309-bea034e7d591 // indirect - golang.org/x/sys v0.0.0-20220913175220-63ea55921009 // indirect - golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 // indirect + golang.org/x/net v0.0.0-20220921203646-d300de134e69 // indirect + golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 // indirect + golang.org/x/term v0.0.0-20220919170432-7a66f970e087 // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) diff --git a/go.sum b/go.sum index 8afb5a70..72ff881e 100644 --- a/go.sum +++ b/go.sum @@ -33,20 +33,20 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= 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/ViBiOh/ChatPotte v0.2.14 h1:P/u2yx6R1paDWVhPzu2IRj7OiQrnr9AFV9CFqTEKmOo= -github.com/ViBiOh/ChatPotte v0.2.14/go.mod h1:lwOYt7xyhG9bcdUdxYaOBN59Owcc8GyM+M1xs9/Qntw= -github.com/ViBiOh/absto v1.0.5 h1:S1QwKW9FUieYKuYOb7RrKqo0t7O40GSL2FdlYwXK3kQ= -github.com/ViBiOh/absto v1.0.5/go.mod h1:0+iBxmam48r3lMeMtU0lL7yHsAdGkcHeS644b31GlLk= -github.com/ViBiOh/auth/v2 v2.14.10 h1:R8S8RRx6dUB8k1daCE4nyrMic5bBBJQLRGvRfeBrCKs= -github.com/ViBiOh/auth/v2 v2.14.10/go.mod h1:sVyWtW3Vw6VbusIMh1JHJ4vMAzZoQ8a/bw8tl/r8Q/I= -github.com/ViBiOh/exas v0.5.2 h1:h+BRP8Q3Tr1aL495i0bDnGtpFLlCgWTT2YIOX8X7RBo= -github.com/ViBiOh/exas v0.5.2/go.mod h1:CaqjlqJiS3G+Gft/7BOlKbC7xQsW8hMSvjRFIWcjPB0= +github.com/ViBiOh/ChatPotte v0.2.15 h1:z8dxNa4Dmbpv18N4ZmoXRo8kvoINce+QrMefqIiqjFw= +github.com/ViBiOh/ChatPotte v0.2.15/go.mod h1:IUBJSHIN41yBNO70X05HDJVoyUO+aI86JwvrMPSr7wM= +github.com/ViBiOh/absto v1.0.6 h1:frlTUMgdL1qBCyKTGf3vlxulv8EUgYv2UE3/BylXNQc= +github.com/ViBiOh/absto v1.0.6/go.mod h1:phPe9zo3ecMrtUMFVFBeGS71qMTzluFZje/qYb7msHI= +github.com/ViBiOh/auth/v2 v2.14.11 h1:Bjh1CvBiTVAts0IbuqrPsRRHuUazNwMxtHDdPI60+UE= +github.com/ViBiOh/auth/v2 v2.14.11/go.mod h1:/gJvnWanGMh9puScqVaY2aOlHHwU/15oDjeZOEMRO48= +github.com/ViBiOh/exas v0.5.3 h1:Y1kNfLBIK6FSGs467OoMvwrOaz4KgDYanbjZeVeJImQ= +github.com/ViBiOh/exas v0.5.3/go.mod h1:7ZUMMD7pbNNnpagtK8YrS0ks/X/05w2MR4dweAc5N18= github.com/ViBiOh/flags v1.2.0 h1:DaujjNXzD29KxKyp4eZdn7c9+uBN5DokWgDAe7DcUmc= github.com/ViBiOh/flags v1.2.0/go.mod h1:UyMB5zeD/aId7Xw3x7577ZNU298JmukzOcV8p/H2W1s= -github.com/ViBiOh/httputils/v4 v4.47.9 h1:lEhwUZI0ioFMwzVkuNZyDVu0IrxuOT9adwOUUy1NnEQ= -github.com/ViBiOh/httputils/v4 v4.47.9/go.mod h1:B31MGYvRLxCarxA3onkKE7DLGAlFzvx2gpWjSmbHUK8= -github.com/ViBiOh/vith v0.5.2 h1:fQh0kLjQALglfbbKGWjw3Tlt4tdN2LHMbe7txynuc48= -github.com/ViBiOh/vith v0.5.2/go.mod h1:fnE4gx85IArbQd64ZUiiGM0JNCJ+1+Fc2MPzHxuxUkA= +github.com/ViBiOh/httputils/v4 v4.48.0 h1:KySMrx2rJTEsJI6SNJDlU2m7zQt16f3Q2BfKEgdLbtU= +github.com/ViBiOh/httputils/v4 v4.48.0/go.mod h1:XcA+8YmzJ7r/VjmtrIDuM1yXdlgpL8SoT7ywmuC87j8= +github.com/ViBiOh/vith v0.5.3 h1:TmVJx4lM6FdEMaAx8rMbgoqSYjRmWz8rlkvpu2pTGyc= +github.com/ViBiOh/vith v0.5.3/go.mod h1:Ww5gkhRgGNaUBTamMyAV7n6qktjKuSjBAT7C4Z95JfU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -181,8 +181,8 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY= -github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= +github.com/klauspost/compress v1.15.10 h1:Ai8UzuomSCDw90e1qNMtb15msBXsNpH6gzkkENQNcJo= +github.com/klauspost/compress v1.15.10/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.1.1 h1:t0wUqjowdm8ezddV5k0tLWVklVuvLJpoHeb4WBdydm0= @@ -198,8 +198,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0j github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= -github.com/minio/minio-go/v7 v7.0.36 h1:KPzAl8C6jcRFEUsGUHR6deRivvKATPNZThzi7D9y/sc= -github.com/minio/minio-go/v7 v7.0.36/go.mod h1:nCrRzjoSUQh8hgKKtu3Y708OLvRLtuASMg2/nvmbarw= +github.com/minio/minio-go/v7 v7.0.37 h1:aJvYMbtpVPSFBck6guyvOkxK03MycxDOCs49ZBuY5M8= +github.com/minio/minio-go/v7 v7.0.37/go.mod h1:nCrRzjoSUQh8hgKKtu3Y708OLvRLtuASMg2/nvmbarw= github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g= github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -278,14 +278,14 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.35.0 h1:Ajldaqhxqw/gNzQA45IKFWLdG7jZuXX/wBW1d5qvbUI= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.35.0/go.mod h1:9NiG9I2aHTKkcxqCILhjtyNA1QEiCjdBACv4IvrFQ+c= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.36.0 h1:qZ3KzA4qPzLBDtQyPk4ydjlg8zvXbNysnFHaVMKJbVo= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.36.0/go.mod h1:14Oo79mRwusSI02L0EfG3Gp1uF3+1wSL+D4zDysxyqs= go.opentelemetry.io/otel v1.10.0 h1:Y7DTJMR6zs1xkS/upamJYk0SxxN4C9AqRd77jmZnyY4= go.opentelemetry.io/otel v1.10.0/go.mod h1:NbvWjCthWHKBEUMpf0/v8ZRZlni86PpGFEMA9pnQSnQ= go.opentelemetry.io/otel/exporters/jaeger v1.10.0 h1:7W3aVVjEYayu/GOqOVF4mbTvnCuxF1wWu3eRxFGQXvw= go.opentelemetry.io/otel/exporters/jaeger v1.10.0/go.mod h1:n9IGyx0fgyXXZ/i0foLHNxtET9CzXHzZeKCucvRBFgA= -go.opentelemetry.io/otel/metric v0.31.0 h1:6SiklT+gfWAwWUR0meEMxQBtihpiEs4c+vL9spDTqUs= -go.opentelemetry.io/otel/metric v0.31.0/go.mod h1:ohmwj9KTSIeBnDBm/ZwH2PSZxZzoOaG2xZeekTRzL5A= +go.opentelemetry.io/otel/metric v0.32.0 h1:lh5KMDB8xlMM4kwE38vlZJ3rZeiWrjw3As1vclfC01k= +go.opentelemetry.io/otel/metric v0.32.0/go.mod h1:PVDNTt297p8ehm949jsIzd+Z2bIZJYQQG/uuHTeWFHY= go.opentelemetry.io/otel/sdk v1.10.0 h1:jZ6K7sVn04kk/3DNUdJ4mqRlGDiXAVuIG+MMENpTNdY= go.opentelemetry.io/otel/sdk v1.10.0/go.mod h1:vO06iKzD5baltJz1zarxMCNHFpUlUiOy4s65ECtn6kE= go.opentelemetry.io/otel/trace v1.10.0 h1:npQMbR8o7mum8uF95yFbOEJffhs1sbCOfDh8zAJiH5E= @@ -296,8 +296,8 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 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.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= -golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220924013350-4ba4fb4dd9e7 h1:WJywXQVIb56P2kAvXeMGTIgQ1ZHQxR60+F9dLsodECc= +golang.org/x/crypto v0.0.0-20220924013350-4ba4fb4dd9e7/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -361,8 +361,8 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220909164309-bea034e7d591 h1:D0B/7al0LLrVC8aWF4+oxpv/m8bc7ViFfVS8/gXGdqI= -golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.0.0-20220921203646-d300de134e69 h1:hUJpGDpnfwdJW8iNypFjmSY0sCBEL+spFTZ2eO+Sfps= +golang.org/x/net v0.0.0-20220921203646-d300de134e69/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -423,12 +423,12 @@ golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220913175220-63ea55921009 h1:PuvuRMeLWqsf/ZdT1UUZz0syhioyv1mzuFZsXs4fvhw= -golang.org/x/sys v0.0.0-20220913175220-63ea55921009/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 h1:h+EGohizhe9XlX18rfpa8k8RAc5XyaeamM+0VHRd4lc= +golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 h1:Q5284mrmYTpACcm+eAKjKJH48BBwSyfJqmmGDTtT8Vc= -golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.0.0-20220919170432-7a66f970e087 h1:tPwmk4vmvVCMdr98VgL4JH+qZxPL8fqlUOHnyOM8N3w= +golang.org/x/term v0.0.0-20220919170432-7a66f970e087/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/pkg/crud/crud.go b/pkg/crud/crud.go index e65d2e06..6cf23d95 100644 --- a/pkg/crud/crud.go +++ b/pkg/crud/crud.go @@ -139,24 +139,26 @@ func New(config Config, storage absto.Storage, rendererApp renderer.App, shareAp return app, nil } -func (a App) Start(done <-chan struct{}) { +func (a App) Start(ctx context.Context) { if a.amqpClient == nil { - a.start(context.Background(), done) + a.start(ctx) return } if _, err := a.amqpClient.Exclusive(context.Background(), a.amqpExclusiveRoutingKey, time.Hour, func(ctx context.Context) error { - a.start(ctx, done) + a.start(ctx) return nil }); err != nil { logger.Error("get exclusive semaphore: %s", err) } } -func (a App) start(ctx context.Context, done <-chan struct{}) { +func (a App) start(ctx context.Context) { logger.Info("Starting startup check...") defer logger.Info("Ending startup check.") + done := ctx.Done() + err := a.storageApp.Walk(ctx, "", func(item absto.Item) error { select { case <-done: diff --git a/pkg/provider/event.go b/pkg/provider/event.go index f8da3e37..8fb6605e 100644 --- a/pkg/provider/event.go +++ b/pkg/provider/event.go @@ -319,14 +319,14 @@ func (e EventBus) Push(event Event) error { } } -func (e EventBus) Start(done <-chan struct{}, storageApp absto.Storage, renamers []Renamer, consumers ...EventConsumer) { +func (e EventBus) Start(ctx context.Context, storageApp absto.Storage, renamers []Renamer, consumers ...EventConsumer) { defer close(e.done) go func() { defer close(e.bus) defer close(e.closed) - <-done + <-ctx.Done() }() for event := range e.bus { diff --git a/pkg/share/share.go b/pkg/share/share.go index cc7e571c..6a42d34a 100644 --- a/pkg/share/share.go +++ b/pkg/share/share.go @@ -125,8 +125,8 @@ func (a *App) Get(requestPath string) provider.Share { return provider.Share{} } -func (a *App) Start(done <-chan struct{}) { - if err := a.loadShares(context.Background()); err != nil { +func (a *App) Start(ctx context.Context) { + if err := a.loadShares(ctx); err != nil { logger.Error("refresh shares: %s", err) return } @@ -139,7 +139,7 @@ func (a *App) Start(done <-chan struct{}) { purgeCron.Exclusive(a, a.amqpExclusiveRoutingKey, semaphoreDuration) } - purgeCron.Start(a.cleanShares, done) + purgeCron.Start(ctx, a.cleanShares) } func (a *App) loadShares(ctx context.Context) error { diff --git a/pkg/webhook/webhook.go b/pkg/webhook/webhook.go index 0ddd16f3..7933b225 100644 --- a/pkg/webhook/webhook.go +++ b/pkg/webhook/webhook.go @@ -124,11 +124,11 @@ exclusive: return nil } -func (a *App) Start(_ <-chan struct{}) { +func (a *App) Start(ctx context.Context) { a.Lock() defer a.Unlock() - if err := a.loadWebhooks(context.Background()); err != nil { + if err := a.loadWebhooks(ctx); err != nil { logger.Error("refresh webhooks: %s", err) return }