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

Towards Pencil 0.4 #49

Open
golddranks opened this issue Feb 22, 2017 · 9 comments
Open

Towards Pencil 0.4 #49

golddranks opened this issue Feb 22, 2017 · 9 comments

Comments

@golddranks
Copy link

golddranks commented Feb 22, 2017

Hi,

I've been using Pencil for the last few months, and I've built a web app that has now entering production stage. As I've been building my app, I've maintained a fork of Pencil, which has allowed me to quickly add features that I've needed. (The fork can be found here: https://github.com/golddranks/pencil/commits/master )

These changes include but are not limited to:

  • Specifying the number of threads used (important in production even when using a reverse proxy, since connections to the DB might block, and I was surprised that Hyper spawned only one thread on a single-core server)
  • Serving partial files in response to the Range header (I'm serving partly dynamic content so just offloading this to Nginx or to some CDN was not feasible)
  • Rough support for serving HTTP 304 Not Modified and specifying cache expiry time when serving files
  • Updating dependencies, supporting Hyper 0.10 which got rid of the dependency on old SSL versions
  • Debug trait implementations for some structures
  • After-request handlers getting a reference not only to the Response but to the Request too (this is handy if you use the TypeMap in Request to pass data from pre-request to post-request handler)
  • Implemented routing by GET parameters

I also made some changes that may prove controversial:

  • Implementing some methods for the dictionaries for getting ownership of the parsed arguments etc. I'd prefer if arguments, fields etc. were parsed in a non-copy way. This way you couldn't the take the ownership, but if you needed it, you could clone. At the moment the data is copied once when parsing, and second time when accessing. Taking ownership prevents the second copy, but it would obviously be better (but requires more work) if the data was copied when a copy is really needed.
  • Exposed some private fields. Accessing fields through accessors is often painful in Rust, especially if mutable access is needed, since accessing one field locks the rest. Direct access to fields is more flexible. (Again, if the request was more immutable and parsed zero-copy, the fields should accessed only with shared references, and exposing the fields only with accessors would be sensible.)

I haven't really looked into how much work implementing more zero-copy parsing would be. Yet.

I'd like to contribute these changes back to Pencil, and help releasing Pencil 0.4. However, as the changes are just stop-gap solutions to my problems, I need to brush them up a bit if I were to contribute them. However, I want to have a confirmation from the maintainer @fengsp if he is willing to merge the PRs if I were to contribute stuff, since I don't want to do needless work :D What do you think?

@golddranks
Copy link
Author

golddranks commented Mar 3, 2017

PSA: I've published a fork called sharp_pencil that mostly does what's been said above (Edit: plus it also allows using Fn closures as handlers! [but not views, ATM]). I'm still willing to merge it, but while there is no answer, it's at least a stop-gap solution.

You can use it like:

[dependencies]
sharp_pencil = "0.4"

and

extern crate sharp_pencil as pencil;

There might be minor breakage with the updated dependencies (and possibly some type inference issues as I made the return values of MultiDics more flexible.) but nothing too drastic.

@spazm
Copy link

spazm commented Apr 18, 2017

👍

@saggit
Copy link

saggit commented Aug 2, 2017

@fengsp What you think?

@spacekookie
Copy link

Is this still being developed?

@golddranks
Copy link
Author

I think that this project is essentially dead... There are other web frameworks in Rust that are more actively developed.

@golddranks
Copy link
Author

Sharp Pencil 0.5 has been released after 3 and half years.

@golddranks
Copy link
Author

It's essentially just a dependency bump, though :–D

@micwoj92
Copy link

@golddranks It would be great if you could open issue tracker on your sharp_pencil fork, due to some changes in notify crate it no longer compiles.

@golddranks
Copy link
Author

@micwoj92 Done! And let's see about the notify crate.

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

5 participants