|
1 | 1 | # Temporal Ruby SDK
|
2 | 2 |
|
3 |
| - |
| 3 | +[](https://github.com/temporalio/sdk-ruby/actions/workflows/ci.yml?query=branch%3Amain) |
| 4 | +[](https://github.com/temporalio/sdk-ruby/actions/workflows/build-native-ext.yml?query=branch%3Amain+event%3Arelease) |
| 5 | +[](https://rubygems.org/gems/temporalio) |
4 | 6 |
|
5 |
| -Temporal is a distributed, scalable, durable, and highly available orchestration engine used to |
6 |
| -execute asynchronous long-running business logic in a scalable and resilient way. |
| 7 | +[Temporal](https://temporal.io/) is a distributed, scalable, durable, and highly available |
| 8 | +orchestration engine used to execute asynchronous long-running business logic in a scalable and |
| 9 | +resilient way. |
7 | 10 |
|
8 | 11 | "Temporal Ruby SDK" is the framework for authoring workflows and activities using the Ruby
|
9 | 12 | programming language.
|
10 | 13 |
|
11 | 14 | ⚠️ UNDER DEVELOPMENT
|
12 | 15 |
|
| 16 | +The Ruby SDK is under development. There are no compatibility guarantees at this time. |
| 17 | + |
| 18 | +At this point the SDK only supports the **Temporal Client** capabilities: |
| 19 | + |
| 20 | +- Starting a workflow (defined in any other SDK) |
| 21 | +- Interacting with a workflow (cancelling, querying, signalling, etc) |
| 22 | +- Interceptor and Data Conversion support |
| 23 | +- gRPC access to Temporal Server |
| 24 | +- Temporal Cloud is not yet supported due to the lack of TLS support, but it's coming soon |
| 25 | + |
| 26 | + |
| 27 | +## Quick Start |
| 28 | + |
| 29 | +### Installation |
| 30 | + |
| 31 | +Add the [`temporalio` gem](https://rubygems.org/gems/temporalio) to your Gemfile: |
| 32 | + |
| 33 | +```ruby |
| 34 | +gem 'temporalio' |
| 35 | +``` |
| 36 | + |
| 37 | +The SDK is now ready for use. To build from source, see [Dev Setup](#dev-setup). |
| 38 | + |
| 39 | +**NOTE: This README is for the current branch and not necessarily what's released on RubyGems.** |
| 40 | + |
| 41 | + |
| 42 | +## Usage |
| 43 | + |
| 44 | +### Client |
| 45 | + |
| 46 | +A client can be created and used to start a workflow like so: |
| 47 | + |
| 48 | +```ruby |
| 49 | +# Establish a gRPC connection to the server |
| 50 | +connection = Temporal::Connection.new('localhost:7233') |
| 51 | + |
| 52 | +# Initialize a Client with a namespace |
| 53 | +client = Temporal::Client.new(connection, 'my-namespace') |
| 54 | + |
| 55 | +# Start a workflow |
| 56 | +handle = client.start_workflow('MyWorkflow', 'some input', id: 'my-id', task_queue: 'my-task-queue') |
| 57 | + |
| 58 | +# Wait for the workflow to finish processing |
| 59 | +result = handle.result |
| 60 | +puts "Result: #{result}" |
| 61 | +``` |
| 62 | + |
| 63 | +Some things to note about the above code: |
| 64 | + |
| 65 | +- A `Client` does not have an explicit "close" |
| 66 | +- TLS is not yet supported |
| 67 | +- All positional arguments after the workflow name are treated as workflow arguments |
| 68 | +- The `handle` represents the workflow that was started and can be used for more than just getting |
| 69 | + the result |
| 70 | +- Clients can have many more options not shown here (e.g. data converters and interceptors) |
| 71 | + |
| 72 | +### Data Conversion |
| 73 | + |
| 74 | +Data converters are used to convert raw Temporal payloads to/from actual Ruby types. These consist |
| 75 | +of 3 distinct types of converters: |
| 76 | + |
| 77 | +- **Payload Converters** to convert Ruby values to/from serialized bytes |
| 78 | +- **Payload Codecs** to convert bytes to bytes (e.g. for compression or encryption) |
| 79 | +- **Failure Converters** to convert exceptions to/from serialized failures |
| 80 | + |
| 81 | +The default data converter supports converting multiple types including: |
| 82 | + |
| 83 | +- `nil` |
| 84 | +- bytes (`String` with `Encoding::ASCII_8BIT`) |
| 85 | +- Anything that [`JSON.generate`](https://ruby-doc.org/stdlib-3.0.0/libdoc/json/rdoc/JSON.html#method-i-generate) |
| 86 | + supports |
| 87 | + |
| 88 | +This notably doesn't include any `Date`, `Time`, or `DateTime` objects as they may not work across |
| 89 | +different SDKs. A custom payload converter can be implemented to support these. |
| 90 | + |
| 91 | + |
13 | 92 | ## Dev Setup
|
14 | 93 |
|
15 | 94 | Once you've forked/cloned the repository you want to make sure all the submodules are fetched as
|
@@ -41,11 +120,11 @@ Now you should be able to compile a dev build of the Bridge:
|
41 | 120 | You can then run all the specs against a dev build using:
|
42 | 121 |
|
43 | 122 | ```sh
|
44 |
| -> DEBUG=true bundle exec rspec |
| 123 | +> bundle exec rspec |
45 | 124 | ```
|
46 | 125 |
|
47 | 126 | And open an IRB session using:
|
48 | 127 |
|
49 | 128 | ```sh
|
50 |
| -> DEBUG=true bundle console |
| 129 | +> bundle console |
51 | 130 | ```
|
0 commit comments