github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/gen/includes/named-pipes.inc.md (about)

     1  ### What are Murex named pipes?
     2  
     3  In POSIX, there is a concept of STDIN, STDOUT and STDERR, these are FIFO files
     4  while are "piped" from one executable to another. ie STDOUT for application 'A'
     5  would be the same file as STDIN for application 'B' when A is piped to B:
     6  `A | B`. Murex adds a another layer around this to enable support for passing
     7  data types and builtins which are agnostic to the data serialization format
     8  traversing the pipeline. While this does add overhead the advantage is this new
     9  wrapper can be used as a primitive for channelling any data from one point to
    10  another.
    11  
    12  Murex named pipes are where these pipes are created in a global store,
    13  decoupled from any executing functions, named and can then be used to pass
    14  data along asynchronously.
    15  
    16  For example
    17  
    18  ```
    19  pipe example
    20  
    21  bg {
    22      <example> -> match Hello
    23  }
    24  
    25  out "foobar"        -> <example>
    26  out "Hello, world!" -> <example>
    27  out "foobar"        -> <example>
    28  
    29  !pipe example
    30  ```
    31  
    32  This returns `Hello, world!` because `out` is writing to the **example** named
    33  pipe and `match` is also reading from it in the background (`bg`).
    34  
    35  Named pipes can also be inlined into the command parameters with `<>` tags
    36  
    37  ```
    38  pipe example
    39  
    40  bg {
    41      <example> -> match: Hello
    42  }
    43  
    44  out <example> "foobar"
    45  out <example> "Hello, world!"
    46  out <example> "foobar"
    47  
    48  !pipe example
    49  ```
    50  
    51  > Please note this is also how `test` works.
    52  
    53  Murex named pipes can also represent network sockets, files on a disk or any
    54  other read and/or write endpoint. Custom builtins can also be written in Golang
    55  to support different abstractions so your Murex code can work with those read
    56  or write endpoints transparently.
    57  
    58  To see the different supported types run
    59  
    60  ```
    61  runtime --pipes
    62  ```
    63  
    64  ### Namespaces and usage in modules and packages
    65  
    66  Pipes created via `pipe` are created in the global namespace. This allows pipes
    67  to be used across different functions easily however it does pose a risk with
    68  name clashes where Murex named pipes are used heavily. Thus is it recommended
    69  that pipes created in modules should be prefixed with the name of its package.