Skip to content

Commit 8616f35

Browse files
LauraLangdonJagger De Leo
and
Jagger De Leo
authored
move docs to reactr repo, add deprecation warnings, fix links (#283)
* move docs to reactr repo, add deprecation warnings, fix links * update readme * add deprecation warnings and fix links (again) * fix typo * change intra-GitHub links to relative links * chore: Rename .runnable.yamls to .module.yaml * empty commit to trigger CI * Revert "chore: Rename .runnable.yamls to .module.yaml" This reverts commit d7262d8. * fix link * fix link fr fr * fix another link Co-authored-by: Jagger De Leo <[email protected]>
1 parent 9aea8b5 commit 8616f35

File tree

4 files changed

+384
-24
lines changed

4 files changed

+384
-24
lines changed

README.md

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
## Reactr has been deprecated. You can use the new [scheduler](https://github.com/suborbital/e2core/tree/main/scheduler) and [engine](https://github.com/suborbital/sat/tree/vmain/engine) packages, which are a drop-in replacements for this project.
1+
## Reactr has been deprecated. You can use the new [scheduler](https://github.com/suborbital/e2core/tree/main/scheduler) and [engine](https://github.com/suborbital/sat/tree/vmain/engine) packages, which are a drop-in replacements for this project. You can find the [docs](./docs) in this repo.
22

33
Reactr is a fast, performant function scheduling library. Reactr is designed to be flexible, with the ability to run embedded in your Go applications and first-class support for WebAssembly.
44

55
Reactr runs functions called Runnables, and transparently spawns workers to process jobs. Each worker processes jobs in sequence, using Runnables to execute them. Reactr jobs are arbitrary data, and they return arbitrary data (or an error). Jobs are scheduled, and their results can be retrieved at a later time.
66

77
## Wasm
88

9-
Reactr has support for Wasm-packaged Runnables. The `engine` package contains a multi-tenant Wasm scheduler, an API to grant capabilities to Wasm Runnables, and support for several languages including Rust (stable), TypeScript/AssemblyScript (beta), and Swift (alpha). See [Wasm](https://docs.suborbital.dev/reactr/wasm) and the [Subo CLI](https://github.com/suborbital/subo) for details.
9+
Reactr has support for Wasm-packaged Runnables. The `engine` package contains a multi-tenant Wasm scheduler, an API to grant capabilities to Wasm Runnables, and support for several languages including Rust (stable), TypeScript/AssemblyScript (beta), and Swift (alpha). See [Wasm](./docs/wasm.md) and the [Subo CLI](https://github.com/suborbital/subo) for details.
1010

1111
### The Basics
1212

@@ -20,26 +20,26 @@ And then get started by defining something `Runnable`:
2020
package main
2121

2222
import (
23-
"fmt"
23+
"fmt"
2424

25-
"github.com/suborbital/reactr/rt"
25+
"github.com/suborbital/reactr/rt"
2626
)
2727

2828
type generic struct{}
2929

3030
// Run runs a generic job
3131
func (g generic) Run(job rt.Job, ctx *rt.Ctx) (interface{}, error) {
32-
fmt.Println("doing job:", job.String()) // get the string value of the job's data
32+
fmt.Println("doing job:", job.String()) // get the string value of the job's data
3333

34-
// do your work here
34+
// do your work here
3535

36-
return fmt.Sprintf("finished %s", job.String()), nil
36+
return fmt.Sprintf("finished %s", job.String()), nil
3737
}
3838

3939
// OnChange is called when Reactr starts or stops a worker to handle jobs,
4040
// and allows the Runnable to set up before receiving jobs or tear down if needed.
4141
func (g generic) OnChange(change rt.ChangeEvent) error {
42-
return nil
42+
return nil
4343
}
4444
```
4545
A `Runnable` is something that can take care of a job, all it needs to do is conform to the `Runnable` interface as you see above.
@@ -49,33 +49,29 @@ Once you have a Runnable, create a Reactr instance, register it, and `Do` some w
4949
package main
5050

5151
import (
52-
"fmt"
53-
"log"
52+
"fmt"
53+
"log"
5454

55-
"github.com/suborbital/reactr/rt"
55+
"github.com/suborbital/reactr/rt"
5656
)
5757

5858
func main() {
59-
r := rt.New()
59+
r := rt.New()
60+
61+
r.Register("generic", generic{})
6062

61-
r.Register("generic", generic{})
63+
result := r.Do(r.Job("generic", "hard work"))
6264

63-
result := r.Do(r.Job("generic", "hard work"))
65+
res, err := result.Then()
66+
if err != nil {
67+
log.Fatal(err)
68+
}
6469

65-
res, err := result.Then()
66-
if err != nil {
67-
log.Fatal(err)
68-
}
69-
70-
fmt.Println("done!", res.(string))
70+
fmt.Println("done!", res.(string))
7171
}
7272
```
7373
When you `Do` some work, you get a `Result`. A result is like a Rust future or a JavaScript promise, it is something you can get the job's result from once it is finished.
7474

7575
Calling `Then()` will block until the job is complete, and then give you the return value from the Runnable's `Run`. Cool, right?
7676

77-
## Reactr has some very powerful capabilities, visit the [Reactr guide](https://docs.suborbital.dev/reactr/) to learn more.
78-
79-
Reactr is being actively developed and has planned improvements, including optimized memory usage, library stability, data persistence, and more. Cheers!
80-
8177
Copyright Suborbital contributors 2021

docs/grav.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Reactr has been deprecated. You can use the new [scheduler](https://github.com/suborbital/e2core/tree/main/scheduler) and [engine](https://github.com/suborbital/sat/tree/vmain/engine) packages, which are a drop-in replacements for this project.
2+
3+
# Reactr ➕ Grav
4+
5+
Reactr is designed to integrate with the other [Suborbital](https://suborbital.dev) projects such as [Grav](https://github.com/suborbital/grav). Grav is a decentralized message bus which allows for your application code to communicate in a scalable, resilient way.
6+
7+
## Handle Messages
8+
Reactr can respond to messages by connecting to a `grav.Pod` using `HandleMsg`:
9+
```go
10+
reactr := rt.New()
11+
g := grav.New()
12+
13+
reactr.HandleMsg(g.Connect(), msgTypeLogin, &loginEmailRunner{})
14+
```
15+
Whenever a message with the given type is received from the bus, a `Job` will be queued to be handled by the provided Runnable. The `Job` will contain the message data.
16+
17+
The result returned by the Runnable's `Run` function may be a `grav.Message`. If so, it will be sent back out over the message bus. Anything else will be put into a message (by converting it into bytes) and sent back over the bus. If `Run` returns an error, a message with type `reactr.runerr` will be sent. If `Run` returns `nil, nil`, then a message of type `reactr.nil` will be sent. All messages sent will be a reply to the message that triggered the job.

0 commit comments

Comments
 (0)