[HN Gopher] Zerocal - A Serverless Calendar App in Rust
___________________________________________________________________
Zerocal - A Serverless Calendar App in Rust
Author : omn1
Score : 103 points
Date : 2022-10-06 15:28 UTC (7 hours ago)
(HTM) web link (endler.dev)
(TXT) w3m dump (endler.dev)
| clircle wrote:
| I'm wondering if this or a similar tool could be hooked into
| emacs to make working with calendars in emacs a bit easier. I
| don't think there is a good way to send calendar invites to
| people from emacs (but happy to be wrong on this one).
| tuukkah wrote:
| As seen in the article, the invites are simple text files. (I
| haven't tried, but you might be able to create one with
| icalendar-export-region?)
|
| I think the more difficult part is sending an email that looks
| and works right with the invite attached in a way compatible
| with the receiving systems.
|
| Invitations from Microsoft systems are especially horrible as
| they look like normal, plain text messages (without an invite)
| in standards-compliant systems. Depending how the sender
| expresses themselves, the receiver might have no clue they were
| invited let alone the time and place.
| [deleted]
| longrod wrote:
| Looks cool but...why not just send the .ics file directly via
| your IM of choice? Am I missing something here? I don't see the
| benefit if you still have to click, open file in your calendar,
| add it to the calendar.
|
| Can you tell me why the above wouldn't work and why this is
| better?
| omn1 wrote:
| You could do that but you'd have to create the ics file
| manually and not every platform allows you to share ics files.
| My original use-case was Github. Wanted to share invites for
| https://github.com/hello-rust/community. Github prevents
| sharing ics. Another thing is that people could edit a link in-
| place to e.g. update the time without creating a new file.
| jacob019 wrote:
| Speaking of zerocal, have you ever noticed that low calorie
| packaged foods like pickles and cauliflower will put tiny serving
| sizes on the package so they can advertise 0 calories? I think
| they round down to zero when it's less than 5 calories.
| EmbeddedHash wrote:
| Yep. Another suspect of this is cooking oil spray, like Pam.
| They can advertise very low calories, usually 0, per serving
| but a serving is considered like 1/3 of a second spray.
| tuukkah wrote:
| > I wanted a way to create calendar entries from my terminal.
|
| > There is no state on the server, it just generates a calendar
| event on the fly and returns it.
|
| Didn't see _that_ coming. I suppose it 's handy that you can call
| it anywhere curl is installed (or even use the browser address
| bar as your command line) instead of having to install and run
| the Rust program locally.
| spdustin wrote:
| I want to make sure I understand this:
|
| You made a VCALENDAR generator with a web-accessible endpoint. It
| fills in the VCALENDAR with info passed in via URL parameters.
| And rather than returning a webpage, it just returns the
| VCALENDAR file.
|
| So you send your friends the link, they click it, rather then
| returning text/html content, it returns a downloadable response
| consisting of a pre-filled VCALENDAR file with the correct MIME
| type, and .ics extension.
|
| Do I have that right?
| omn1 wrote:
| That's correct.
| EGreg wrote:
| Sorry but how is it serverless? Is it a static HTML file with
| JS that does the job? Isn't there a server that the request
| goes to?
| omn1 wrote:
| Good question. It depends on your definition of serverless.
| Strictly speaking there is no serverless, there's always
| some infrastructure somewhere.
|
| However the calendar file gets created out of thin air from
| the GET parameters alone. There is no state or storage
| involved. Other calendar apps have a backend with a DB;
| this one doesn't. Now whether that counts as truly
| serverless is up to you I guess. It's as close as you could
| get with a calendar I'd say. Not easy to get the point
| across in a title. ;) Hope that helps.
| actuallyalys wrote:
| "Stateless" is probably clearer. "Serverless" usually
| refers to services from cloud providers where your code
| is run on demand rather than having a server that is
| idling around (to use a sibling comment's phrase). I
| don't really care for "serverless" as a term because
| there are still servers (as you point out) and there are
| other architectures and cloud services that seem equally
| serverless that aren't usually called that.
| jethro_tell wrote:
| serverless is when you save the state but don't keep a
| machine sitting around when there are no requests, so
| you'd keep your calendar state in a hosted db and when
| someone asks for the calendar, a thread spins up and
| creates the calendar from the state and then disappears
| until there is another request. This is basically the
| exact opposite of serverless
| rustyminnow wrote:
| > serverless is when you [...] don't keep a machine
| sitting around when there are no requests
|
| FTFY
|
| The key part of serverless is that you don't have a
| server idling around. Whether or not you use a hosted db
| is not relevant.
| outworlder wrote:
| And you may even use some 'serverless' DB services. Or
| not. The app is still serverless.
| drexlspivey wrote:
| This can easily run on Cloudflare workers, you don't even
| need a server
| jcelerier wrote:
| ... what do you think those are
| adamrezich wrote:
| this thread is making me feel like I'm going crazy
| aliqot wrote:
| Mmm yes, this one reminds me of the microservices debacle
| from a few years ago about when does your monolith
| technically become a microservice. I can't find the link,
| but I think we were unable to clearly define at which
| point your monolith has become a true 'SoA' microservice
| beast.
| [deleted]
| aaaaaaaaaaab wrote:
| Do you even need a service for this? Couldn't this be a simple
| static HTML + minimal JS that opens a base64 URL with content-
| type "text/x-vcalendar"?
| omn1 wrote:
| Not sure I understand because that's what it is basically.
| The Rust part is just for the routing; it decides whether to
| serve the form or the generated calendar file.
| resoluteteeth wrote:
| What they mean is that instead of using "serverless"
| hosting running a rust program to generate ics files you
| could literally just have a statically hosted html file
| that uses a couple lines of javascript to generate the ics
| files within the browser, so there would be no rust or
| server component at all.
|
| You could just host it with github pages.
|
| Actually I'm confused why you're saying:
|
| > The Rust part is just for the routing
|
| Because it appears that you're generating the ics files in
| rust?
| omn1 wrote:
| Got it. The generator logic is in Rust yes. I could have
| written it in JavaScript as well but it was just easier
| for me to do that part in Rust. Should have mentioned
| that. Of course you could host a static HTML with JS on
| Github pages, but Github pages also runs on a server. So
| to answer the original question, yes you do need some
| server for it unless you make it a command line app.
| aaaaaaaaaaab wrote:
| You can serve a static HTML page from anywhere. GitHub
| pages, S3, maybe even Dropbox. Running a Rust binary is
| an order of magnitude more complex than that.
| ipaddr wrote:
| You need a browser and a file. In your example you need a
| server to make the file and and a browser.
| omn1 wrote:
| True, but for others to resolve the calendar entries
| you'd need to serve that file somewhere.
| [deleted]
| omn1 wrote:
| Author here, had a lot of fun building this as it's just ~100
| lines of Rust code + some CSS/HTML. If someone is looking for a
| fun thing to contribute to during Hacktoberfest, the code is on
| Github: https://github.com/mre/zerocal Will mainly use it for
| myself to send out event links to friends.
| schemescape wrote:
| FYI: the text on your blog post is cropped on my small screen
| (iPhone SE), and scrolling doesn't even help, so its
| essentially unreadable.
| omn1 wrote:
| Thanks for the info. I thought I fixed that lately [1]. I
| don't have an iPhone to test it with but I'll see what I can
| do.
|
| At least on the Chrome viewport emulator it looks fine to
| me...
|
| https://github.com/mre/endler.dev/commit/bc1187d290d153455b0.
| ..
| yewenjie wrote:
| Can it be self-hosted without relying on shuttle.rs? If yes,
| could you please update the readme with instructions?
| omn1 wrote:
| It's just Rust, so it can be. Will add a `main.rs` and some
| instructions, but PRs are welcome if someone beats me to it.
| ;) https://github.com/mre/zerocal/issues/9
| omn1 wrote:
| Update: self-hosting works now. Added instructions to the
| docs. Have fun.
| belkarx wrote:
| The process for making webapps in Rust seems extremely clean
| compared to other languages (or maybe I'm not exposed enough but
| I remember making things with Golang and even just JS was
| _torture_ with common hosting solutions). Props to shuttle.rs and
| the Rust community!
| tomcam wrote:
| > I remember making things with Golang... was torture with
| common hosting solutions)
|
| What made it difficult to deploy Go apps?
| belkarx wrote:
| I did it around 2 years ago: the web solutions were not very
| mature and it was poorly supported (but that's my subjective
| experience)
| aliqot wrote:
| What solutions were you using?
| simlevesque wrote:
| I beg you to keep GET requests idempotent. It's not that hard.
| fny wrote:
| Don't be a party pooper. This is just RPC via HTTP. ;)
| ibotty wrote:
| Maybe I am missing something, but which GET is not idempotent?
| 10000truths wrote:
| There's no state maintained on the server, so all requests made
| to it are idempotent.
___________________________________________________________________
(page generated 2022-10-06 23:00 UTC)