Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Read process interleaved with stream assignment #61

Open
ad-si opened this issue Oct 29, 2022 · 6 comments
Open

Feature Request: Read process interleaved with stream assignment #61

ad-si opened this issue Oct 29, 2022 · 6 comments

Comments

@ad-si
Copy link

ad-si commented Oct 29, 2022

It would be cool to have a function a la

readProcessTimed
  :: MonadIO m	  
  => ProcessConfig stdin stdoutIgnored stderrIgnored	  
  -> m (ExitCode, [(ByteString, ByteString, ByteString)])

which would results in something like this:

( ExitSuccess,
    [ ( "2022-10-29T15:20:12.168Z", "stdout", "Hello World!" ) ] 
    , ( "2022-10-29T15:20:12.175Z", "stderr", "ERROR: World not available" ) ] 
    ]
)
  • There should probably be a version with and without timestamp (or make it configurable)
  • It should probably use a more elaborate data type than a tuple of strings
@tomjaguarpaw
Copy link
Collaborator

I don't think I follow. What do the timestamps refer to here? The first time some data was available on that stream?

@ad-si
Copy link
Author

ad-si commented Oct 29, 2022

Well, that's up for debate I guess, but Google Cloud Functions for example uses a timestamp for each line (terminated by \n). I guess it's the moment the \n appears on the stream.

@tomjaguarpaw
Copy link
Collaborator

Personally I'd say that kind of thing belongs in a higher level library and that typed-process is too low-level for that. @snoyberg makes the final decision though.

@snoyberg
Copy link
Member

I agree with @tomjaguarpaw's assessment.

@ad-si
Copy link
Author

ad-si commented Oct 30, 2022

Ok, but even for a version without timestamps, but tags where each chunk came from?

( ExitSuccess,
    [ Stdout "Hello World!"
    , Stderr "ERROR: World not available"
    ]
)

@tomjaguarpaw
Copy link
Collaborator

Yes, even for that. How about this: you write something that does that, use it happily in production for a year, and then come back here with a PR saying "this is rock solid in production and really useful, would you like to incorporate it?". Then we're more likely to add it to the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants