-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add protoc-gen-go-restate * Split out the selector proto * Rename handler and service type options * Add to readme re options
- Loading branch information
1 parent
adae520
commit 8eb988a
Showing
45 changed files
with
2,476 additions
and
1,282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
version: v1 | ||
version: v2 | ||
managed: | ||
enabled: true | ||
go_package_prefix: | ||
default: github.com/restatedev/sdk-go/generated | ||
override: | ||
- file_option: go_package_prefix | ||
value: github.com/restatedev/sdk-go/generated | ||
plugins: | ||
- plugin: go | ||
- remote: buf.build/protocolbuffers/go:v1.34.2 | ||
out: generated | ||
opt: paths=source_relative | ||
inputs: | ||
- module: buf.build/restatedev/service-protocol | ||
- directory: proto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,2 @@ | ||
# Generated by buf. DO NOT EDIT. | ||
version: v1 | ||
deps: | ||
- remote: buf.build | ||
owner: restatedev | ||
repository: proto | ||
commit: 6ea2d15aed8f408590a1465844df5a8e | ||
digest: shake256:e6599809ff13490a631f87d1a4b13ef1886d1bd1c0aa001ccb92806c0acc373d047a6ead761f8a21dfbd57a4fd9acd5915a52e47bd5b4e4a02dd1766f78511b3 | ||
version: v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: v2 | ||
managed: | ||
enabled: true | ||
plugins: | ||
- remote: buf.build/protocolbuffers/go:v1.34.2 | ||
out: . | ||
opt: paths=source_relative | ||
- local: | ||
- docker | ||
- run | ||
- --pull=always | ||
- -i | ||
- ghcr.io/restatedev/protoc-gen-go-restate:latest | ||
out: . | ||
opt: paths=source_relative | ||
inputs: | ||
- directory: . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Generated by buf. DO NOT EDIT. | ||
version: v2 | ||
deps: | ||
- name: buf.build/restatedev/sdk-go | ||
commit: 9ea0b54286dd4f35b0cb96ecdf09b402 | ||
digest: b5:822b9362e943c827c36e44b0db519542259439382f94817989349d0ee590617ba70e35975840c5d96ceff278254806435e7d570db81548f9703c00b01eec398e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: v2 | ||
lint: | ||
use: | ||
- DEFAULT | ||
breaking: | ||
use: | ||
- FILE | ||
deps: | ||
- buf.build/restatedev/sdk-go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"fmt" | ||
"log/slog" | ||
"os" | ||
|
||
restate "github.com/restatedev/sdk-go" | ||
helloworld "github.com/restatedev/sdk-go/examples/codegen/proto" | ||
"github.com/restatedev/sdk-go/server" | ||
) | ||
|
||
type greeter struct { | ||
helloworld.UnimplementedGreeterServer | ||
} | ||
|
||
func (greeter) SayHello(ctx restate.Context, req *helloworld.HelloRequest) (*helloworld.HelloResponse, error) { | ||
counter := helloworld.NewCounterClient(ctx, req.Name) | ||
count, err := counter.Add(). | ||
Request(&helloworld.AddRequest{Delta: 1}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &helloworld.HelloResponse{ | ||
Message: fmt.Sprintf("Hello, %s! Call number: %d", req.Name, count.Value), | ||
}, nil | ||
} | ||
|
||
type counter struct { | ||
helloworld.UnimplementedCounterServer | ||
} | ||
|
||
func (c counter) Add(ctx restate.ObjectContext, req *helloworld.AddRequest) (*helloworld.GetResponse, error) { | ||
count, err := restate.GetAs[int64](ctx, "counter") | ||
if err != nil && !errors.Is(err, restate.ErrKeyNotFound) { | ||
return nil, err | ||
} | ||
|
||
count += 1 | ||
if err := ctx.Set("counter", count); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &helloworld.GetResponse{Value: count}, nil | ||
} | ||
|
||
func (c counter) Get(ctx restate.ObjectSharedContext, _ *helloworld.GetRequest) (*helloworld.GetResponse, error) { | ||
count, err := restate.GetAs[int64](ctx, "counter") | ||
if err != nil && !errors.Is(err, restate.ErrKeyNotFound) { | ||
return nil, err | ||
} | ||
|
||
return &helloworld.GetResponse{Value: count}, nil | ||
} | ||
|
||
func main() { | ||
server := server.NewRestate(). | ||
Bind(helloworld.NewGreeterServer(greeter{})). | ||
Bind(helloworld.NewCounterServer(counter{})) | ||
|
||
if err := server.Start(context.Background(), ":9080"); err != nil { | ||
slog.Error("application exited unexpectedly", "err", err.Error()) | ||
os.Exit(1) | ||
} | ||
} |
Oops, something went wrong.