Closed AThilenius closed 8 years ago
Starting exploration on ways to implement this. Please feel free to add to the conversation.
Logical problem; the old model for Fiber doesn't actually work any more because a single container lives "forever", so a stream is never closed. Meaning we have only one, never ending stream to/from the container. I'm then inclined to ditch the idea of persistent streams and think of this more as an 'SSH' sort of thing. However, keeping the last N entries would be nice incase the person has a long running job and closes their laptop while it finishes.
I then propose:
Depends on #22
This all makes sense to me.
We'll this all got thrown out the window with tty.js
Fiber (the streaming text service) needs to be reimplemented. I want to be really careful with this one, it's important to get this one right. It needs to do two important things:
The challenge is in storing the stream history. This is essentially a pub-sub system with history, step 4 of this article talks about how to do it with Redis. We will probably use Redis for this because it's such a good fit. But very old runs need to be pulled out of Redis and flushed to the DB and Redis is limited in size by how much memory the machine has.
Note for later: There is a potential race condition in 'pull history', 'observe changes'. To avoid this, we need to observe the stream first AND get a sentinel token from the server of where it is at in the stream (by ID). Only then are we safe to pull history from 0-N where N was given to us by the server.