Skip to content

Commit

Permalink
Merge branch 'main' of flomesh-io.github.com:flomesh-io/pipy
Browse files Browse the repository at this point in the history
  • Loading branch information
pajama-coder committed Aug 30, 2023
2 parents 687ef40 + 19cc58f commit 60a956c
Show file tree
Hide file tree
Showing 29 changed files with 888 additions and 498 deletions.
358 changes: 170 additions & 188 deletions docs/dts/Configuration.d.ts

Large diffs are not rendered by default.

9 changes: 2 additions & 7 deletions docs/reference/api/Configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,8 @@ These filters translate streams between the _raw byte form_ and the _message for
#### Muxers and demuxers

* [demux()](/reference/api/Configuration/demux)
* [demuxQueue()](/reference/api/Configuration/demuxQueue)
* [demuxHTTP()](/reference/api/Configuration/demuxHTTP)
* [mux()](/reference/api/Configuration/mux)
* [muxQueue()](/reference/api/Configuration/muxQueue)
* [muxHTTP()](/reference/api/Configuration/muxHTTP)
* [serveHTTP()](/reference/api/Configuration/serveHTTP)

Expand All @@ -89,16 +87,13 @@ These filters split messages from one stream into multiple streams, or the oppos
* [branch()](/reference/api/Configuration/branch)
* [chain()](/reference/api/Configuration/chain)
* [fork()](/reference/api/Configuration/fork)
* [input()](/reference/api/Configuration/input)
* [link()](/reference/api/Configuration/link)
* [output()](/reference/api/Configuration/output)
* [use()](/reference/api/Configuration/use)

These filters pass events in a stream from one pipeline to another. Unlike _muxers and demuxers_, they only change where streams are going without changing their content.

#### Buffering

* [depositMessage()](/reference/api/Configuration/depositMessage)
* [replay()](/reference/api/Configuration/replay)
* [throttleConcurrency()](/reference/api/Configuration/throttleConcurrency)
* [throttleDataRate()](/reference/api/Configuration/throttleDataRate)
Expand All @@ -124,10 +119,10 @@ These filters don't change anything in the stream. They simply pass down all eve

#### Transformers

* [compress()](/reference/api/Configuration/compress)
* [compressHTTP()](/reference/api/Configuration/compressHTTP)
* [compressMessage()](/reference/api/Configuration/compressMessage)
* [decompress()](/reference/api/Configuration/decompress)
* [decompressHTTP()](/reference/api/Configuration/decompressHTTP)
* [decompressMessage()](/reference/api/Configuration/decompressMessage)
* [exec()](/reference/api/Configuration/exec)
* [pack()](/reference/api/Configuration/pack)
* [read()](/reference/api/Configuration/read)
Expand Down
9 changes: 2 additions & 7 deletions docs/reference/api/Configuration.zh.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@ pipy().listen(8080) // 返回与之前相同配置对象
#### 多路复用和分路

* [demux()](/reference/api/Configuration/demux)
* [demuxQueue()](/reference/api/Configuration/demuxQueue)
* [demuxHTTP()](/reference/api/Configuration/demuxHTTP)
* [mux()](/reference/api/Configuration/mux)
* [muxQueue()](/reference/api/Configuration/muxQueue)
* [muxHTTP()](/reference/api/Configuration/muxHTTP)
* [serveHTTP()](/reference/api/Configuration/serveHTTP)

Expand All @@ -85,16 +83,13 @@ pipy().listen(8080) // 返回与之前相同配置对象
* [branch()](/reference/api/Configuration/branch)
* [chain()](/reference/api/Configuration/chain)
* [fork()](/reference/api/Configuration/fork)
* [input()](/reference/api/Configuration/input)
* [link()](/reference/api/Configuration/link)
* [output()](/reference/api/Configuration/output)
* [use()](/reference/api/Configuration/use)

这些过滤器将流从一个管道传递到另一个管道。与*多路复用和分路*不同,它们只修改流传输的方向,而不修改流本身的内容。

#### 缓冲

