-- Leo's gemini proxy

-- Connecting to senders.io:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini; lang=en;

Devlog 2 - Unit Tests and Streams


I haven't posted since my rant on Thursday. I have actually been on/off developing and trying to find something constructive to say after what was maybe my second worst day of work in a long time.


Progress


I had made some progress in my last devlog but I hadn't gotten things in a runnable state. I actually made another blunder - Streams can't reprocess. I went with streams to begin with because it cuts out the decisions of like "What collection do I use?" But I figured just go with Collection for now and maybe put in the notes on a good way to interact.


Unit tests


> "Hey, why not build a java gemini server? And spend your free time doing what you do at work all day"


This is the brilliant idea I had. I don't feel comfortable sharing code, or even running it in production without at least _most_ of the custom code I have running without a single test hitting it. But that means writing a bunch of unit tests...


JUnit 5


Because I can do two things at once: I can write my server AND learn something new: I am going to use JUni 5. I haven't used JUnit 5 at work yet, we kept everything on 4 and I don't see anything meaningful to make me move but figure at somepoint we'll have to use it and I better get use to it.


Collections


The main bug left in the pre-alpha build was using Streams. You can't reprocess them so you could boot but not load the resources more than once. So we had to change it over to use some other collection. I decided to just go old-school and use the Collection interface and leave it up to the caller. Ideally you would use an immutable data-structure like an Iterable actually. But I didn't think of that until I started writing this log so maybe I'll try that out.


hosts.stream()
...
  .flatMap(h -> routers().stream())
  .flatMap(r -> r.routes().stream())
...

Is essentially what we're left with. To use an Iterable you can do:


StreamSupport.stream(hosts.spliterator(), false)
...
  .flatMap(h -> StreamSupport.stream(h.routers().spliterator(), false))
  .flatMap(r -> StreamSupport.stream(r.routes().spliterator(), false))
...

So while the internal structure matches more with the usage, its usage is just awkward so Collection is just easier honestly... but we'll see.


Pre-Alpha (0.0.1)


I am actually going to finish unit testing this and migrate my server onto this. It still lacks client certificate support and CGIs. But I want to get something in production to run it through its paces.


What is required for alpha? (0.1.x)?


For alpha I want to have: a deployable package, isolated logging (access vs error logs), and maybe even availability on maven central.


What is required for beta? (0.x.x)?


To become beta I need client-certificates, cgi support, a stable API, documentation and contribution documents etc, and 100% be in maven central. Part of me even wants as a goal of post-beta to publish the documents in Gemini as well on my server. (Thank you SNI!)


Conclusion


This wasn't exactly a meaningful devlog as it was really just saying "I am close to a pre-alpha build" and "I goof'd up one thing again". But I figure better to just think this out with you all in my log ... and take a break from unit tests.



Links


Gemlog

Home


-- Response ended

-- Page fetched on Fri Mar 29 12:38:04 2024