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

Article posting #28

Open
1 of 4 tasks
sgg opened this issue Oct 18, 2020 · 2 comments
Open
1 of 4 tasks

Article posting #28

sgg opened this issue Oct 18, 2020 · 2 comments
Assignees

Comments

@sgg
Copy link
Owner

sgg commented Oct 18, 2020

Add the ability to post articles. Now would probably be a good time to introduce some integration tests!

POST is particularly tricky because (like IHAVE) it is a two stage command. If we model this incorrectly we could end up with an inconsistent stream state. The workflow is as follows:

  1. Client sends POST
  2. Server replies with status
  3. If status is 340, send post and check response. Otherwise stop.
  • Implement POST command(s)
  • Provide builder(s)
  • Provide first class support in the NntpClient so that users do not have to deal with the stateful nature themselves
  • Provide doc examples and worked example
@sgg sgg self-assigned this Oct 18, 2020
@sgg
Copy link
Owner Author

sgg commented Oct 19, 2020

I've elected to model POST as two NntpCommands -- InitiatePost and Post.

InitiatePost can be used to initiate transfers and Post can be used to transfer an actual article. There is a Builder provided for creating these from headers and a body.

Fundamentally article transfer looks like two command/response exchanges, so I chose to model it that way.
This is line w/ Brokaw's general design philosophy -> leave the low level bits simple and introducing more user friendly abstractions at the NntpClient layer.

Alternatives Considered

  1. Modifying the NntpCommand to support stateful behavior. I decided against as very few commands have this kind of behavior (w/r/t RFC3977 it's just POST and IHAVE). The added complexity that would be required here does not seem to be worth it.
  2. Introducing new traits/types that can represent command sequences. Again, more code, more complexity, little benefit.

I am still chewing on the UX. I will definitely introduce a method in the NntpClient to make article transfer easier. A higher level Article may also be introduced.

Users may want:

  • Creating articles from streams (aka a file/buffer)
  • mandatory header validation.

sgg added a commit that referenced this issue Oct 19, 2020
POST is stateful and if you squint it looks like two commands rather
than one so we model it as two commands: InitiatePost and Post.

See #28 for more info on the implementation.

* The postit example demonstrates how we can generate messages from a
  JSON payload (or really anything that supports serde).
@r3k2
Copy link

r3k2 commented Apr 26, 2024

Hello @sgg so post is working? I am about to start a TUI usenet client and thinking in using this libraries...

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

2 participants