restate-sdk 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Cargo.lock +1040 -0
- data/Cargo.toml +8 -0
- data/LICENSE +21 -0
- data/README.md +133 -0
- data/ext/restate_internal/Cargo.toml +16 -0
- data/ext/restate_internal/extconf.rb +4 -0
- data/ext/restate_internal/src/lib.rs +1094 -0
- data/lib/restate/context.rb +336 -0
- data/lib/restate/discovery.rb +150 -0
- data/lib/restate/durable_future.rb +131 -0
- data/lib/restate/endpoint.rb +69 -0
- data/lib/restate/errors.rb +60 -0
- data/lib/restate/handler.rb +51 -0
- data/lib/restate/serde.rb +313 -0
- data/lib/restate/server.rb +280 -0
- data/lib/restate/server_context.rb +812 -0
- data/lib/restate/service.rb +37 -0
- data/lib/restate/service_dsl.rb +243 -0
- data/lib/restate/testing.rb +197 -0
- data/lib/restate/version.rb +6 -0
- data/lib/restate/virtual_object.rb +58 -0
- data/lib/restate/vm.rb +325 -0
- data/lib/restate/workflow.rb +57 -0
- data/lib/restate.rb +130 -0
- data/lib/tapioca/dsl/compilers/restate.rb +45 -0
- metadata +127 -0
data/Cargo.toml
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Restate Software, Inc., Restate GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
[](https://docs.restate.dev)
|
|
2
|
+
[](https://github.com/restatedev/examples)
|
|
3
|
+
[](https://discord.gg/skW3AZ6uGd)
|
|
4
|
+
[](https://twitter.com/intent/follow?screen_name=restatedev)
|
|
5
|
+
|
|
6
|
+
# Restate Ruby SDK
|
|
7
|
+
|
|
8
|
+
[Restate](https://restate.dev/) is a system for easily building resilient applications using *distributed durable async/await*. This repository contains the Restate SDK for writing services in **Ruby**.
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
require 'restate'
|
|
12
|
+
|
|
13
|
+
class Greeter < Restate::Service
|
|
14
|
+
handler def greet(name)
|
|
15
|
+
ctx = Restate.current_context
|
|
16
|
+
ctx.run_sync('build-greeting') { "Hello, #{name}!" }
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Community
|
|
22
|
+
|
|
23
|
+
* [Join our online community](https://discord.gg/skW3AZ6uGd) for help, sharing feedback and talking to the community.
|
|
24
|
+
* [Check out our documentation](https://docs.restate.dev) to get quickly started!
|
|
25
|
+
* [Follow us on Twitter](https://twitter.com/restatedev) for staying up to date.
|
|
26
|
+
* [Create a GitHub issue](https://github.com/restatedev/sdk-ruby/issues) for requesting a new feature or reporting a problem.
|
|
27
|
+
* [Visit our GitHub org](https://github.com/restatedev) for exploring other repositories.
|
|
28
|
+
|
|
29
|
+
## Using the SDK
|
|
30
|
+
|
|
31
|
+
**Prerequisites:**
|
|
32
|
+
- Ruby >= 3.1
|
|
33
|
+
|
|
34
|
+
For brand-new projects, we recommend using the [Restate Ruby Template](template/):
|
|
35
|
+
|
|
36
|
+
```shell
|
|
37
|
+
cp -r template/ my-restate-service
|
|
38
|
+
cd my-restate-service
|
|
39
|
+
bundle install
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Or add the gem to an existing project:
|
|
43
|
+
|
|
44
|
+
```shell
|
|
45
|
+
gem install restate-sdk
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Typed handlers with T::Struct
|
|
49
|
+
|
|
50
|
+
Use Sorbet's `T::Struct` for typed input/output with automatic JSON Schema generation:
|
|
51
|
+
|
|
52
|
+
```ruby
|
|
53
|
+
require 'restate'
|
|
54
|
+
|
|
55
|
+
class RegistrationRequest < T::Struct
|
|
56
|
+
const :event_name, String
|
|
57
|
+
const :attendee, String
|
|
58
|
+
const :num_guests, Integer
|
|
59
|
+
const :note, T.nilable(String)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
class RegistrationResponse < T::Struct
|
|
63
|
+
const :registration_id, String
|
|
64
|
+
const :status, String
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
class EventService < Restate::Service
|
|
68
|
+
handler :register, input: RegistrationRequest, output: RegistrationResponse
|
|
69
|
+
def register(request)
|
|
70
|
+
ctx = Restate.current_context
|
|
71
|
+
|
|
72
|
+
registration_id = ctx.run_sync('create-registration') do
|
|
73
|
+
"reg_#{request.event_name}_#{rand(10_000)}"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
RegistrationResponse.new(
|
|
77
|
+
registration_id: registration_id,
|
|
78
|
+
status: 'confirmed'
|
|
79
|
+
)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
See more in the [User Guide](docs/USER_GUIDE.md) and the [examples/](examples/) directory.
|
|
85
|
+
|
|
86
|
+
## Contributing
|
|
87
|
+
|
|
88
|
+
We're excited if you join the Restate community and start contributing!
|
|
89
|
+
Whether it is feature requests, bug reports, ideas & feedback or PRs, we appreciate any and all contributions.
|
|
90
|
+
We know that your time is precious and, therefore, deeply value any effort to contribute!
|
|
91
|
+
|
|
92
|
+
### Local development
|
|
93
|
+
|
|
94
|
+
* Ruby >= 3.1
|
|
95
|
+
* [Rust toolchain](https://rustup.rs/)
|
|
96
|
+
* Docker (for integration tests)
|
|
97
|
+
* Java 21+ (for sdk-test-suite integration tests)
|
|
98
|
+
|
|
99
|
+
Install dependencies and build:
|
|
100
|
+
|
|
101
|
+
```shell
|
|
102
|
+
bundle install
|
|
103
|
+
make build
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Run the full verification suite (build, lint, typecheck, tests):
|
|
107
|
+
|
|
108
|
+
```shell
|
|
109
|
+
make verify
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Run integration tests (requires Docker + Java 21+):
|
|
113
|
+
|
|
114
|
+
```shell
|
|
115
|
+
make test-integration
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Releasing the package
|
|
119
|
+
|
|
120
|
+
Pull latest main:
|
|
121
|
+
|
|
122
|
+
```shell
|
|
123
|
+
git checkout main && git pull
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Update the version in `lib/restate/version.rb`, commit it. Then push a tag:
|
|
127
|
+
|
|
128
|
+
```shell
|
|
129
|
+
git tag -m "Release v0.1.0" v0.1.0
|
|
130
|
+
git push origin v0.1.0
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
The [release workflow](.github/workflows/release.yml) will build pre-compiled native gems for all platforms (x86_64/aarch64 Linux, macOS, musl) and publish them to RubyGems.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "restate_internal"
|
|
3
|
+
version = "0.4.3"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
publish = false
|
|
6
|
+
|
|
7
|
+
[lib]
|
|
8
|
+
name = "restate_internal"
|
|
9
|
+
crate-type = ["cdylib"]
|
|
10
|
+
doc = false
|
|
11
|
+
|
|
12
|
+
[dependencies]
|
|
13
|
+
magnus = { version = "0.8", features = ["rb-sys"] }
|
|
14
|
+
rb-sys = { version = "0.9", features = ["stable-api-compiled-fallback"] }
|
|
15
|
+
restate-sdk-shared-core = { version = "=0.7.0", features = ["request_identity", "sha2_random_seed"] }
|
|
16
|
+
tracing-subscriber = { version = "0.3", features = ["fmt", "env-filter"] }
|