From e9ef69ca1f78ac81f42127ea04bf7755d8b3f87a Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Mon, 8 May 2023 15:21:31 +0200 Subject: [PATCH] feat: initial draft of SDK --- README.md | 28 +- api.go | 72 + api/README.md | 11 + api/buf.yaml | 11 + api/rpc/v1/executor.proto | 64 + buf.gen.yaml | 17 + buf.work.yaml | 3 + buf.yaml | 4 + context.go | 85 + entrypoint.go | 34 + examples/hello_world/go.mod | 11 - examples/hello_world_go/.gitignore | 2 + examples/hello_world_go/go.mod | 23 + examples/hello_world_go/go.sum | 19 + examples/hello_world_go/main.go | 17 + examples/hello_world_go/main_test.go | 31 + examples/hello_world_go/module/hello_world.go | 41 + executor.go | 29 + go.mod | 11 +- go.sum | 15 +- imports_stub.go | 9 + imports_wasi.go | 15 + integration/README.md | 13 + integration/go.mod | 19 + integration/go.sum | 19 + integration/logging.go | 23 + integration/mem_mgr.go | 75 + integration/test_host.go | 224 ++ internal/mem/unmanaged.go | 17 + logger.go | 78 + protocol/generated/rpc/v1/executor.pb.go | 990 +++++++ .../generated/rpc/v1/executor_vtproto.pb.go | 2375 +++++++++++++++++ registry.go | 47 + state_proxy.go | 67 + test/test_host.go | 62 - 35 files changed, 4481 insertions(+), 80 deletions(-) create mode 100644 api.go create mode 100644 api/README.md create mode 100644 api/buf.yaml create mode 100644 api/rpc/v1/executor.proto create mode 100644 buf.gen.yaml create mode 100644 buf.work.yaml create mode 100644 buf.yaml create mode 100644 context.go create mode 100644 entrypoint.go delete mode 100644 examples/hello_world/go.mod create mode 100644 examples/hello_world_go/.gitignore create mode 100644 examples/hello_world_go/go.mod create mode 100644 examples/hello_world_go/go.sum create mode 100644 examples/hello_world_go/main.go create mode 100644 examples/hello_world_go/main_test.go create mode 100644 examples/hello_world_go/module/hello_world.go create mode 100644 executor.go create mode 100644 imports_stub.go create mode 100644 imports_wasi.go create mode 100644 integration/README.md create mode 100644 integration/go.mod create mode 100644 integration/go.sum create mode 100644 integration/logging.go create mode 100644 integration/mem_mgr.go create mode 100644 integration/test_host.go create mode 100644 internal/mem/unmanaged.go create mode 100644 logger.go create mode 100644 protocol/generated/rpc/v1/executor.pb.go create mode 100644 protocol/generated/rpc/v1/executor_vtproto.pb.go create mode 100644 registry.go create mode 100644 state_proxy.go delete mode 100644 test/test_host.go diff --git a/README.md b/README.md index f3151a4..f5db029 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,28 @@ -# wasi-module-sdk-go +# Module SDK for Go +This module provides glue code to implement a buildr WASI module easily and quickly. +To implement a new buildr WASI module: + +1. Create a new Go module +1. Reference this SDK (`go get -u code.icb4dc0.de/buildr/wasi-module-sdk`) +1. create a `main.go` with an **empty** `main()` function +1. implement the `sdk.Module` interface for your module +1. implement an `init()` function that registers your module and the SDK's type registry +1. compile the module e.g. with tinygo + +See also the [examples](./examples) directory to get started. + +## Dependencies + +### easyjson + +Right now the SDK depends on [easyjson](https://github.com/mailru/easyjson) to unmarshal the modules state as defined in the HCL configuration. +The main reason for this is that the reflection support in TinyGo is limited and for instance `encoding/json` heavily depends on reflection. +The SDK itself uses protobuf (vtprotobuf) to exchange data with the host without reflection but this is not generic enough to support every possibility of module configuration (e.g. `map` would require extra encoding/decoding steps, same for `map ../../ -) \ No newline at end of file diff --git a/examples/hello_world_go/.gitignore b/examples/hello_world_go/.gitignore new file mode 100644 index 0000000..eac91e9 --- /dev/null +++ b/examples/hello_world_go/.gitignore @@ -0,0 +1,2 @@ +*.wasm +*_easyjson.go \ No newline at end of file diff --git a/examples/hello_world_go/go.mod b/examples/hello_world_go/go.mod new file mode 100644 index 0000000..1faecaf --- /dev/null +++ b/examples/hello_world_go/go.mod @@ -0,0 +1,23 @@ +module hello_world + +go 1.20 + +require ( + code.icb4dc0.de/buildr/wasi-module-sdk v0.0.0-00010101000000-000000000000 + code.icb4dc0.de/buildr/wasi-module-sdk/integration v0.0.0-00010101000000-000000000000 + github.com/mailru/easyjson v0.7.7 + golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53 +) + +replace ( + code.icb4dc0.de/buildr/wasi-module-sdk => ../../ + code.icb4dc0.de/buildr/wasi-module-sdk/integration => ../../integration +) + +require ( + github.com/google/uuid v1.3.0 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/tetratelabs/tinymem v0.1.0 // indirect + github.com/tetratelabs/wazero v1.1.0 // indirect + google.golang.org/protobuf v1.30.0 // indirect +) diff --git a/examples/hello_world_go/go.sum b/examples/hello_world_go/go.sum new file mode 100644 index 0000000..6abbda4 --- /dev/null +++ b/examples/hello_world_go/go.sum @@ -0,0 +1,19 @@ +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/tetratelabs/tinymem v0.1.0 h1:Qza1JAg9lquPPJ/CIei5qQYx7t18KLie83O2WR6CM58= +github.com/tetratelabs/tinymem v0.1.0/go.mod h1:WFFTZFhLod6lTL+UetFAopVbGaB+KFsVcIY+RUv7NeY= +github.com/tetratelabs/wazero v1.1.0 h1:EByoAhC+QcYpwSZJSs/aV0uokxPwBgKxfiokSUwAknQ= +github.com/tetratelabs/wazero v1.1.0/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ= +golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53 h1:5llv2sWeaMSnA3w2kS57ouQQ4pudlXrR0dCgw51QK9o= +golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= diff --git a/examples/hello_world_go/main.go b/examples/hello_world_go/main.go new file mode 100644 index 0000000..9ac87c0 --- /dev/null +++ b/examples/hello_world_go/main.go @@ -0,0 +1,17 @@ +package main + +//go:generate tinygo build -o hello_world.wasm -scheduler=none -gc=leaking --no-debug -target=wasi main.go + +import ( + sdk "code.icb4dc0.de/buildr/wasi-module-sdk" + "hello_world/module" +) + +func init() { + sdk.Register(sdk.CategoryTask, "hello_world", sdk.ModuleFactoryFunc(func() sdk.Module { + return new(module.HelloWorld) + })) +} + +func main() { +} diff --git a/examples/hello_world_go/main_test.go b/examples/hello_world_go/main_test.go new file mode 100644 index 0000000..9a7b041 --- /dev/null +++ b/examples/hello_world_go/main_test.go @@ -0,0 +1,31 @@ +package main_test + +import ( + sdk "code.icb4dc0.de/buildr/wasi-module-sdk" + "code.icb4dc0.de/buildr/wasi-module-sdk/integration" + "context" + _ "embed" + "golang.org/x/exp/slog" + "testing" +) + +//go:embed hello_world.wasm +var payload []byte + +func TestModule(t *testing.T) { + h := integration.NewHost( + slog.New(slog.NewTextHandler(integration.NewTestWriter(t))), + integration.WithState(integration.StateKey(sdk.CategoryTask, "test", "hello"), []byte("world")), + ) + + s := integration.TestSpec{ + ModuleCategory: sdk.CategoryTask, + ModuleType: "hello_world", + ModuleName: "test", + RawTaskSpec: []byte(`{"Name": "Ted"}`), + } + + if err := h.Run(context.Background(), payload, s); err != nil { + t.Errorf("Failed to run module: %v", err) + } +} diff --git a/examples/hello_world_go/module/hello_world.go b/examples/hello_world_go/module/hello_world.go new file mode 100644 index 0000000..b80637f --- /dev/null +++ b/examples/hello_world_go/module/hello_world.go @@ -0,0 +1,41 @@ +package module + +//go:generate go run -mod=mod github.com/mailru/easyjson/easyjson -all hello_world.go + +import ( + sdk "code.icb4dc0.de/buildr/wasi-module-sdk" + "golang.org/x/exp/slog" +) + +var _ sdk.Module = (*HelloWorld)(nil) + +type HelloWorld struct { + Name string +} + +func (h HelloWorld) Execute(ctx sdk.ExecutionContext) error { + logger := ctx.Logger() + + logger.Info("Executing hello world") + + val, _, err := ctx.GetState(ctx, "hello") + if err != nil { + return err + } + + if err := ctx.SetState(ctx, "state", []byte(`{"hello":"world"}`)); err != nil { + return err + } + + logger.Info("Got value from state", slog.String("value", string(val))) + + return nil +} + +func (HelloWorld) Category() sdk.Category { + return sdk.CategoryTask +} + +func (HelloWorld) Type() string { + return "hello_world" +} diff --git a/executor.go b/executor.go new file mode 100644 index 0000000..5322bf3 --- /dev/null +++ b/executor.go @@ -0,0 +1,29 @@ +package sdk + +import ( + "context" + "golang.org/x/exp/slog" +) + +func NewExecutor(repoRoot, outDir, binDir string) Executor { + return Executor{ + logger: slog.New(NewWASIHandler()), + repoRoot: repoRoot, + outDir: outDir, + binDir: binDir, + } +} + +type Executor struct { + logger *slog.Logger + repoRoot string + outDir string + binDir string +} + +func (e Executor) Run(ctx context.Context, modName string, m Module) { + execCtx := newWasiExecutionContext(ctx, e.logger, modName, m, e.repoRoot, e.binDir, e.outDir) + if err := m.Execute(execCtx); err != nil { + e.logger.Error("Failed to execute module", slog.String("err", err.Error())) + } +} diff --git a/go.mod b/go.mod index 7ba3f28..b0ab55d 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,13 @@ module code.icb4dc0.de/buildr/wasi-module-sdk go 1.20 require ( - buf.build/gen/go/buildr/buildr/protocolbuffers/go v1.30.0-20230504155321-a2ad89049f80.1 // indirect - github.com/tetratelabs/wazero v1.1.0 // indirect + github.com/mailru/easyjson v0.7.7 + github.com/tetratelabs/tinymem v0.1.0 + golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53 + google.golang.org/protobuf v1.30.0 +) + +require ( + github.com/google/go-cmp v0.5.9 // indirect + github.com/josharian/intern v1.0.0 // indirect ) diff --git a/go.sum b/go.sum index 94155d4..3fd0f97 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,16 @@ -buf.build/gen/go/buildr/buildr/protocolbuffers/go v1.30.0-20230504155321-a2ad89049f80.1 h1:gDR2MbPrmDLMU4SU83sLG53G1BO2jWLZRSwA7Zx/ORs= -buf.build/gen/go/buildr/buildr/protocolbuffers/go v1.30.0-20230504155321-a2ad89049f80.1/go.mod h1:HnJwr6AoSkS1h+Fr8+UR7MDcZMzmv7lJPJWeTjdclPs= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/tetratelabs/wazero v1.1.0 h1:EByoAhC+QcYpwSZJSs/aV0uokxPwBgKxfiokSUwAknQ= -github.com/tetratelabs/wazero v1.1.0/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/tetratelabs/tinymem v0.1.0 h1:Qza1JAg9lquPPJ/CIei5qQYx7t18KLie83O2WR6CM58= +github.com/tetratelabs/tinymem v0.1.0/go.mod h1:WFFTZFhLod6lTL+UetFAopVbGaB+KFsVcIY+RUv7NeY= +golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53 h1:5llv2sWeaMSnA3w2kS57ouQQ4pudlXrR0dCgw51QK9o= +golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= diff --git a/imports_stub.go b/imports_stub.go new file mode 100644 index 0000000..a342ff9 --- /dev/null +++ b/imports_stub.go @@ -0,0 +1,9 @@ +//go:build !wasi + +package sdk + +func _log_msg(ptr, size uint32) {} + +func _get_state(ptr, size uint32) (ptrSize uint64) { return 0 } + +func _set_state(ptr, size uint32) (ptrSize uint64) { return 0 } diff --git a/imports_wasi.go b/imports_wasi.go new file mode 100644 index 0000000..084f886 --- /dev/null +++ b/imports_wasi.go @@ -0,0 +1,15 @@ +//go:build wasi + +package sdk + +//go:wasm-module buildr +//export log_msg +func _log_msg(ptr, size uint32) + +//go:wasm-module buildr +//export get_state +func _get_state(ptr, size uint32) (ptrSize uint64) + +//go:wasm-module buildr +//export set_state +func _set_state(ptr, size uint32) (ptrSize uint64) diff --git a/integration/README.md b/integration/README.md new file mode 100644 index 0000000..29e3fff --- /dev/null +++ b/integration/README.md @@ -0,0 +1,13 @@ +# Integration module + +The integration module is meant as a helper to blackbox test a WASI module. +It's a shortcut to instantiate and execute a module in the context of buildr. + +The workflow basically looks like this: + +1. Compile module e.g. with tinygo to `*.wasm` file +1. Create a `integration.Host` (with `integration.NewHost(...)` function) +1. Specify the scenario (category, type, ...) +1. Execute the module + +A very basic example can be found in the [`hello_world_go` example](../examples/hello_world_go/main_test.go) \ No newline at end of file diff --git a/integration/go.mod b/integration/go.mod new file mode 100644 index 0000000..53b3df1 --- /dev/null +++ b/integration/go.mod @@ -0,0 +1,19 @@ +module code.icb4dc0.de/buildr/wasi-module-sdk/integration + +go 1.20 + +require ( + code.icb4dc0.de/buildr/wasi-module-sdk v0.0.0-00010101000000-000000000000 + github.com/google/uuid v1.3.0 + github.com/tetratelabs/wazero v1.1.0 + golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53 +) + +require ( + github.com/josharian/intern v1.0.0 // indirect + github.com/mailru/easyjson v0.7.7 // indirect + github.com/tetratelabs/tinymem v0.1.0 // indirect + google.golang.org/protobuf v1.30.0 // indirect +) + +replace code.icb4dc0.de/buildr/wasi-module-sdk => ../ diff --git a/integration/go.sum b/integration/go.sum new file mode 100644 index 0000000..6abbda4 --- /dev/null +++ b/integration/go.sum @@ -0,0 +1,19 @@ +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/tetratelabs/tinymem v0.1.0 h1:Qza1JAg9lquPPJ/CIei5qQYx7t18KLie83O2WR6CM58= +github.com/tetratelabs/tinymem v0.1.0/go.mod h1:WFFTZFhLod6lTL+UetFAopVbGaB+KFsVcIY+RUv7NeY= +github.com/tetratelabs/wazero v1.1.0 h1:EByoAhC+QcYpwSZJSs/aV0uokxPwBgKxfiokSUwAknQ= +github.com/tetratelabs/wazero v1.1.0/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ= +golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53 h1:5llv2sWeaMSnA3w2kS57ouQQ4pudlXrR0dCgw51QK9o= +golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= diff --git a/integration/logging.go b/integration/logging.go new file mode 100644 index 0000000..bfe7b62 --- /dev/null +++ b/integration/logging.go @@ -0,0 +1,23 @@ +package integration + +import ( + "io" + "testing" +) + +var _ io.Writer = (*TestWriter)(nil) + +func NewTestWriter(tb testing.TB) TestWriter { + return TestWriter{ + TB: tb, + } +} + +type TestWriter struct { + TB testing.TB +} + +func (t TestWriter) Write(p []byte) (n int, err error) { + t.TB.Log(string(p)) + return len(p), nil +} diff --git a/integration/mem_mgr.go b/integration/mem_mgr.go new file mode 100644 index 0000000..becc6b4 --- /dev/null +++ b/integration/mem_mgr.go @@ -0,0 +1,75 @@ +package integration + +import ( + "context" + "errors" + "github.com/tetratelabs/wazero/api" +) + +type Message interface { + MarshalVT() (dAtA []byte, err error) + UnmarshalVT(dAtA []byte) error +} + +func newMemoryManager(mod api.Module) *memoryManager { + return &memoryManager{ + allocate: mod.ExportedFunction("malloc"), + deallocate: mod.ExportedFunction("free"), + } +} + +type memoryManager struct { + allocate api.Function + deallocate api.Function + danglingAllocations []uint64 +} + +func (m *memoryManager) WriteMessage(ctx context.Context, mod api.Module, msg Message) (uint64, error) { + data, err := msg.MarshalVT() + if err != nil { + return 0, err + } + ptr, err := m.Allocate(ctx, uint64(len(data))) + if err != nil { + return 0, err + } + + if !mod.Memory().Write(uint32(ptr), data) { + return 0, errors.New("failed to write message to memory") + } + + return (ptr << uint64(32)) | uint64(len(data)), nil +} + +func (m *memoryManager) Allocate(ctx context.Context, size uint64) (ptr uint64, err error) { + results, err := m.allocate.Call(ctx, size) + if err != nil { + return 0, err + } + + m.danglingAllocations = append(m.danglingAllocations, results[0]) + + return results[0], nil +} + +func (m *memoryManager) WithMem(ctx context.Context, size uint64, delegate func(ptr uint64) error) error { + results, err := m.allocate.Call(ctx, size) + if err != nil { + return err + } + + defer m.deallocate.Call(ctx, results[0]) + + return delegate(results[0]) +} + +func (m *memoryManager) Close() (err error) { + ctx := context.Background() + + for i := range m.danglingAllocations { + _, e := m.deallocate.Call(ctx, m.danglingAllocations[i]) + err = errors.Join(err, e) + } + + return err +} diff --git a/integration/test_host.go b/integration/test_host.go new file mode 100644 index 0000000..5e3d7a5 --- /dev/null +++ b/integration/test_host.go @@ -0,0 +1,224 @@ +package integration + +import ( + "context" + "crypto/md5" + "errors" + "os" + "time" + + sdk "code.icb4dc0.de/buildr/wasi-module-sdk" + rpcv1 "code.icb4dc0.de/buildr/wasi-module-sdk/protocol/generated/rpc/v1" + "github.com/google/uuid" + "github.com/tetratelabs/wazero" + "github.com/tetratelabs/wazero/api" + "github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1" + "golang.org/x/exp/slog" +) + +func StateKey(cat sdk.Category, modName, key string) string { + h := md5.New() + _, _ = h.Write([]byte(cat.String())) + _, _ = h.Write([]byte(modName)) + _, _ = h.Write([]byte(key)) + + return string(h.Sum(nil)) +} + +type TestSpec struct { + ModuleCategory sdk.Category + ModuleType string + ModuleName string + RawTaskSpec []byte +} + +type HostOption func(h *Host) + +func WithState(key string, value []byte) HostOption { + return func(h *Host) { + h.state[key] = value + } +} + +func NewHost(logger *slog.Logger, opts ...HostOption) *Host { + h := &Host{ + Logger: logger, + state: make(map[string][]byte), + } + + for i := range opts { + opts[i](h) + } + + return h +} + +type Host struct { + memMgr *memoryManager + state map[string][]byte + Logger *slog.Logger +} + +func (h *Host) Run(ctx context.Context, wasiPayload []byte, spec TestSpec) (err error) { + runtimeConfig := wazero.NewRuntimeConfig(). + WithCloseOnContextDone(true) + + r := wazero.NewRuntimeWithConfig(ctx, runtimeConfig) + defer func() { + ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) + defer cancel() + err = errors.Join(err, r.Close(ctx)) + }() + + _, err = r.NewHostModuleBuilder("buildr"). + NewFunctionBuilder().WithFunc(h.log).Export("log_msg"). + NewFunctionBuilder().WithFunc(h.getState).Export("get_state"). + NewFunctionBuilder().WithFunc(h.setState).Export("set_state"). + Instantiate(ctx) + + if err != nil { + return err + } + + closer, err := wasi_snapshot_preview1.Instantiate(ctx, r) + if err != nil { + return err + } + + defer func() { + err = errors.Join(err, closer.Close(context.Background())) + }() + + config := wazero.NewFSConfig(). + WithDirMount(".", "/work") + + moduleConfig := wazero.NewModuleConfig(). + WithStdout(os.Stdout). + WithStderr(os.Stderr). + WithFSConfig(config) + + mod, err := r.InstantiateWithConfig(ctx, wasiPayload, moduleConfig) + if err != nil { + return err + } + + startTask := &rpcv1.StartTaskRequest{ + Reference: &rpcv1.ModuleReference{ + TaskId: uuid.NewString(), + ModuleCategory: spec.ModuleCategory.String(), + ModuleType: spec.ModuleType, + ModuleName: spec.ModuleName, + }, + Buildr: &rpcv1.Buildr{ + Repo: &rpcv1.Buildr_Repo{ + Root: "/work", + }, + }, + RawTask: spec.RawTaskSpec, + } + + data, err := startTask.MarshalVT() + if err != nil { + return err + } + + run := mod.ExportedFunction("run") + h.memMgr = newMemoryManager(mod) + + defer func() { + err = errors.Join(err, h.memMgr.Close()) + }() + + err = h.memMgr.WithMem(ctx, uint64(len(data)), func(ptr uint64) error { + if !mod.Memory().Write(uint32(ptr), data) { + return errors.New("failed to write to memory") + } + + _, err = run.Call(ctx, ptr, uint64(len(data))) + + return err + }) + + return err +} + +func (h *Host) getState(ctx context.Context, m api.Module, offset, byteCount uint32) uint64 { + if h.state == nil { + h.state = make(map[string][]byte) + } + + buf, ok := m.Memory().Read(offset, byteCount) + if !ok { + return 0 + } + + getStateReq := new(rpcv1.GetStateRequest) + if err := getStateReq.UnmarshalVT(buf); err != nil { + h.Logger.Error("failed to unmarshal getStateRequest", slog.String("err", err.Error())) + return 0 + } + + resp := new(rpcv1.GetStateResponse) + resp.Data, _ = h.state[string(getStateReq.Key)] + + if ptr, err := h.memMgr.WriteMessage(ctx, m, resp); err != nil { + h.Logger.Error("Failed to write message", slog.String("err", err.Error())) + return 0 + } else { + return ptr + } +} + +func (h *Host) setState(ctx context.Context, m api.Module, offset, byteCount uint32) (result uint64) { + if h.state == nil { + h.state = make(map[string][]byte) + } + + buf, ok := m.Memory().Read(offset, byteCount) + if !ok { + return 0 + } + + setState := new(rpcv1.SetState) + if err := setState.UnmarshalVT(buf); err != nil { + h.Logger.Error("failed to unmarshal SetState", slog.String("err", err.Error())) + return 0 + } + + var resp rpcv1.Result + if len(setState.Key) < 1 { + resp.Error = "key might not be empty" + } else { + h.state[string(setState.Key)] = setState.Data + resp.Success = true + } + + if ptr, err := h.memMgr.WriteMessage(ctx, m, &resp); err != nil { + h.Logger.Error("Failed to write message", slog.String("err", err.Error())) + return 0 + } else { + return ptr + } +} + +func (h *Host) log(ctx context.Context, m api.Module, offset, byteCount uint32) { + buf, ok := m.Memory().Read(offset, byteCount) + if !ok { + return + } + + taskLog := new(rpcv1.TaskLog) + if err := taskLog.UnmarshalVT(buf); err != nil { + h.Logger.Warn("failed to unmarshal task log", slog.String("err", err.Error())) + return + } + + rec := slog.NewRecord(time.UnixMicro(taskLog.Time), slog.Level(taskLog.Level), taskLog.Message, 0) + + for i := range taskLog.Attributes { + attr := taskLog.Attributes[i] + rec.AddAttrs(slog.String(attr.Key, attr.Value)) + } + + _ = h.Logger.Handler().Handle(ctx, rec) +} diff --git a/internal/mem/unmanaged.go b/internal/mem/unmanaged.go new file mode 100644 index 0000000..650077e --- /dev/null +++ b/internal/mem/unmanaged.go @@ -0,0 +1,17 @@ +package mem + +import "unsafe" + +func DataToManagedPtr(data []byte) (uint32, uint32) { + ptr := unsafe.Pointer(unsafe.SliceData(data)) + return uint32(uintptr(ptr)), uint32(len(data)) +} + +func DataFromPtr(ptr, size uint32) []byte { + p := unsafe.Pointer(uintptr(ptr)) + return unsafe.Slice((*byte)(p), int(size)) +} + +func PtrToData(ptr uint32, size uint32) []byte { + return unsafe.Slice((*byte)(unsafe.Pointer(uintptr(ptr))), size) +} diff --git a/logger.go b/logger.go new file mode 100644 index 0000000..08f5dd2 --- /dev/null +++ b/logger.go @@ -0,0 +1,78 @@ +package sdk + +// #include +import "C" + +import ( + "code.icb4dc0.de/buildr/wasi-module-sdk/internal/mem" + rpcv1 "code.icb4dc0.de/buildr/wasi-module-sdk/protocol/generated/rpc/v1" + "context" + "golang.org/x/exp/slog" +) + +var _ slog.Handler = (*WASIHandler)(nil) + +func NewWASIHandler() WASIHandler { + return WASIHandler{} +} + +type WASIHandler struct { + Level slog.Level + attrs []slog.Attr + group string +} + +func (h WASIHandler) Enabled(_ context.Context, level slog.Level) bool { + return h.Level <= level +} + +func (h WASIHandler) Handle(ctx context.Context, record slog.Record) error { + taskLog := rpcv1.TaskLog{ + Time: record.Time.UnixMicro(), + Message: record.Message, + Level: int32(record.Level), + Attributes: make([]*rpcv1.TaskLog_LogAttribute, 0, record.NumAttrs()), + } + + record.Attrs(func(attr slog.Attr) bool { + taskLog.Attributes = append(taskLog.Attributes, &rpcv1.TaskLog_LogAttribute{ + Key: attr.Key, + Value: attr.Value.String(), + }) + + return true + }) + + data, err := taskLog.MarshalVT() + if err != nil { + return err + } + + _log_msg(mem.DataToManagedPtr(data)) + + return nil +} + +func (h WASIHandler) WithAttrs(attrs []slog.Attr) slog.Handler { + newHandler := WASIHandler{ + Level: h.Level, + attrs: make([]slog.Attr, 0, len(attrs)+len(h.attrs)), + } + + newHandler.attrs = append(newHandler.attrs, h.attrs...) + newHandler.attrs = append(newHandler.attrs, attrs...) + + return newHandler +} + +func (h WASIHandler) WithGroup(name string) slog.Handler { + newHandler := WASIHandler{ + Level: h.Level, + attrs: make([]slog.Attr, len(h.attrs)), + } + + copy(newHandler.attrs, h.attrs) + newHandler.group = name + + return newHandler +} diff --git a/protocol/generated/rpc/v1/executor.pb.go b/protocol/generated/rpc/v1/executor.pb.go new file mode 100644 index 0000000..acc7455 --- /dev/null +++ b/protocol/generated/rpc/v1/executor.pb.go @@ -0,0 +1,990 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc (unknown) +// source: rpc/v1/executor.proto + +package rpcv1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Buildr struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Repo *Buildr_Repo `protobuf:"bytes,1,opt,name=repo,proto3" json:"repo,omitempty"` + Github *Buildr_GitHub `protobuf:"bytes,2,opt,name=github,proto3" json:"github,omitempty"` +} + +func (x *Buildr) Reset() { + *x = Buildr{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_v1_executor_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Buildr) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Buildr) ProtoMessage() {} + +func (x *Buildr) ProtoReflect() protoreflect.Message { + mi := &file_rpc_v1_executor_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Buildr.ProtoReflect.Descriptor instead. +func (*Buildr) Descriptor() ([]byte, []int) { + return file_rpc_v1_executor_proto_rawDescGZIP(), []int{0} +} + +func (x *Buildr) GetRepo() *Buildr_Repo { + if x != nil { + return x.Repo + } + return nil +} + +func (x *Buildr) GetGithub() *Buildr_GitHub { + if x != nil { + return x.Github + } + return nil +} + +type ModuleReference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TaskId string `protobuf:"bytes,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` + ModuleCategory string `protobuf:"bytes,2,opt,name=module_category,json=moduleCategory,proto3" json:"module_category,omitempty"` + ModuleType string `protobuf:"bytes,3,opt,name=module_type,json=moduleType,proto3" json:"module_type,omitempty"` + ModuleName string `protobuf:"bytes,4,opt,name=module_name,json=moduleName,proto3" json:"module_name,omitempty"` +} + +func (x *ModuleReference) Reset() { + *x = ModuleReference{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_v1_executor_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ModuleReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ModuleReference) ProtoMessage() {} + +func (x *ModuleReference) ProtoReflect() protoreflect.Message { + mi := &file_rpc_v1_executor_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ModuleReference.ProtoReflect.Descriptor instead. +func (*ModuleReference) Descriptor() ([]byte, []int) { + return file_rpc_v1_executor_proto_rawDescGZIP(), []int{1} +} + +func (x *ModuleReference) GetTaskId() string { + if x != nil { + return x.TaskId + } + return "" +} + +func (x *ModuleReference) GetModuleCategory() string { + if x != nil { + return x.ModuleCategory + } + return "" +} + +func (x *ModuleReference) GetModuleType() string { + if x != nil { + return x.ModuleType + } + return "" +} + +func (x *ModuleReference) GetModuleName() string { + if x != nil { + return x.ModuleName + } + return "" +} + +type StartTaskRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Reference *ModuleReference `protobuf:"bytes,1,opt,name=reference,proto3" json:"reference,omitempty"` + Buildr *Buildr `protobuf:"bytes,2,opt,name=buildr,proto3" json:"buildr,omitempty"` + RawTask []byte `protobuf:"bytes,3,opt,name=raw_task,json=rawTask,proto3" json:"raw_task,omitempty"` +} + +func (x *StartTaskRequest) Reset() { + *x = StartTaskRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_v1_executor_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StartTaskRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StartTaskRequest) ProtoMessage() {} + +func (x *StartTaskRequest) ProtoReflect() protoreflect.Message { + mi := &file_rpc_v1_executor_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StartTaskRequest.ProtoReflect.Descriptor instead. +func (*StartTaskRequest) Descriptor() ([]byte, []int) { + return file_rpc_v1_executor_proto_rawDescGZIP(), []int{2} +} + +func (x *StartTaskRequest) GetReference() *ModuleReference { + if x != nil { + return x.Reference + } + return nil +} + +func (x *StartTaskRequest) GetBuildr() *Buildr { + if x != nil { + return x.Buildr + } + return nil +} + +func (x *StartTaskRequest) GetRawTask() []byte { + if x != nil { + return x.RawTask + } + return nil +} + +type TaskResult struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` + ModifiedFilesArchivePath string `protobuf:"bytes,2,opt,name=modified_files_archive_path,json=modifiedFilesArchivePath,proto3" json:"modified_files_archive_path,omitempty"` +} + +func (x *TaskResult) Reset() { + *x = TaskResult{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_v1_executor_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TaskResult) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TaskResult) ProtoMessage() {} + +func (x *TaskResult) ProtoReflect() protoreflect.Message { + mi := &file_rpc_v1_executor_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TaskResult.ProtoReflect.Descriptor instead. +func (*TaskResult) Descriptor() ([]byte, []int) { + return file_rpc_v1_executor_proto_rawDescGZIP(), []int{3} +} + +func (x *TaskResult) GetError() string { + if x != nil { + return x.Error + } + return "" +} + +func (x *TaskResult) GetModifiedFilesArchivePath() string { + if x != nil { + return x.ModifiedFilesArchivePath + } + return "" +} + +type TaskLog struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Time int64 `protobuf:"varint,1,opt,name=time,proto3" json:"time,omitempty"` + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + Level int32 `protobuf:"varint,3,opt,name=level,proto3" json:"level,omitempty"` + Attributes []*TaskLog_LogAttribute `protobuf:"bytes,4,rep,name=attributes,proto3" json:"attributes,omitempty"` +} + +func (x *TaskLog) Reset() { + *x = TaskLog{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_v1_executor_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TaskLog) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TaskLog) ProtoMessage() {} + +func (x *TaskLog) ProtoReflect() protoreflect.Message { + mi := &file_rpc_v1_executor_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TaskLog.ProtoReflect.Descriptor instead. +func (*TaskLog) Descriptor() ([]byte, []int) { + return file_rpc_v1_executor_proto_rawDescGZIP(), []int{4} +} + +func (x *TaskLog) GetTime() int64 { + if x != nil { + return x.Time + } + return 0 +} + +func (x *TaskLog) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +func (x *TaskLog) GetLevel() int32 { + if x != nil { + return x.Level + } + return 0 +} + +func (x *TaskLog) GetAttributes() []*TaskLog_LogAttribute { + if x != nil { + return x.Attributes + } + return nil +} + +type SetState struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` +} + +func (x *SetState) Reset() { + *x = SetState{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_v1_executor_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SetState) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SetState) ProtoMessage() {} + +func (x *SetState) ProtoReflect() protoreflect.Message { + mi := &file_rpc_v1_executor_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SetState.ProtoReflect.Descriptor instead. +func (*SetState) Descriptor() ([]byte, []int) { + return file_rpc_v1_executor_proto_rawDescGZIP(), []int{5} +} + +func (x *SetState) GetKey() []byte { + if x != nil { + return x.Key + } + return nil +} + +func (x *SetState) GetData() []byte { + if x != nil { + return x.Data + } + return nil +} + +type GetStateRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (x *GetStateRequest) Reset() { + *x = GetStateRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_v1_executor_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetStateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetStateRequest) ProtoMessage() {} + +func (x *GetStateRequest) ProtoReflect() protoreflect.Message { + mi := &file_rpc_v1_executor_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetStateRequest.ProtoReflect.Descriptor instead. +func (*GetStateRequest) Descriptor() ([]byte, []int) { + return file_rpc_v1_executor_proto_rawDescGZIP(), []int{6} +} + +func (x *GetStateRequest) GetKey() []byte { + if x != nil { + return x.Key + } + return nil +} + +type GetStateResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` +} + +func (x *GetStateResponse) Reset() { + *x = GetStateResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_v1_executor_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetStateResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetStateResponse) ProtoMessage() {} + +func (x *GetStateResponse) ProtoReflect() protoreflect.Message { + mi := &file_rpc_v1_executor_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetStateResponse.ProtoReflect.Descriptor instead. +func (*GetStateResponse) Descriptor() ([]byte, []int) { + return file_rpc_v1_executor_proto_rawDescGZIP(), []int{7} +} + +func (x *GetStateResponse) GetKey() []byte { + if x != nil { + return x.Key + } + return nil +} + +func (x *GetStateResponse) GetData() []byte { + if x != nil { + return x.Data + } + return nil +} + +type Result struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` +} + +func (x *Result) Reset() { + *x = Result{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_v1_executor_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Result) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Result) ProtoMessage() {} + +func (x *Result) ProtoReflect() protoreflect.Message { + mi := &file_rpc_v1_executor_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Result.ProtoReflect.Descriptor instead. +func (*Result) Descriptor() ([]byte, []int) { + return file_rpc_v1_executor_proto_rawDescGZIP(), []int{8} +} + +func (x *Result) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +func (x *Result) GetError() string { + if x != nil { + return x.Error + } + return "" +} + +type Buildr_Repo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Root string `protobuf:"bytes,1,opt,name=root,proto3" json:"root,omitempty"` +} + +func (x *Buildr_Repo) Reset() { + *x = Buildr_Repo{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_v1_executor_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Buildr_Repo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Buildr_Repo) ProtoMessage() {} + +func (x *Buildr_Repo) ProtoReflect() protoreflect.Message { + mi := &file_rpc_v1_executor_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Buildr_Repo.ProtoReflect.Descriptor instead. +func (*Buildr_Repo) Descriptor() ([]byte, []int) { + return file_rpc_v1_executor_proto_rawDescGZIP(), []int{0, 0} +} + +func (x *Buildr_Repo) GetRoot() string { + if x != nil { + return x.Root + } + return "" +} + +type Buildr_GitHub struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ApiToken string `protobuf:"bytes,1,opt,name=api_token,json=apiToken,proto3" json:"api_token,omitempty"` +} + +func (x *Buildr_GitHub) Reset() { + *x = Buildr_GitHub{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_v1_executor_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Buildr_GitHub) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Buildr_GitHub) ProtoMessage() {} + +func (x *Buildr_GitHub) ProtoReflect() protoreflect.Message { + mi := &file_rpc_v1_executor_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Buildr_GitHub.ProtoReflect.Descriptor instead. +func (*Buildr_GitHub) Descriptor() ([]byte, []int) { + return file_rpc_v1_executor_proto_rawDescGZIP(), []int{0, 1} +} + +func (x *Buildr_GitHub) GetApiToken() string { + if x != nil { + return x.ApiToken + } + return "" +} + +type TaskLog_LogAttribute struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *TaskLog_LogAttribute) Reset() { + *x = TaskLog_LogAttribute{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_v1_executor_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TaskLog_LogAttribute) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TaskLog_LogAttribute) ProtoMessage() {} + +func (x *TaskLog_LogAttribute) ProtoReflect() protoreflect.Message { + mi := &file_rpc_v1_executor_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TaskLog_LogAttribute.ProtoReflect.Descriptor instead. +func (*TaskLog_LogAttribute) Descriptor() ([]byte, []int) { + return file_rpc_v1_executor_proto_rawDescGZIP(), []int{4, 0} +} + +func (x *TaskLog_LogAttribute) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +func (x *TaskLog_LogAttribute) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +var File_rpc_v1_executor_proto protoreflect.FileDescriptor + +var file_rpc_v1_executor_proto_rawDesc = []byte{ + 0x0a, 0x15, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x6f, + 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x72, 0x2e, + 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x22, 0xb1, 0x01, 0x0a, 0x06, 0x42, 0x75, 0x69, 0x6c, 0x64, + 0x72, 0x12, 0x2e, 0x0a, 0x04, 0x72, 0x65, 0x70, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1a, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x72, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, + 0x42, 0x75, 0x69, 0x6c, 0x64, 0x72, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x52, 0x04, 0x72, 0x65, 0x70, + 0x6f, 0x12, 0x34, 0x0a, 0x06, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1c, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x72, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x76, + 0x31, 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x72, 0x2e, 0x47, 0x69, 0x74, 0x48, 0x75, 0x62, 0x52, + 0x06, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x1a, 0x1a, 0x0a, 0x04, 0x52, 0x65, 0x70, 0x6f, 0x12, + 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, + 0x6f, 0x6f, 0x74, 0x1a, 0x25, 0x0a, 0x06, 0x47, 0x69, 0x74, 0x48, 0x75, 0x62, 0x12, 0x1b, 0x0a, + 0x09, 0x61, 0x70, 0x69, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x61, 0x70, 0x69, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x95, 0x01, 0x0a, 0x0f, 0x4d, + 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x17, + 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x0f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, + 0x65, 0x5f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, + 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x4e, 0x61, + 0x6d, 0x65, 0x22, 0x9a, 0x01, 0x0a, 0x10, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x61, 0x73, 0x6b, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3c, 0x0a, 0x09, 0x72, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x62, 0x75, 0x69, + 0x6c, 0x64, 0x72, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, + 0x65, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x66, 0x65, + 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x2d, 0x0a, 0x06, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x72, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x72, 0x2e, 0x72, + 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x72, 0x52, 0x06, 0x62, 0x75, + 0x69, 0x6c, 0x64, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x72, 0x61, 0x77, 0x5f, 0x74, 0x61, 0x73, 0x6b, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x72, 0x61, 0x77, 0x54, 0x61, 0x73, 0x6b, 0x22, + 0x61, 0x0a, 0x0a, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x14, 0x0a, + 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, + 0x72, 0x6f, 0x72, 0x12, 0x3d, 0x0a, 0x1b, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x5f, + 0x66, 0x69, 0x6c, 0x65, 0x73, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x5f, 0x70, 0x61, + 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x18, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, + 0x65, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x50, 0x61, + 0x74, 0x68, 0x22, 0xca, 0x01, 0x0a, 0x07, 0x54, 0x61, 0x73, 0x6b, 0x4c, 0x6f, 0x67, 0x12, 0x12, + 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x74, 0x69, + 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, + 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, 0x76, + 0x65, 0x6c, 0x12, 0x43, 0x0a, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, + 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x72, 0x2e, + 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x4c, 0x6f, 0x67, 0x2e, 0x4c, + 0x6f, 0x67, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x52, 0x0a, 0x61, 0x74, 0x74, + 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x1a, 0x36, 0x0a, 0x0c, 0x4c, 0x6f, 0x67, 0x41, 0x74, + 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, + 0x30, 0x0a, 0x08, 0x53, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, + 0x61, 0x22, 0x23, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x38, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, + 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, + 0x22, 0x38, 0x0a, 0x06, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, + 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, + 0x63, 0x65, 0x73, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x42, 0xb6, 0x01, 0x0a, 0x11, 0x63, + 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x72, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, + 0x42, 0x0d, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, + 0x01, 0x5a, 0x3c, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x69, 0x63, 0x62, 0x34, 0x64, 0x63, 0x30, 0x2e, + 0x64, 0x65, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x72, 0x2f, 0x77, 0x61, 0x73, 0x69, 0x2d, 0x6d, + 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x61, 0x6c, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x31, 0x3b, 0x72, 0x70, 0x63, 0x76, 0x31, 0xa2, + 0x02, 0x03, 0x42, 0x52, 0x58, 0xaa, 0x02, 0x0d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x72, 0x2e, 0x52, + 0x70, 0x63, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0d, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x72, 0x5c, 0x52, + 0x70, 0x63, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x19, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x72, 0x5c, 0x52, + 0x70, 0x63, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0xea, 0x02, 0x0f, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x72, 0x3a, 0x3a, 0x52, 0x70, 0x63, 0x3a, + 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_rpc_v1_executor_proto_rawDescOnce sync.Once + file_rpc_v1_executor_proto_rawDescData = file_rpc_v1_executor_proto_rawDesc +) + +func file_rpc_v1_executor_proto_rawDescGZIP() []byte { + file_rpc_v1_executor_proto_rawDescOnce.Do(func() { + file_rpc_v1_executor_proto_rawDescData = protoimpl.X.CompressGZIP(file_rpc_v1_executor_proto_rawDescData) + }) + return file_rpc_v1_executor_proto_rawDescData +} + +var file_rpc_v1_executor_proto_msgTypes = make([]protoimpl.MessageInfo, 12) +var file_rpc_v1_executor_proto_goTypes = []interface{}{ + (*Buildr)(nil), // 0: buildr.rpc.v1.Buildr + (*ModuleReference)(nil), // 1: buildr.rpc.v1.ModuleReference + (*StartTaskRequest)(nil), // 2: buildr.rpc.v1.StartTaskRequest + (*TaskResult)(nil), // 3: buildr.rpc.v1.TaskResult + (*TaskLog)(nil), // 4: buildr.rpc.v1.TaskLog + (*SetState)(nil), // 5: buildr.rpc.v1.SetState + (*GetStateRequest)(nil), // 6: buildr.rpc.v1.GetStateRequest + (*GetStateResponse)(nil), // 7: buildr.rpc.v1.GetStateResponse + (*Result)(nil), // 8: buildr.rpc.v1.Result + (*Buildr_Repo)(nil), // 9: buildr.rpc.v1.Buildr.Repo + (*Buildr_GitHub)(nil), // 10: buildr.rpc.v1.Buildr.GitHub + (*TaskLog_LogAttribute)(nil), // 11: buildr.rpc.v1.TaskLog.LogAttribute +} +var file_rpc_v1_executor_proto_depIdxs = []int32{ + 9, // 0: buildr.rpc.v1.Buildr.repo:type_name -> buildr.rpc.v1.Buildr.Repo + 10, // 1: buildr.rpc.v1.Buildr.github:type_name -> buildr.rpc.v1.Buildr.GitHub + 1, // 2: buildr.rpc.v1.StartTaskRequest.reference:type_name -> buildr.rpc.v1.ModuleReference + 0, // 3: buildr.rpc.v1.StartTaskRequest.buildr:type_name -> buildr.rpc.v1.Buildr + 11, // 4: buildr.rpc.v1.TaskLog.attributes:type_name -> buildr.rpc.v1.TaskLog.LogAttribute + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name +} + +func init() { file_rpc_v1_executor_proto_init() } +func file_rpc_v1_executor_proto_init() { + if File_rpc_v1_executor_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_rpc_v1_executor_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Buildr); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_v1_executor_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ModuleReference); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_v1_executor_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StartTaskRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_v1_executor_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TaskResult); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_v1_executor_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TaskLog); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_v1_executor_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SetState); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_v1_executor_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetStateRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_v1_executor_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetStateResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_v1_executor_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Result); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_v1_executor_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Buildr_Repo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_v1_executor_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Buildr_GitHub); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_v1_executor_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TaskLog_LogAttribute); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_rpc_v1_executor_proto_rawDesc, + NumEnums: 0, + NumMessages: 12, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_rpc_v1_executor_proto_goTypes, + DependencyIndexes: file_rpc_v1_executor_proto_depIdxs, + MessageInfos: file_rpc_v1_executor_proto_msgTypes, + }.Build() + File_rpc_v1_executor_proto = out.File + file_rpc_v1_executor_proto_rawDesc = nil + file_rpc_v1_executor_proto_goTypes = nil + file_rpc_v1_executor_proto_depIdxs = nil +} diff --git a/protocol/generated/rpc/v1/executor_vtproto.pb.go b/protocol/generated/rpc/v1/executor_vtproto.pb.go new file mode 100644 index 0000000..d2ff18b --- /dev/null +++ b/protocol/generated/rpc/v1/executor_vtproto.pb.go @@ -0,0 +1,2375 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: v0.4.0 +// source: rpc/v1/executor.proto + +package rpcv1 + +import ( + fmt "fmt" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + bits "math/bits" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +func (m *Buildr_Repo) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Buildr_Repo) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Buildr_Repo) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Root) > 0 { + i -= len(m.Root) + copy(dAtA[i:], m.Root) + i = encodeVarint(dAtA, i, uint64(len(m.Root))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Buildr_GitHub) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Buildr_GitHub) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Buildr_GitHub) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.ApiToken) > 0 { + i -= len(m.ApiToken) + copy(dAtA[i:], m.ApiToken) + i = encodeVarint(dAtA, i, uint64(len(m.ApiToken))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Buildr) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Buildr) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Buildr) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Github != nil { + size, err := m.Github.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + if m.Repo != nil { + size, err := m.Repo.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ModuleReference) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ModuleReference) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *ModuleReference) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.ModuleName) > 0 { + i -= len(m.ModuleName) + copy(dAtA[i:], m.ModuleName) + i = encodeVarint(dAtA, i, uint64(len(m.ModuleName))) + i-- + dAtA[i] = 0x22 + } + if len(m.ModuleType) > 0 { + i -= len(m.ModuleType) + copy(dAtA[i:], m.ModuleType) + i = encodeVarint(dAtA, i, uint64(len(m.ModuleType))) + i-- + dAtA[i] = 0x1a + } + if len(m.ModuleCategory) > 0 { + i -= len(m.ModuleCategory) + copy(dAtA[i:], m.ModuleCategory) + i = encodeVarint(dAtA, i, uint64(len(m.ModuleCategory))) + i-- + dAtA[i] = 0x12 + } + if len(m.TaskId) > 0 { + i -= len(m.TaskId) + copy(dAtA[i:], m.TaskId) + i = encodeVarint(dAtA, i, uint64(len(m.TaskId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *StartTaskRequest) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StartTaskRequest) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *StartTaskRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.RawTask) > 0 { + i -= len(m.RawTask) + copy(dAtA[i:], m.RawTask) + i = encodeVarint(dAtA, i, uint64(len(m.RawTask))) + i-- + dAtA[i] = 0x1a + } + if m.Buildr != nil { + size, err := m.Buildr.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + if m.Reference != nil { + size, err := m.Reference.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *TaskResult) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TaskResult) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *TaskResult) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.ModifiedFilesArchivePath) > 0 { + i -= len(m.ModifiedFilesArchivePath) + copy(dAtA[i:], m.ModifiedFilesArchivePath) + i = encodeVarint(dAtA, i, uint64(len(m.ModifiedFilesArchivePath))) + i-- + dAtA[i] = 0x12 + } + if len(m.Error) > 0 { + i -= len(m.Error) + copy(dAtA[i:], m.Error) + i = encodeVarint(dAtA, i, uint64(len(m.Error))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *TaskLog_LogAttribute) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TaskLog_LogAttribute) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *TaskLog_LogAttribute) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarint(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarint(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *TaskLog) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TaskLog) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *TaskLog) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Attributes) > 0 { + for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Attributes[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 + } + } + if m.Level != 0 { + i = encodeVarint(dAtA, i, uint64(m.Level)) + i-- + dAtA[i] = 0x18 + } + if len(m.Message) > 0 { + i -= len(m.Message) + copy(dAtA[i:], m.Message) + i = encodeVarint(dAtA, i, uint64(len(m.Message))) + i-- + dAtA[i] = 0x12 + } + if m.Time != 0 { + i = encodeVarint(dAtA, i, uint64(m.Time)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *SetState) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SetState) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SetState) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarint(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarint(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *GetStateRequest) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetStateRequest) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *GetStateRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarint(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *GetStateResponse) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetStateResponse) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *GetStateResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarint(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarint(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Result) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Result) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Result) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Error) > 0 { + i -= len(m.Error) + copy(dAtA[i:], m.Error) + i = encodeVarint(dAtA, i, uint64(len(m.Error))) + i-- + dAtA[i] = 0x12 + } + if m.Success { + i-- + if m.Success { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarint(dAtA []byte, offset int, v uint64) int { + offset -= sov(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Buildr_Repo) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Root) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *Buildr_GitHub) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ApiToken) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *Buildr) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Repo != nil { + l = m.Repo.SizeVT() + n += 1 + l + sov(uint64(l)) + } + if m.Github != nil { + l = m.Github.SizeVT() + n += 1 + l + sov(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *ModuleReference) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.TaskId) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + l = len(m.ModuleCategory) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + l = len(m.ModuleType) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + l = len(m.ModuleName) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *StartTaskRequest) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Reference != nil { + l = m.Reference.SizeVT() + n += 1 + l + sov(uint64(l)) + } + if m.Buildr != nil { + l = m.Buildr.SizeVT() + n += 1 + l + sov(uint64(l)) + } + l = len(m.RawTask) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *TaskResult) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Error) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + l = len(m.ModifiedFilesArchivePath) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *TaskLog_LogAttribute) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *TaskLog) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Time != 0 { + n += 1 + sov(uint64(m.Time)) + } + l = len(m.Message) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + if m.Level != 0 { + n += 1 + sov(uint64(m.Level)) + } + if len(m.Attributes) > 0 { + for _, e := range m.Attributes { + l = e.SizeVT() + n += 1 + l + sov(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *SetState) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *GetStateRequest) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *GetStateResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *Result) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Success { + n += 2 + } + l = len(m.Error) + if l > 0 { + n += 1 + l + sov(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func sov(x uint64) (n int) { + return (bits.Len64(x|1) + 6) / 7 +} +func soz(x uint64) (n int) { + return sov(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Buildr_Repo) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Buildr_Repo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Buildr_Repo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Root", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Root = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Buildr_GitHub) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Buildr_GitHub: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Buildr_GitHub: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ApiToken", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ApiToken = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Buildr) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Buildr: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Buildr: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Repo", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Repo == nil { + m.Repo = &Buildr_Repo{} + } + if err := m.Repo.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Github", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Github == nil { + m.Github = &Buildr_GitHub{} + } + if err := m.Github.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ModuleReference) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ModuleReference: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ModuleReference: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TaskId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TaskId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ModuleCategory", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ModuleCategory = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ModuleType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ModuleType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ModuleName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ModuleName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StartTaskRequest) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StartTaskRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StartTaskRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Reference", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Reference == nil { + m.Reference = &ModuleReference{} + } + if err := m.Reference.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Buildr", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Buildr == nil { + m.Buildr = &Buildr{} + } + if err := m.Buildr.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RawTask", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RawTask = append(m.RawTask[:0], dAtA[iNdEx:postIndex]...) + if m.RawTask == nil { + m.RawTask = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TaskResult) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TaskResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TaskResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Error = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ModifiedFilesArchivePath", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ModifiedFilesArchivePath = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TaskLog_LogAttribute) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TaskLog_LogAttribute: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TaskLog_LogAttribute: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TaskLog) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TaskLog: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TaskLog: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) + } + m.Time = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Time |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Message = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Level", wireType) + } + m.Level = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Level |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Attributes = append(m.Attributes, &TaskLog_LogAttribute{}) + if err := m.Attributes[len(m.Attributes)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SetState) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SetState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SetState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetStateRequest) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetStateRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetStateRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetStateResponse) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetStateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetStateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Result) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Result: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Result: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Success", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Success = bool(v != 0) + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Error = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func skip(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflow + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLength + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroup + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLength + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLength = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflow = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroup = fmt.Errorf("proto: unexpected end of group") +) diff --git a/registry.go b/registry.go new file mode 100644 index 0000000..f9bb151 --- /dev/null +++ b/registry.go @@ -0,0 +1,47 @@ +package sdk + +import ( + "fmt" + "sync" +) + +type Registration interface { + RegisterAt(registry *TypeRegistry) +} + +type RegistrationFunc func(registry *TypeRegistry) + +func (f RegistrationFunc) RegisterAt(registry *TypeRegistry) { + f(registry) +} + +func NewTypeRegistry() *TypeRegistry { + return &TypeRegistry{ + registrations: make(map[string]Factory), + } +} + +type TypeRegistry struct { + lock sync.Mutex + registrations map[string]Factory +} + +func (r *TypeRegistry) Add(cat Category, moduleName string, factory Factory) { + r.lock.Lock() + defer r.lock.Unlock() + + r.registrations[specOf(cat, moduleName)] = factory +} + +func (r *TypeRegistry) Get(cat Category, moduleName string) Module { + f, ok := r.registrations[specOf(cat, moduleName)] + if !ok { + return nil + } + + return f.Create() +} + +func specOf(cat Category, moduleName string) string { + return fmt.Sprintf("%s/%s", cat.String(), moduleName) +} diff --git a/state_proxy.go b/state_proxy.go new file mode 100644 index 0000000..356f783 --- /dev/null +++ b/state_proxy.go @@ -0,0 +1,67 @@ +package sdk + +import ( + "code.icb4dc0.de/buildr/wasi-module-sdk/internal/mem" + rpcv1 "code.icb4dc0.de/buildr/wasi-module-sdk/protocol/generated/rpc/v1" + "errors" +) + +type StateProxy struct { +} + +func (s StateProxy) Set(key, state []byte) error { + setCmd := &rpcv1.SetState{ + Key: key, + Data: state, + } + data, err := setCmd.MarshalVT() + if err != nil { + return err + } + + result := _set_state(mem.DataToManagedPtr(data)) + if result == 0 { + return errors.New("unknown error occurred") + } + resultPtr := uint32(result >> 32) + resultSize := uint32(result) + + resultMsg := new(rpcv1.Result) + if err := resultMsg.UnmarshalVT(mem.PtrToData(resultPtr, resultSize)); err != nil { + return err + } + + if !resultMsg.Success { + if resultMsg.Error != "" { + return errors.New(resultMsg.Error) + } + return errors.New("unknown error occurred") + } + + return nil +} + +func (s StateProxy) Get(key []byte) (state []byte, meta StateMetadata, err error) { + getCmd := &rpcv1.GetStateRequest{ + Key: key, + } + + data, err := getCmd.MarshalVT() + if err != nil { + return nil, StateMetadata{}, err + } + + result := _get_state(mem.DataToManagedPtr(data)) + if result == 0 { + return nil, StateMetadata{}, errors.New("error occurred while processing request") + } + resultPtr := uint32(result >> 32) + resultSize := uint32(result) + + getStateResult := new(rpcv1.GetStateResponse) + if err := getStateResult.UnmarshalVT(mem.PtrToData(resultPtr, resultSize)); err != nil { + return nil, StateMetadata{}, err + } + + return getStateResult.Data, StateMetadata{}, nil +} diff --git a/test/test_host.go b/test/test_host.go deleted file mode 100644 index 08a67fe..0000000 --- a/test/test_host.go +++ /dev/null @@ -1,62 +0,0 @@ -package test - -import ( - rpcv1 "buf.build/gen/go/buildr/buildr/protocolbuffers/go/rpc/v1" - "context" - "errors" - "github.com/tetratelabs/wazero" - "github.com/tetratelabs/wazero/api" - "github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1" - "golang.org/x/exp/slog" - "google.golang.org/protobuf/proto" -) - -type Host struct { - Logger *slog.Logger -} - -func (h *Host) Run(ctx context.Context) (err error) { - r := wazero.NewRuntime(ctx) - defer r.Close(context.Background()) - - _, err = r.NewHostModuleBuilder("test"). - NewFunctionBuilder().WithFunc(h.log).Export("log"). - Instantiate(ctx) - - if err != nil { - return err - } - - closer, err := wasi_snapshot_preview1.Instantiate(ctx, r) - if err != nil { - return err - } - - defer func() { - err = errors.Join(err, closer.Close(context.Background())) - }() - - return nil -} - -func (h *Host) log(ctx context.Context, m api.Module, offset, byteCount uint32) { - buf, ok := m.Memory().Read(offset, byteCount) - if !ok { - return - } - - var taskLog *rpcv1.TaskLog - if err := proto.Unmarshal(buf, taskLog); err != nil { - h.Logger.Warn("failed to unmarshal task log", slog.String("err", err.Error())) - return - } - - rec := slog.NewRecord(taskLog.Time.AsTime(), slog.Level(taskLog.Level), taskLog.Message, -1) - - for i := range taskLog.Attributes { - attr := taskLog.Attributes[i] - rec.AddAttrs(slog.String(attr.Key, attr.Value)) - } - - _ = h.Logger.Handler().Handle(ctx, rec) -}