Skip to content

Commit 523f6a5

Browse files
committed
docs: update readmes
1 parent da316e6 commit 523f6a5

File tree

14 files changed

+449
-215
lines changed

14 files changed

+449
-215
lines changed

.github/BUMP

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
30
1+
31

.github/workflows/go.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,13 @@ jobs:
118118
message: ${{ env.TESTS }}
119119
color: blue
120120

121-
- name: Badge - tests /pkg
122-
uses: schneegans/[email protected]
123-
with:
124-
auth: ${{ secrets.GIST_SECRET }}
125-
gistID: c6032233dc1d632732ecdc1a4c119850
126-
filename: tests-pkg.json
127-
label: tests /pkg
128-
message: ${{ env.TESTS_PKG }}
129-
color: blue
121+
# TODO fix
122+
# - name: Badge - tests /pkg
123+
# uses: schneegans/[email protected]
124+
# with:
125+
# auth: ${{ secrets.GIST_SECRET }}
126+
# gistID: c6032233dc1d632732ecdc1a4c119850
127+
# filename: tests-pkg.json
128+
# label: tests /pkg
129+
# message: ${{ env.TESTS_PKG }}
130+
# color: blue

.github/workflows/linter.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ on: [push]
55
jobs:
66
build:
77

8-
# if: false # Disable this job
8+
# TODO fix timeouts
9+
if: false # Disable this job
910

1011
runs-on: ubuntu-latest
1112
strategy:

BREAKING.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22

33
Only `pkg/machine` and `pkg/states` adhere to semver. Semver of other packages is not guaranteed at the moment.
44

5+
## v0.13
6+
7+
- `LogSteps` has been removed
8+
- `LogChanges` is now `2`
9+
- `Opts.DontLogID` is now `DontLogId`
10+
- `Transition.ID` is now `Id`
11+
- `SetLogId` is now `SemLogger.EnableId`
12+
- `GetLogId` is now `SemLogger.IsId`
13+
- `SetLogArgs` is now `SemLogger.SetArgs`
14+
- `GetLogArgs` is now `SemLogger.Args`
15+
- `SetLogger` is now `SemLogger.SetLogger`
16+
- `GetLogger` is now `SemLogger.Logger`
17+
- `SetLogLevel` is now `SemLogger.SetLevel`
18+
- `GetLogLevel` is now `SemLogger.Level`
19+
- `SetLoggerEmpty` is now `SemLogger.SetEmpty`
20+
- `SetLoggerSimple` is now `SemLogger.SetSimple`
21+
- `Tracer.MutationQueued` added
22+
- `AddBreakpoint` has `strict` added
23+
- `Logger` is now `LoggerFn`
24+
525
## v0.12
626

727
- `Opts.ID` and `Opts.ParentID` are now `Opts.Id`, `Opts.ParentId`

CHANGELOG.md

