From 8ef7648713a61bc2302e7965468ee94da969ff66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo?= Date: Thu, 6 Feb 2020 17:35:37 +0100 Subject: [PATCH] cli: add gRPC hooks (#316) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add grpc hook * add retry/backoff params make streaming RPC call * Update cmd/tusd/cli/flags.go Co-Authored-By: Márk Sági-Kazár * move one time grpc configuration to `Setup` * remove stream grpc Co-authored-by: Márk Sági-Kazár --- cmd/tusd/cli/flags.go | 6 + cmd/tusd/cli/hooks.go | 8 + cmd/tusd/cli/hooks/grpc.go | 73 ++++ cmd/tusd/cli/hooks/proto/v1/hook.proto | 68 ++++ docs/hooks.md | 73 ++++ go.mod | 5 +- go.sum | 31 ++ pkg/proto/v1/hook.pb.go | 454 +++++++++++++++++++++++++ 8 files changed, 717 insertions(+), 1 deletion(-) create mode 100644 cmd/tusd/cli/hooks/grpc.go create mode 100644 cmd/tusd/cli/hooks/proto/v1/hook.proto create mode 100644 pkg/proto/v1/hook.pb.go diff --git a/cmd/tusd/cli/flags.go b/cmd/tusd/cli/flags.go index 65f4619..efd2f62 100644 --- a/cmd/tusd/cli/flags.go +++ b/cmd/tusd/cli/flags.go @@ -26,6 +26,9 @@ var Flags struct { HttpHooksEndpoint string HttpHooksRetry int HttpHooksBackoff int + GrpcHooksEndpoint string + GrpcHooksRetry int + GrpcHooksBackoff int HooksStopUploadCode int PluginHookPath string EnabledHooks []hooks.HookType @@ -54,6 +57,9 @@ func ParseFlags() { flag.StringVar(&Flags.HttpHooksEndpoint, "hooks-http", "", "An HTTP endpoint to which hook events will be sent to") flag.IntVar(&Flags.HttpHooksRetry, "hooks-http-retry", 3, "Number of times to retry on a 500 or network timeout") flag.IntVar(&Flags.HttpHooksBackoff, "hooks-http-backoff", 1, "Number of seconds to wait before retrying each retry") + flag.StringVar(&Flags.GrpcHooksEndpoint, "hooks-grpc", "", "An gRPC endpoint to which hook events will be sent to") + flag.IntVar(&Flags.GrpcHooksRetry, "hooks-grpc-retry", 3, "Number of times to retry on a server error or network timeout") + flag.IntVar(&Flags.GrpcHooksBackoff, "hooks-grpc-backoff", 1, "Number of seconds to wait before retrying each retry") flag.IntVar(&Flags.HooksStopUploadCode, "hooks-stop-code", 0, "Return code from post-receive hook which causes tusd to stop and delete the current upload. A zero value means that no uploads will be stopped") flag.StringVar(&Flags.PluginHookPath, "hooks-plugin", "", "Path to a Go plugin for loading hook functions (only supported on Linux and macOS; highly EXPERIMENTAL and may BREAK in the future)") flag.BoolVar(&Flags.ShowVersion, "version", false, "Print tusd version information") diff --git a/cmd/tusd/cli/hooks.go b/cmd/tusd/cli/hooks.go index 781f76a..a9fde10 100644 --- a/cmd/tusd/cli/hooks.go +++ b/cmd/tusd/cli/hooks.go @@ -58,6 +58,14 @@ func SetupPreHooks(config *handler.Config) error { MaxRetries: Flags.HttpHooksRetry, Backoff: Flags.HttpHooksBackoff, } + } else if Flags.GrpcHooksEndpoint != "" { + stdout.Printf("Using '%s' as the endpoint for gRPC hooks", Flags.GrpcHooksEndpoint) + + hookHandler = &hooks.GrpcHook{ + Endpoint: Flags.GrpcHooksEndpoint, + MaxRetries: Flags.GrpcHooksRetry, + Backoff: Flags.GrpcHooksBackoff, + } } else if Flags.PluginHookPath != "" { stdout.Printf("Using '%s' to load plugin for hooks", Flags.PluginHookPath) diff --git a/cmd/tusd/cli/hooks/grpc.go b/cmd/tusd/cli/hooks/grpc.go new file mode 100644 index 0000000..a55a1b4 --- /dev/null +++ b/cmd/tusd/cli/hooks/grpc.go @@ -0,0 +1,73 @@ +package hooks + +import ( + "context" + "time" + + grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/retry" + "github.com/tus/tusd/pkg/handler" + pb "github.com/tus/tusd/pkg/proto/v1" + "google.golang.org/grpc" + "google.golang.org/grpc/status" +) + +type GrpcHook struct { + Endpoint string + MaxRetries int + Backoff int + Client pb.HookServiceClient +} + +func (g GrpcHook) Setup() error { + opts := []grpc_retry.CallOption{ + grpc_retry.WithBackoff(grpc_retry.BackoffLinear(time.Duration(g.Backoff) * time.Second)), + grpc_retry.WithMax(uint(g.MaxRetries)), + } + grpcOpts := []grpc.DialOption{ + grpc.WithInsecure(), + grpc.WithUnaryInterceptor(grpc_retry.UnaryClientInterceptor(opts...)), + } + conn, err := grpc.Dial(g.Endpoint, grpcOpts...) + if err != nil { + return err + } + g.Client = pb.NewHookServiceClient(conn) + return nil +} + +func (g GrpcHook) InvokeHook(typ HookType, info handler.HookEvent, captureOutput bool) ([]byte, int, error) { + ctx := context.Background() + req := &pb.SendRequest{Hook: marshal(info)} + resp, err := g.Client.Send(ctx, req) + if err != nil { + if e, ok := status.FromError(err); ok { + return nil, int(e.Code()), err + } + return nil, 2, err + } + if captureOutput { + return resp.Response.GetValue(), 0, err + } + return nil, 0, err +} + +func marshal(info handler.HookEvent) *pb.Hook { + return &pb.Hook{ + Upload: &pb.Upload{ + Id: info.Upload.ID, + Size: info.Upload.Size, + SizeIsDeferred: info.Upload.SizeIsDeferred, + Offset: info.Upload.Offset, + MetaData: info.Upload.MetaData, + IsPartial: info.Upload.IsPartial, + IsFinal: info.Upload.IsFinal, + PartialUploads: info.Upload.PartialUploads, + Storage: info.Upload.Storage, + }, + HttpRequest: &pb.HTTPRequest{ + Method: info.HTTPRequest.Method, + Uri: info.HTTPRequest.URI, + RemoteAddr: info.HTTPRequest.RemoteAddr, + }, + } +} diff --git a/cmd/tusd/cli/hooks/proto/v1/hook.proto b/cmd/tusd/cli/hooks/proto/v1/hook.proto new file mode 100644 index 0000000..633740a --- /dev/null +++ b/cmd/tusd/cli/hooks/proto/v1/hook.proto @@ -0,0 +1,68 @@ +syntax = "proto3"; +package v1; + +import "google/protobuf/any.proto"; + +// Uploaded data +message Upload { + // Unique integer identifier of the uploaded file + string id = 1; + // Total file size in bytes specified in the NewUpload call + int64 Size = 2; + // Indicates whether the total file size is deferred until later + bool SizeIsDeferred = 3; + // Offset in bytes (zero-based) + int64 Offset = 4; + map metaData = 5; + // Indicates that this is a partial upload which will later be used to form + // a final upload by concatenation. Partial uploads should not be processed + // when they are finished since they are only incomplete chunks of files. + bool isPartial = 6; + // Indicates that this is a final upload + bool isFinal = 7; + // If the upload is a final one (see IsFinal) this will be a non-empty + // ordered slice containing the ids of the uploads of which the final upload + // will consist after concatenation. + repeated string partialUploads = 8; + // Storage contains information about where the data storage saves the upload, + // for example a file path. The available values vary depending on what data + // store is used. This map may also be nil. + map storage = 9; +} + +message HTTPRequest { + // Method is the HTTP method, e.g. POST or PATCH + string method = 1; + // URI is the full HTTP request URI, e.g. /files/fooo + string uri = 2; + // RemoteAddr contains the network address that sent the request + string remoteAddr = 3; +} + +// Hook's data +message Hook { + // Upload contains information about the upload that caused this hook + // to be fired. + Upload upload = 1; + // HTTPRequest contains details about the HTTP request that reached + // tusd. + HTTPRequest httpRequest = 2; +} + +// Request data to send hook +message SendRequest { + // The hook data + Hook hook = 1; +} + +// Response that contains data for sended hook +message SendResponse { + // The response of the hook. + google.protobuf.Any response = 1; +} + +// The hook service definition. +service HookService { + // Sends a hook + rpc Send (SendRequest) returns (SendResponse) {} +} diff --git a/docs/hooks.md b/docs/hooks.md index 1720700..dc45112 100644 --- a/docs/hooks.md +++ b/docs/hooks.md @@ -202,3 +202,76 @@ Tusd uses the [Pester library](https://github.com/sethgrid/pester) to issue requ $ # Retrying 5 times with a 2 second backoff $ tusd --hooks-http http://localhost:8081/write --hooks-http-retry 5 --hooks-http-backoff 2 ``` + +## GRPC Hooks + +GRPC Hooks are the third type of hooks supported by tusd. Like the others hooks, it is disabled by default. To enable it, pass the `--hooks-grpc option to the tusd binary. The flag's value will be a gRPC endpoint, which the tusd binary will be sent to: + +```bash +$ tusd --hooks-grpc localhost:8080 + +[tusd] Using 'localhost:8080' as the endpoint for gRPC hooks +[tusd] Using './data' as directory storage. +... +``` + +### Usage + +Tusd will issue a `gRPC` request to the specified endpoint, specifying the hook name, such as pre-create or post-finish, in the `Hook-Name` header and following body: + +```js +{ + // The upload object contains the upload's details + "Upload": { + // The upload's ID. Will be empty during the pre-create event + "ID": "14b1c4c77771671a8479bc0444bbc5ce", + // The upload's total size in bytes. + "Size": 46205, + // The upload's current offset in bytes. + "Offset": 1592, + // These properties will be set to true, if the upload as a final or partial + // one. See the Concatenation extension for details: + // http://tus.io/protocols/resumable-upload.html#concatenation + "IsFinal": false, + "IsPartial": false, + // If the upload is a final one, this value will be an array of upload IDs + // which are concatenated to produce the upload. + "PartialUploads": null, + // The upload's meta data which can be supplied by the clients as it wishes. + // All keys and values in this object will be strings. + // Be aware that it may contain maliciously crafted values and you must not + // trust it without escaping it first! + "MetaData": { + "filename": "transloadit.png" + }, + // Details about where the data store saved the uploaded file. The different + // availabl keys vary depending on the used data store. + "Storage": { + // For example, the filestore supplies the absolute file path: + "Type": "filestore", + "Path": "/my/upload/directory/14b1c4c77771671a8479bc0444bbc5ce", + + // The S3Store and GCSStore supply the bucket name and object key: + "Type": "s3store", + "Bucket": "my-upload-bucket", + "Key": "my-prefix/14b1c4c77771671a8479bc0444bbc5ce" + } + }, + // Details about the HTTP request which caused this hook to be fired. + // It can be used to record the client's IP address or inspect the headers. + "HTTPRequest": { + "Method": "PATCH", + "URI": "/files/14b1c4c77771671a8479bc0444bbc5ce", + "RemoteAddr": "1.2.3.4:47689", + } +} +``` + +### Configuration + +By default, tusd will retry 3 times based on the gRPC status response or network error, with a 1 second backoff. This can be configured with the flags `--hooks-grpc-retry` and `--hooks-grpc-backoff`, like so: + +```bash +$ # Retrying 5 times with a 2 second backoff +$ tusd --hooks-grpc localhost:8081/ --hooks-grpc-retry 5 --hooks-grpc-backoff 2 +``` diff --git a/go.mod b/go.mod index cf4ba6a..a2014f1 100644 --- a/go.mod +++ b/go.mod @@ -7,11 +7,14 @@ require ( github.com/aws/aws-sdk-go v1.20.1 github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40 github.com/golang/mock v1.3.1 + github.com/golang/protobuf v1.3.2 + github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 github.com/prometheus/client_golang v1.0.0 github.com/sethgrid/pester v0.0.0-20190127155807-68a33a018ad0 - github.com/stretchr/testify v1.3.0 + github.com/stretchr/testify v1.4.0 github.com/vimeo/go-util v1.2.0 google.golang.org/api v0.6.0 + google.golang.org/grpc v1.25.1 gopkg.in/Acconut/lockfile.v1 v1.1.0 gopkg.in/h2non/gock.v1 v1.0.14 ) diff --git a/go.sum b/go.sum index 2a66c9f..c62421c 100644 --- a/go.sum +++ b/go.sum @@ -13,16 +13,20 @@ github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40 h1:y4B3+GPxKlrigF1ha5FFErxK+sr6sWxQovRMzwMhejo= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gogo/protobuf v1.1.1 h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= @@ -32,6 +36,8 @@ github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFU github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c h1:964Od4U6p2jUkFxvCydnIczKteheJEzHRToSGK3Bnlw= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -42,6 +48,8 @@ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXi github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/googleapis/gax-go/v2 v2.0.4 h1:hU4mGcQI4DaAYW+IbTun+2qEZVFxK0ySjQLTbS0VQKc= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 h1:THDBEeQ9xZ8JEaCLyLQqXMMdRqNr0QAUJTIkQAUtFjg= +github.com/grpc-ecosystem/go-grpc-middleware v1.1.0/go.mod h1:f5nM7jw/oeRSadq3xCzHAvxcr8HZnzsqU6ILg/0NiiE= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -53,6 +61,8 @@ github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwK github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -65,8 +75,10 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= @@ -75,6 +87,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 h1:S/YWwWx/RA8rT8tKFRuGUZhuA90OyIBpPCXkcbwU8DE= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.4.1 h1:K0MGApIoQvMw27RTdJkPbr3JZ7DNbtxQNyi5STVM6Kw= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= @@ -84,15 +98,21 @@ github.com/sethgrid/pester v0.0.0-20190127155807-68a33a018ad0 h1:X9XMOYjxEfAYSy3 github.com/sethgrid/pester v0.0.0-20190127155807-68a33a018ad0/go.mod h1:Ad7IjTpvzZO8Fl0vh9AzQ+j/jYZfyp2diGwI8m5q+ns= github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/vimeo/go-util v1.2.0 h1:YHzwOnM+V2tc6r67K9fXpYqUiRwXp0TgFKuyj+A5bsg= github.com/vimeo/go-util v1.2.0/go.mod h1:s13SMDTSO7AjH1nbgp707mfN5JFIWUFDU5MDDuRRtKs= go.opencensus.io v0.21.0 h1:mU6zScU4U1YAFPHEHYk+3JC4SY7JxgkqS10ZOSyksNg= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -123,6 +143,7 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b h1:ag/x1USPSsqHud38I9BAC88qdNLDHHtQ4mlgQIZPPNA= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -131,6 +152,7 @@ golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c h1:fqgJT0MGcGpPgpWU7VRdRjuArfcOvC4AoJmILihzhDg= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/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-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -139,6 +161,7 @@ golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c h1:97SnQk1GYRXJgvwZ8fadnxDOWfKvkNQHH3CtZntPSrM= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.6.0 h1:2tJEkRfnZL5g1GeBUlITh/rqT5HG3sFcoVCUUxmgJ2g= google.golang.org/api v0.6.0/go.mod h1:btoxGiFvQNVUZQ8W08zLtrVS08CNpINPEfxXxgJL1Q4= @@ -152,9 +175,14 @@ google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRn google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190530194941-fb225487d101 h1:wuGevabY6r+ivPNagjUXGGxF+GqgMd+dBhjsxW4q9u4= google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1 h1:Hz2g2wirWK7H0qIIhGIqRGTuMwTE8HEKFnDZZ7lm9NU= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1 h1:wdKvqQk7IttEw92GoRyKG2IDrUIpgpj6H6m81yfeMW0= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= gopkg.in/Acconut/lockfile.v1 v1.1.0 h1:c5AMZOxgM1y+Zl8eSbaCENzVYp/LCaWosbQSXzb3FVI= gopkg.in/Acconut/lockfile.v1 v1.1.0/go.mod h1:6UCz3wJ8tSFUsPR6uP/j8uegEtDuEEqFxlpi0JI4Umw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= @@ -164,7 +192,10 @@ gopkg.in/h2non/gock.v1 v1.0.14 h1:fTeu9fcUvSnLNacYvYI54h+1/XEteDyHvrVCZEEEYNM= gopkg.in/h2non/gock.v1 v1.0.14/go.mod h1:sX4zAkdYX1TRGJ2JY156cFspQn4yRWn6p9EMdODlynE= gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/pkg/proto/v1/hook.pb.go b/pkg/proto/v1/hook.pb.go new file mode 100644 index 0000000..123b6c1 --- /dev/null +++ b/pkg/proto/v1/hook.pb.go @@ -0,0 +1,454 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: hook.proto + +package v1 + +import ( + context "context" + fmt "fmt" + proto "github.com/golang/protobuf/proto" + any "github.com/golang/protobuf/ptypes/any" + grpc "google.golang.org/grpc" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package + +// Uploaded data +type Upload struct { + // Unique integer identifier of the uploaded file + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // Total file size in bytes specified in the NewUpload call + Size int64 `protobuf:"varint,2,opt,name=Size,proto3" json:"Size,omitempty"` + // Indicates whether the total file size is deferred until later + SizeIsDeferred bool `protobuf:"varint,3,opt,name=SizeIsDeferred,proto3" json:"SizeIsDeferred,omitempty"` + // Offset in bytes (zero-based) + Offset int64 `protobuf:"varint,4,opt,name=Offset,proto3" json:"Offset,omitempty"` + MetaData map[string]string `protobuf:"bytes,5,rep,name=metaData,proto3" json:"metaData,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // Indicates that this is a partial upload which will later be used to form + // a final upload by concatenation. Partial uploads should not be processed + // when they are finished since they are only incomplete chunks of files. + IsPartial bool `protobuf:"varint,6,opt,name=isPartial,proto3" json:"isPartial,omitempty"` + // Indicates that this is a final upload + IsFinal bool `protobuf:"varint,7,opt,name=isFinal,proto3" json:"isFinal,omitempty"` + // If the upload is a final one (see IsFinal) this will be a non-empty + // ordered slice containing the ids of the uploads of which the final upload + // will consist after concatenation. + PartialUploads []string `protobuf:"bytes,8,rep,name=partialUploads,proto3" json:"partialUploads,omitempty"` + // Storage contains information about where the data storage saves the upload, + // for example a file path. The available values vary depending on what data + // store is used. This map may also be nil. + Storage map[string]string `protobuf:"bytes,9,rep,name=storage,proto3" json:"storage,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Upload) Reset() { *m = Upload{} } +func (m *Upload) String() string { return proto.CompactTextString(m) } +func (*Upload) ProtoMessage() {} +func (*Upload) Descriptor() ([]byte, []int) { + return fileDescriptor_3eef30da1c11ee1b, []int{0} +} + +func (m *Upload) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Upload.Unmarshal(m, b) +} +func (m *Upload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Upload.Marshal(b, m, deterministic) +} +func (m *Upload) XXX_Merge(src proto.Message) { + xxx_messageInfo_Upload.Merge(m, src) +} +func (m *Upload) XXX_Size() int { + return xxx_messageInfo_Upload.Size(m) +} +func (m *Upload) XXX_DiscardUnknown() { + xxx_messageInfo_Upload.DiscardUnknown(m) +} + +var xxx_messageInfo_Upload proto.InternalMessageInfo + +func (m *Upload) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func (m *Upload) GetSize() int64 { + if m != nil { + return m.Size + } + return 0 +} + +func (m *Upload) GetSizeIsDeferred() bool { + if m != nil { + return m.SizeIsDeferred + } + return false +} + +func (m *Upload) GetOffset() int64 { + if m != nil { + return m.Offset + } + return 0 +} + +func (m *Upload) GetMetaData() map[string]string { + if m != nil { + return m.MetaData + } + return nil +} + +func (m *Upload) GetIsPartial() bool { + if m != nil { + return m.IsPartial + } + return false +} + +func (m *Upload) GetIsFinal() bool { + if m != nil { + return m.IsFinal + } + return false +} + +func (m *Upload) GetPartialUploads() []string { + if m != nil { + return m.PartialUploads + } + return nil +} + +func (m *Upload) GetStorage() map[string]string { + if m != nil { + return m.Storage + } + return nil +} + +type HTTPRequest struct { + // Method is the HTTP method, e.g. POST or PATCH + Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"` + // URI is the full HTTP request URI, e.g. /files/fooo + Uri string `protobuf:"bytes,2,opt,name=uri,proto3" json:"uri,omitempty"` + // RemoteAddr contains the network address that sent the request + RemoteAddr string `protobuf:"bytes,3,opt,name=remoteAddr,proto3" json:"remoteAddr,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *HTTPRequest) Reset() { *m = HTTPRequest{} } +func (m *HTTPRequest) String() string { return proto.CompactTextString(m) } +func (*HTTPRequest) ProtoMessage() {} +func (*HTTPRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3eef30da1c11ee1b, []int{1} +} + +func (m *HTTPRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_HTTPRequest.Unmarshal(m, b) +} +func (m *HTTPRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_HTTPRequest.Marshal(b, m, deterministic) +} +func (m *HTTPRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_HTTPRequest.Merge(m, src) +} +func (m *HTTPRequest) XXX_Size() int { + return xxx_messageInfo_HTTPRequest.Size(m) +} +func (m *HTTPRequest) XXX_DiscardUnknown() { + xxx_messageInfo_HTTPRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_HTTPRequest proto.InternalMessageInfo + +func (m *HTTPRequest) GetMethod() string { + if m != nil { + return m.Method + } + return "" +} + +func (m *HTTPRequest) GetUri() string { + if m != nil { + return m.Uri + } + return "" +} + +func (m *HTTPRequest) GetRemoteAddr() string { + if m != nil { + return m.RemoteAddr + } + return "" +} + +// Hook's data +type Hook struct { + // Upload contains information about the upload that caused this hook + // to be fired. + Upload *Upload `protobuf:"bytes,1,opt,name=upload,proto3" json:"upload,omitempty"` + // HTTPRequest contains details about the HTTP request that reached + // tusd. + HttpRequest *HTTPRequest `protobuf:"bytes,2,opt,name=httpRequest,proto3" json:"httpRequest,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Hook) Reset() { *m = Hook{} } +func (m *Hook) String() string { return proto.CompactTextString(m) } +func (*Hook) ProtoMessage() {} +func (*Hook) Descriptor() ([]byte, []int) { + return fileDescriptor_3eef30da1c11ee1b, []int{2} +} + +func (m *Hook) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Hook.Unmarshal(m, b) +} +func (m *Hook) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Hook.Marshal(b, m, deterministic) +} +func (m *Hook) XXX_Merge(src proto.Message) { + xxx_messageInfo_Hook.Merge(m, src) +} +func (m *Hook) XXX_Size() int { + return xxx_messageInfo_Hook.Size(m) +} +func (m *Hook) XXX_DiscardUnknown() { + xxx_messageInfo_Hook.DiscardUnknown(m) +} + +var xxx_messageInfo_Hook proto.InternalMessageInfo + +func (m *Hook) GetUpload() *Upload { + if m != nil { + return m.Upload + } + return nil +} + +func (m *Hook) GetHttpRequest() *HTTPRequest { + if m != nil { + return m.HttpRequest + } + return nil +} + +// Request data to send hook +type SendRequest struct { + // The hook data + Hook *Hook `protobuf:"bytes,1,opt,name=hook,proto3" json:"hook,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SendRequest) Reset() { *m = SendRequest{} } +func (m *SendRequest) String() string { return proto.CompactTextString(m) } +func (*SendRequest) ProtoMessage() {} +func (*SendRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3eef30da1c11ee1b, []int{3} +} + +func (m *SendRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SendRequest.Unmarshal(m, b) +} +func (m *SendRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SendRequest.Marshal(b, m, deterministic) +} +func (m *SendRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SendRequest.Merge(m, src) +} +func (m *SendRequest) XXX_Size() int { + return xxx_messageInfo_SendRequest.Size(m) +} +func (m *SendRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SendRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SendRequest proto.InternalMessageInfo + +func (m *SendRequest) GetHook() *Hook { + if m != nil { + return m.Hook + } + return nil +} + +// Response that contains data for sended hook +type SendResponse struct { + // The response of the hook. + Response *any.Any `protobuf:"bytes,1,opt,name=response,proto3" json:"response,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SendResponse) Reset() { *m = SendResponse{} } +func (m *SendResponse) String() string { return proto.CompactTextString(m) } +func (*SendResponse) ProtoMessage() {} +func (*SendResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3eef30da1c11ee1b, []int{4} +} + +func (m *SendResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SendResponse.Unmarshal(m, b) +} +func (m *SendResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SendResponse.Marshal(b, m, deterministic) +} +func (m *SendResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_SendResponse.Merge(m, src) +} +func (m *SendResponse) XXX_Size() int { + return xxx_messageInfo_SendResponse.Size(m) +} +func (m *SendResponse) XXX_DiscardUnknown() { + xxx_messageInfo_SendResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_SendResponse proto.InternalMessageInfo + +func (m *SendResponse) GetResponse() *any.Any { + if m != nil { + return m.Response + } + return nil +} + +func init() { + proto.RegisterType((*Upload)(nil), "v1.Upload") + proto.RegisterMapType((map[string]string)(nil), "v1.Upload.MetaDataEntry") + proto.RegisterMapType((map[string]string)(nil), "v1.Upload.StorageEntry") + proto.RegisterType((*HTTPRequest)(nil), "v1.HTTPRequest") + proto.RegisterType((*Hook)(nil), "v1.Hook") + proto.RegisterType((*SendRequest)(nil), "v1.SendRequest") + proto.RegisterType((*SendResponse)(nil), "v1.SendResponse") +} + +func init() { proto.RegisterFile("hook.proto", fileDescriptor_3eef30da1c11ee1b) } + +var fileDescriptor_3eef30da1c11ee1b = []byte{ + // 467 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x52, 0x4d, 0x6f, 0xd3, 0x40, + 0x10, 0xc5, 0x1f, 0x75, 0xec, 0x71, 0x29, 0xd5, 0xaa, 0x82, 0x25, 0xaa, 0x90, 0xe5, 0x03, 0xb2, + 0x54, 0xc9, 0x25, 0x81, 0x03, 0x0a, 0x17, 0x2a, 0x15, 0x54, 0x0e, 0x88, 0x6a, 0x53, 0xc4, 0x89, + 0xc3, 0x16, 0x6f, 0x12, 0x2b, 0x8e, 0xd7, 0xac, 0xd7, 0x91, 0xc2, 0x8f, 0xe2, 0x37, 0xa2, 0xfd, + 0x70, 0x63, 0x72, 0xeb, 0xc9, 0x33, 0x6f, 0xde, 0xbc, 0x79, 0x9e, 0x1d, 0x80, 0x15, 0xe7, 0xeb, + 0xbc, 0x11, 0x5c, 0x72, 0xe4, 0x6e, 0x27, 0xe3, 0x97, 0x4b, 0xce, 0x97, 0x15, 0xbb, 0xd4, 0xc8, + 0x7d, 0xb7, 0xb8, 0xa4, 0xf5, 0xce, 0x94, 0xd3, 0xbf, 0x1e, 0x04, 0xdf, 0x9b, 0x8a, 0xd3, 0x02, + 0x9d, 0x80, 0x5b, 0x16, 0xd8, 0x49, 0x9c, 0x2c, 0x22, 0x6e, 0x59, 0x20, 0x04, 0xfe, 0xbc, 0xfc, + 0xc3, 0xb0, 0x9b, 0x38, 0x99, 0x47, 0x74, 0x8c, 0x5e, 0xc3, 0x89, 0xfa, 0x7e, 0x69, 0xaf, 0xd9, + 0x82, 0x09, 0xc1, 0x0a, 0xec, 0x25, 0x4e, 0x16, 0x92, 0x03, 0x14, 0x3d, 0x87, 0xe0, 0xdb, 0x62, + 0xd1, 0x32, 0x89, 0x7d, 0xdd, 0x6d, 0x33, 0xf4, 0x0e, 0xc2, 0x0d, 0x93, 0xf4, 0x9a, 0x4a, 0x8a, + 0x8f, 0x12, 0x2f, 0x8b, 0xa7, 0x38, 0xdf, 0x4e, 0x72, 0xe3, 0x20, 0xff, 0x6a, 0x4b, 0x9f, 0x6a, + 0x29, 0x76, 0xe4, 0x81, 0x89, 0xce, 0x21, 0x2a, 0xdb, 0x5b, 0x2a, 0x64, 0x49, 0x2b, 0x1c, 0xe8, + 0x81, 0x7b, 0x00, 0x61, 0x18, 0x95, 0xed, 0xe7, 0xb2, 0xa6, 0x15, 0x1e, 0xe9, 0x5a, 0x9f, 0x2a, + 0xb7, 0x8d, 0x21, 0x99, 0x01, 0x2d, 0x0e, 0x13, 0x2f, 0x8b, 0xc8, 0x01, 0x8a, 0x26, 0x30, 0x6a, + 0x25, 0x17, 0x74, 0xc9, 0x70, 0xa4, 0x4d, 0xbd, 0x18, 0x98, 0x9a, 0x9b, 0x8a, 0xf1, 0xd4, 0xf3, + 0xc6, 0x1f, 0xe0, 0xe9, 0x7f, 0x6e, 0xd1, 0x29, 0x78, 0x6b, 0xb6, 0xb3, 0xeb, 0x53, 0x21, 0x3a, + 0x83, 0xa3, 0x2d, 0xad, 0x3a, 0xb3, 0xc0, 0x88, 0x98, 0x64, 0xe6, 0xbe, 0x77, 0xc6, 0x33, 0x38, + 0x1e, 0xaa, 0x3e, 0xa6, 0x37, 0xfd, 0x01, 0xf1, 0xcd, 0xdd, 0xdd, 0x2d, 0x61, 0xbf, 0x3b, 0xd6, + 0x4a, 0xb5, 0xe8, 0x0d, 0x93, 0x2b, 0xde, 0x3f, 0x9c, 0xcd, 0x94, 0x64, 0x27, 0x4a, 0xdb, 0xae, + 0x42, 0xf4, 0x0a, 0x40, 0xb0, 0x0d, 0x97, 0xec, 0xaa, 0x28, 0x84, 0x7e, 0xb6, 0x88, 0x0c, 0x90, + 0xf4, 0x27, 0xf8, 0x37, 0x9c, 0xaf, 0x51, 0x0a, 0x41, 0xa7, 0xff, 0x5c, 0x2b, 0xc6, 0x53, 0xd8, + 0xef, 0x82, 0xd8, 0x0a, 0x9a, 0x40, 0xbc, 0x92, 0xb2, 0xb1, 0x26, 0xf4, 0x94, 0x78, 0xfa, 0x4c, + 0x11, 0x07, 0xde, 0xc8, 0x90, 0x93, 0x5e, 0x40, 0x3c, 0x67, 0x75, 0xd1, 0xfb, 0x3e, 0x07, 0x5f, + 0x1d, 0xa9, 0x9d, 0x11, 0xea, 0x56, 0xce, 0xd7, 0x44, 0xa3, 0xe9, 0x47, 0x38, 0x36, 0xe4, 0xb6, + 0xe1, 0x75, 0xcb, 0xd0, 0x1b, 0x08, 0x85, 0x8d, 0x6d, 0xc7, 0x59, 0x6e, 0x6e, 0x3a, 0xef, 0x6f, + 0x3a, 0xbf, 0xaa, 0x77, 0xe4, 0x81, 0x35, 0x9d, 0x41, 0xac, 0xf4, 0xe6, 0x4c, 0x6c, 0xcb, 0x5f, + 0x0c, 0x5d, 0x80, 0xaf, 0x04, 0x91, 0xf6, 0x38, 0xf0, 0x31, 0x3e, 0xdd, 0x03, 0xa6, 0x33, 0x7d, + 0x72, 0x1f, 0x68, 0xcd, 0xb7, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x87, 0x7b, 0x45, 0xd1, 0x47, + 0x03, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// HookServiceClient is the client API for HookService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type HookServiceClient interface { + // Sends a hook + Send(ctx context.Context, in *SendRequest, opts ...grpc.CallOption) (*SendResponse, error) +} + +type hookServiceClient struct { + cc *grpc.ClientConn +} + +func NewHookServiceClient(cc *grpc.ClientConn) HookServiceClient { + return &hookServiceClient{cc} +} + +func (c *hookServiceClient) Send(ctx context.Context, in *SendRequest, opts ...grpc.CallOption) (*SendResponse, error) { + out := new(SendResponse) + err := c.cc.Invoke(ctx, "/v1.HookService/Send", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// HookServiceServer is the server API for HookService service. +type HookServiceServer interface { + // Sends a hook + Send(context.Context, *SendRequest) (*SendResponse, error) +} + +func RegisterHookServiceServer(s *grpc.Server, srv HookServiceServer) { + s.RegisterService(&_HookService_serviceDesc, srv) +} + +func _HookService_Send_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SendRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HookServiceServer).Send(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/v1.HookService/Send", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HookServiceServer).Send(ctx, req.(*SendRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _HookService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "v1.HookService", + HandlerType: (*HookServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Send", + Handler: _HookService_Send_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "hook.proto", +}