question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[ Feature request ] Connecting code blocks through pipes.

See original GitHub issue

Hello good people of maid,

It would be useful if code blocks could communicate somehow.

Stdin - stdout

In the following pattern the code blocks are connected through the stdin-stdout:


## build 

Builds important stuff 

Snippet 1 

```js
process.stdout.write("hi there from snippet 1");
```

Snippet 2

```js
process.stdin.on('data', console.log); // hi there from snippet 1
```

Next

Another way of allowing communication between code blocks is by injecting a method inside each code block in a similar way of how express.js does it with their middlwares.


## build 

Builds important stuff 

Code block 1 

```js
next('hi there from snippet 1');
```

Code block 2

```js
console.log(maid.result); // hi there from snippet 1
```

This pattern can also be used to control the execution flow:


## build 

Builds important stuff 

Code block 1 

```js
next('hi there from snippet 1');
```

Code block 2

```js
if (true) {
	console.log(maid.result); // hi there from snippet 1
}else {
	next("hi there from snippet 2");
}
```

Code block 3 

```bash
 // This will never get executed 

```

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
Marakcommented, Jun 11, 2018

@AlvaroBernalG

My opinion is that this is out of scope of what maid should and can do.

I do think your idea is actually very good, but it’s going to add layers of complexity which maid shouldn’t have to deal with directly.

To give some background, I have already developed a similar system to what you have described ( connecting code snippets through STDIN / STDOUT or as HTTP middlewares ). Mostly we used HTTP, but it’s all essentially just generic streaming interfaces.

If you are interested in how we did this, here are some examples including chaining services of multiple languages which may inspire you:

https://github.com/Stackvana/microcule/tree/master/examples https://github.com/Stackvana/microcule/blob/master/examples/express-chain-services.js

I’m glad to offer any input I can. I’ve been working with this kind of development pattern for a few years and am eager to see more developers thinking about the problem space.

1reaction
AlvaroBernalGcommented, Jun 11, 2018

@Marak @egoist I do agree this wouldn’t be trivial to add, so I understand if you don’t want to push this forward.

@Marak. Awesome stuff, I will definitely have a look later.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Feature Request] Mek Pipes in One Block + New Pipe Type
You can run say an item pipe, a fluid pipe, and a power pipe all in the same space and even connect all...
Read more >
Code block language formatting - Evernote Forum
Hello, I love the code block feature that was added. However, I think it has some down falls. Mostly, I think it is...
Read more >
Building multiple branches - Azure Pipelines | Microsoft Learn
Make a change to your code in the feature branch and commit the change. Navigate to the Pipelines menu in Azure Pipelines or...
Read more >
Pipeline architecture - GitLab Docs
Pipelines are the fundamental building blocks for CI/CD in GitLab. This page documents some of the important concepts related to them.
Read more >
Write a pipe for Bitbucket Pipelines - Atlassian Support
Depending on what you need it for, you can make a simple pipe or a complete pipe. They work in the same way,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found