Lines changed: 342 additions & 158 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![](https://goreportcard.com/badge/github.com/pancsta/asyncmachine-go)](https://goreportcard.com/report/github.com/pancsta/asyncmachine-go)
22
[![](https://pkg.go.dev/badge/github.com/pancsta/asyncmachine-go.svg)](https://pkg.go.dev/github.com/pancsta/asyncmachine-go)
3-
![](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/pancsta/c6032233dc1d632732ecdc1a4c119850/raw/loc.json)
43
![](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/pancsta/c6032233dc1d632732ecdc1a4c119850/raw/loc-pkg.json)
4+
![](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/pancsta/c6032233dc1d632732ecdc1a4c119850/raw/loc-tools.json)
55
![](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/pancsta/c6032233dc1d632732ecdc1a4c119850/raw/tests.json)
66
![](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/pancsta/c6032233dc1d632732ecdc1a4c119850/raw/tests-pkg.json)
77
![](https://img.shields.io/github/v/release/pancsta/asyncmachine-go)
@@ -17,7 +17,6 @@
1717
<a href="#documentation">Docs</a> .
1818
<a href="#development">Dev</a> .
1919
<a href="#faq">FAQ</a> .
20-
<a href="#changes">Changes</a>
2120
<br />
2221
</div>
2322

@@ -43,24 +42,25 @@ and [diagrams](https://github.com/pancsta/asyncmachine-go/pull/216).
4342
As a control flow library, it decides about running of predefined bits of code (transition handlers) - their order and
4443
which ones to run, according to currently active states (flags). Thanks to a [novel state machine](/pkg/machine/README.md),
4544
the number of handlers can be minimized while maximizing scenario coverage. It's lightweight, fault-tolerant by design,
46-
has rule-based mutations, and can be used to target virtually *any* step-in-time, in *any* workflow.
45+
has rule-based mutations, and can be used to target virtually *any* step-in-time, in *any* workflow. It's a low-level
46+
tool and provides acceptable performance.
4747

4848
**asyncmachine-go** takes care of `context`, `select`, and `panic`, while allowing for graph-structured concurrency
49-
with [goroutine cancellation](https://github.com/pancsta/asyncmachine-go/pull/261). The history log and relations have
49+
with [goroutine cancelation](https://github.com/pancsta/asyncmachine-go/pull/261). The history log and relations have
5050
vector formats.
5151

5252
It aims to create **autonomous** workflows with **organic** control flow and **stateful** APIs:
5353

5454
- **autonomous** - automatic states, relations, context-based decisions
55-
- **organic** - relations, negotiation, cancellation
55+
- **organic** - relations, negotiation, cancelation
5656
- **stateful** - maintaining context, responsive, atomic
5757

5858
<div align="center">
5959
<a href="https://github.com/pancsta/asyncmachine-go/blob/main/tools/cmd/am-dbg/README.md">
6060
<img src="https://github.com/pancsta/assets/blob/main/asyncmachine-go/video-mouse.gif?raw=true" alt="TUI Debugger" /></a>
6161
</div>
6262

63-
Each state represents:
63+
#### Each state represents
6464

6565
- binary flag
6666
- node with relations
@@ -73,7 +73,7 @@ Each state represents:
7373
- lock
7474
- breakpoint
7575

76-
Besides workflows, it can be used for **stateful applications** of any size - daemons, UIs, configs, bots, firewalls,
76+
Besides workflows, it can be used for **stateful applications of any size** - daemons, UIs, configs, bots, firewalls,
7777
synchronization consensus, games, smart graphs, microservice orchestration, robots, contracts, streams, DI containers,
7878
test scenarios, simulators, as well as **"real-time" systems** which rely on instant cancelation.
7979

@@ -137,7 +137,7 @@ The top layers depend on the bottom ones.
137137
<tr>
138138
<td>.</td>
139139
<td>.</td>
140-
<td colspan="9" align=center>🐇 <a href="pkg/machine">Machine API</a></td>
140+
<td colspan="9" align=center>🐇 <a href="pkg/machine">Machine pkg</a></td>
141141
<td>.</td>
142142
<td>.</td>
143143
</tr>
@@ -189,13 +189,13 @@ err := amhelp.WaitForAll(ctx, time.Second,
189189
mach.When1(ss.BasicStatesDef.Ready, nil),
190190
// pre-mutation subscription
191191
whenPayload)
192-
// check cancellation
192+
// check cancelation
193193
if ctx.Err() != nil {
194194
return // state ctx expired
195195
}
196196
// check error
197197
if err != nil {
198-
// err state mutation
198+
// error state mutation
199199
client.Mach.AddErr(err, nil)
200200
return // no err required
201201
}
@@ -291,11 +291,11 @@ This monorepo offers the following importable packages, especially:
291291

292292
Other packages:
293293

294-
- [`/pkg/graph`](/pkg/graph) Multigraph of interconnected state machines.
294+
- [`/pkg/rpc`](/pkg/rpc) Remote state machines, with the same API as local ones.
295295
- [`/pkg/history`](/pkg/history) History tracking and traversal.
296296
- [`/pkg/integrations`](/pkg/integrations) NATS and other JSON integrations.
297+
- [`/pkg/graph`](/pkg/graph) Multigraph of interconnected state machines.
297298
- [`/pkg/node`](/pkg/node) Distributed worker pools with supervisors.
298-
- [`/pkg/rpc`](/pkg/rpc) Remote state machines, with the same API as local ones.
299299
- [`/pkg/pubsub`](/pkg/pubsub) Decentralized PubSub based on libp2p gossipsub.
300300

301301
## [Devtools](/tools)

ROADMAP.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
# Roadmap
22

3-
- negotiation testers (eg `CanAdd`)
4-
- more helpers for queue and history traversal
53
- handlers for RPC workers
6-
- DB-based scheduler
7-
- NATS integration
4+
- handler loop based scheduler
85
- go1.22 traces
96
- inference
10-
- dynamic state schemas
117
- optimizations
128
- tutorials
139

Taskfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ tasks:
366366

367367
lint-go:
368368
cmds:
369-
- $(go env GOPATH)/bin/golangci-lint run --fix --timeout 5m
369+
- $(go env GOPATH)/bin/golangci-lint run --fix --timeout 15m
370370

371371
lint-md:
372372
cmds:

docs/env-configs.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,18 @@ AM_DBG_ADDR=localhost:6831
3636
# defaults to ""
3737
AM_HEALTHCHECK=1
3838

39-
# set the log level 0-6
39+
# machine text log level 0-5
4040
# defaults to "0"
4141
AM_LOG=2
4242

43+
# log transition steps
44+
# defaults to ""
45+
AM_LOG_STEPS=1
46+
47+
# log graph structure (mut traces, pipes, etc)
48+
# defaults to ""
49+
AM_LOG_GRAPH=1
50+
4351
# enable file logging (use machine ID as name)
4452
# defaults to ""
4553
AM_LOG_FILE=1

docs/manual.md

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ am.Schema{
9292
}
9393
```
9494

95-
State names have a predefined **naming convention** which is `CamelCase`.
95+
State names have a predefined [naming convention](#naming-convention) which is `CamelCase`.
9696

9797
**Example** - synchronous state
9898

@@ -548,8 +548,9 @@ Once a transition begins to execute, it goes through the following steps:
548548
549549
### Transition Handlers
550550
551-
**Asyncmachine** implements **AOP** ([Aspect Oriented Programming](https://en.wikipedia.org/wiki/Aspect-oriented_programming))
552-
through a handler naming convention. Use [`LogEverything`](#logging) to see a full list of each transition's handlers.
551+
The **asyncmachine** implements **AOP** ([Aspect Oriented Programming](https://en.wikipedia.org/wiki/Aspect-oriented_programming))
552+
through a handler naming convention (either via a suffix or concatenation). Use [`LogEverything`](#logging) to see a
553+
full list of each transition's handlers.
553554

554555
**State handler** is a struct method with a predefined suffix or prefix, which receives an [Event struct](#event-struct).
555556
There are [negotiation handlers](#negotiation-handlers) (returning a `bool`) and [final handlers](#final-handlers) (with
@@ -598,6 +599,20 @@ List of handlers during a transition from `Foo` to `Foo Bar`, in the order of ex
598599

599600
Self handlers provide a simple alternative to [`Multi` states](#multi-states), while fully maintaining [state clocks](#clock-and-context).
600601

602+
#### Transition Sub-handler
603+
604+
**State sub-handler** is a struct method which does not get called directly via the event loop, but also lacks locking,
605+
because of which, they can only be called by other handlers (either top level or sub-handlers). There is a [naming convention](#naming-convention)
606+
for these handlers, but no conventions for either parameters not return values.
607+
608+
Example:
609+
610+
- `hListProcesses(name string) ([]string, error)`
611+
- `hDoFoo() error`
612+
613+
Sub-handlers are useful when combined with `EvalToGetter` from `pkg/helpers`, as well as for sharing code between
614+
handlers, without worrying about calling it from a non-handler code-path.
615+
601616
### Defining Handlers
602617

603618
Handlers are defined as struct methods. Each machine can have many handler structs bound to itself using
@@ -1789,13 +1804,22 @@ func Msg(msgTx *Msg) {
17891804
- wait contexts
17901805
- Dispose
17911806
- WhenDisposed
1792-
- RegisterDisposalHandler
1807+
- HandleDispose
17931808

17941809
### Dynamically Generating States
17951810

17961811
// TODO
17971812

1798-
- Machine.SetStrcut
1813+
- Machine.SetSchema
1814+
- schema versions
1815+
1816+
### Naming Convention
1817+
1818+
- states: CamelCase, eg `ProcessRunning`
1819+
- handlers: CamelCase, eg `ProcessRunningState`
1820+
- sub-handlers: CamelCase, eg `hListRunning`
1821+
- TODO dedicated section with examples
1822+
- regular methods: none, eg `privMethod`, `PubMethod`
17991823

18001824
## Cheatsheet
18011825

0 commit comments

Comments
 (0)