* [depositMessage()](/reference/api/Configuration/depositMessage)
* [throttleConcurrency()](/reference/api/Configuration/throttleConcurrency)
* [throttleDataRate()](/reference/api/Configuration/throttleDataRate)
* [throttleMessageRate()](/reference/api/Configuration/throttleMessageRate)
Expand All @@ -119,10 +114,10 @@ pipy().listen(8080) // 返回与之前相同配置对象

#### 转换器

* [compress()](/reference/api/Configuration/compress)
* [compressHTTP()](/reference/api/Configuration/compressHTTP)
* [compressMessage()](/reference/api/Configuration/compressMessage)
* [decompress()](/reference/api/Configuration/decompress)
* [decompressHTTP()](/reference/api/Configuration/decompressHTTP)
* [decompressMessage()](/reference/api/Configuration/decompressMessage)
* [exec()](/reference/api/Configuration/exec)
* [pack()](/reference/api/Configuration/pack)
* [read()](/reference/api/Configuration/read)
Expand Down
27 changes: 27 additions & 0 deletions docs/reference/api/Configuration/admin.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: Configuration.admin()
api: Configuration.admin
---

## Description

<Summary/>

## Syntax

``` js
```

## Parameters

<Parameters/>

## Example

``` js
```

## See Also

* [Configuration](/reference/api/Configuration)
* [exit()](/reference/api/Configuration/exit)
3 changes: 2 additions & 1 deletion docs/reference/api/Configuration/branch.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,5 @@ pipy()
## See Also

* [Configuration](/reference/api/Configuration)
* [link()](/reference/api/Configuration/link)
* [branchMessage()](/reference/api/Configuration/branchMessage)
* [branchMessageStart()](/reference/api/Configuration/branchMessageStart)
114 changes: 114 additions & 0 deletions docs/reference/api/Configuration/branchMessage.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
title: Configuration.branchMessage()
api: Configuration.branchMessage
---

## Description

<Summary/>

<FilterDiagram
name="branchMessage"
input="Event"
output="Event"
subInput="Event"
subOutput="Event"
subType="demux"
/>

### Select from several sub-pipeline layouts

The _branch_ filter can be given more than one sub-pipeline layouts, each corresponding to a condition. As the first event arrives at the filter, it evaluates each condition in order to find the first one that is met, and creates a sub-pipeline based on its corresponding sub-pipeline layout.

> Once a pipeline layout is selected, it won't change throughout the whole lifetime of the current stream, even when the conditions may change afterwards.
If no conditions are met, the last pipeline layout without a set condition is selected.

``` js
pipy({
_condition: undefined,
})

.pipeline()
.branch(
() => _condition === 'cond1', (
$=>$.dump('branch1')
),
() => _condition === 'cond2', (
$=>$.dump('branch1')
),
(
$=>$.dump('default branch')
)
)
```

### Block up events until a condition is met

If all sub-pipeline layout options have conditions but none of them are met, _branch_ filter will block the stream until a condition is met. This can be used to buffer up events while waiting for a certain situation.

``` js
pipy({
_targetDetected: false,
})

.pipeline()
.branch(
() => _targetDetected, (
$=>$.dump()
)
)
```

> The condition the filter is waiting for is only checked every time there's an input event to the filter. To check the condition whenever any state in the context has changed, regardless of any input events, use [wait()](/reference/api/Configuration/wait) instead.
### Static branch

If none of the condition arguments are functions, the _branch_ filter will be *static*, in which case there will not be a _branch_ filter being appended to the current pipeline configuration. Instead, all conditions will be evaluated at _configuration time_ to find a branch. The function for that branch will then be executed with one single argument for the current _Configuration_, giving your script a chance to selectively insert or bypass filters from the very beginning.

``` js
((
dumpEnabled = false,
) => pipy()

.listen(8080)
.branch(
dumpEnabled, (
$=>$.dump()
)
)
.dummy()

)()
```

## Syntax

``` js
pipy()
.pipeline()
.branch(
() => isConditionAMet(), pipelineLayoutA,
() => isConditionBMet(), pipelineLayoutB,
// ...
fallbackPipelineLayout,
)

pipy()
.pipeline()
.branch(
() => isConditionAMet(), pipelineLayoutA,
() => isConditionBMet(), pipelineLayoutB,
// ...
)
```

