Skip to content

Commit

Permalink
move docs to reactr repo, add deprecation warnings, fix links (#283)
Browse files Browse the repository at this point in the history
* 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 <jagger@suborbital.dev>
  • Loading branch information
LauraLangdon and Jagger De Leo committed Oct 5, 2022
1 parent 9aea8b5 commit 8616f35
Show file tree
Hide file tree
Showing 4 changed files with 384 additions and 24 deletions.
44 changes: 20 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
## 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.
## 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.

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.

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.

## Wasm

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.
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.

### The Basics

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

import (
"fmt"
"fmt"

"github.com/suborbital/reactr/rt"
"github.com/suborbital/reactr/rt"
)

type generic struct{}

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

// do your work here
// do your work here

return fmt.Sprintf("finished %s", job.String()), nil
return fmt.Sprintf("finished %s", job.String()), nil
}

// OnChange is called when Reactr starts or stops a worker to handle jobs,
// and allows the Runnable to set up before receiving jobs or tear down if needed.
func (g generic) OnChange(change rt.ChangeEvent) error {
return nil
return nil
}
```
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.
Expand All @@ -49,33 +49,29 @@ Once you have a Runnable, create a Reactr instance, register it, and `Do` some w
package main

import (
"fmt"
"log"
"fmt"
"log"

"github.com/suborbital/reactr/rt"
"github.com/suborbital/reactr/rt"
)

func main() {
r := rt.New()
r := rt.New()

r.Register("generic", generic{})

r.Register("generic", generic{})
result := r.Do(r.Job("generic", "hard work"))

result := r.Do(r.Job("generic", "hard work"))
res, err := result.Then()
if err != nil {
log.Fatal(err)
}

res, err := result.Then()
if err != nil {
log.Fatal(err)
}

fmt.Println("done!", res.(string))
fmt.Println("done!", res.(string))
}
```
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.

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

## Reactr has some very powerful capabilities, visit the [Reactr guide](https://docs.suborbital.dev/reactr/) to learn more.

Reactr is being actively developed and has planned improvements, including optimized memory usage, library stability, data persistence, and more. Cheers!

Copyright Suborbital contributors 2021
17 changes: 17 additions & 0 deletions docs/grav.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## 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.

# Reactr ➕ Grav

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.

## Handle Messages
Reactr can respond to messages by connecting to a `grav.Pod` using `HandleMsg`:
```go
reactr := rt.New()
g := grav.New()

reactr.HandleMsg(g.Connect(), msgTypeLogin, &loginEmailRunner{})
```
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.

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 comments on commit 8616f35

Please sign in to comment.