## Parameters

<Parameters/>

## See Also

* [Configuration](/reference/api/Configuration)
* [branch()](/reference/api/Configuration/branch)
* [branchMessageStart()](/reference/api/Configuration/branchMessageStart)
114 changes: 114 additions & 0 deletions docs/reference/api/Configuration/branchMessageStart.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
title: Configuration.branchMessageStart()
api: Configuration.branchMessageStart
---

## Description

<Summary/>

<FilterDiagram
name="branchMessageStart"
input="Event"
output="Event"
subInput="Event"
subOutput="Event"
subType="demux"
/>

### Select from several sub-pipeline layouts

The _branch_ filter can be given more than one sub-pipeline layouts, each corresponding to a condition. As the first event arrives at the filter, it evaluates each condition in order to find the first one that is met, and creates a sub-pipeline based on its corresponding sub-pipeline layout.

> Once a pipeline layout is selected, it won't change throughout the whole lifetime of the current stream, even when the conditions may change afterwards.
If no conditions are met, the last pipeline layout without a set condition is selected.

``` js
pipy({
_condition: undefined,
})

.pipeline()
.branch(
() => _condition === 'cond1', (
$=>$.dump('branch1')
),
() => _condition === 'cond2', (
$=>$.dump('branch1')
),
(
$=>$.dump('default branch')
)
)
```

### Block up events until a condition is met

If all sub-pipeline layout options have conditions but none of them are met, _branch_ filter will block the stream until a condition is met. This can be used to buffer up events while waiting for a certain situation.

``` js
pipy({
_targetDetected: false,
})

.pipeline()
.branch(
() => _targetDetected, (
$=>$.dump()
)
)
```

> The condition the filter is waiting for is only checked every time there's an input event to the filter. To check the condition whenever any state in the context has changed, regardless of any input events, use [wait()](/reference/api/Configuration/wait) instead.
### Static branch

If none of the condition arguments are functions, the _branch_ filter will be *static*, in which case there will not be a _branch_ filter being appended to the current pipeline configuration. Instead, all conditions will be evaluated at _configuration time_ to find a branch. The function for that branch will then be executed with one single argument for the current _Configuration_, giving your script a chance to selectively insert or bypass filters from the very beginning.

``` js
((
dumpEnabled = false,
) => pipy()

.listen(8080)
.branch(
dumpEnabled, (
$=>$.dump()
)
)
.dummy()

)()
```

## Syntax

``` js
pipy()
.pipeline()
.branch(
() => isConditionAMet(), pipelineLayoutA,
() => isConditionBMet(), pipelineLayoutB,
// ...
fallbackPipelineLayout,
)

pipy()
.pipeline()
.branch(
() => isConditionAMet(), pipelineLayoutA,
() => isConditionBMet(), pipelineLayoutB,
// ...
)
```

## Parameters

<Parameters/>

## See Also

* [Configuration](/reference/api/Configuration)
* [branch()](/reference/api/Configuration/branch)
* [branchMessage()](/reference/api/Configuration/branchMessage)
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
title: Configuration.compressMessage()
api: Configuration.compressMessage
title: Configuration.compress()
api: Configuration.compress
---

## Description

<Summary/>

<FilterDiagram
name="compressMessage"
name="compress"
input="Message"
output="Message"
/>
Expand All @@ -31,4 +31,5 @@ pipy()
## See Also

* [Configuration](/reference/api/Configuration)
* [decompress()](/reference/api/Configuration/decompress)
* [compressHTTP()](/reference/api/Configuration/compressHTTP)
3 changes: 2 additions & 1 deletion docs/reference/api/Configuration/compressHTTP.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ pipy()
## See Also

* [Configuration](/reference/api/Configuration)
* [compressMessage()](/reference/api/Configuration/compressMessage)
* [decompressHTTP()](/reference/api/Configuration/decompressHTTP)
* [compress()](/reference/api/Configuration/compress)
Loading

0 comments on commit 60a956c

Please sign in to comment.