This includes the first conference I ever organized (otsconf) and my first real conference talk (Web Conference).
I hope I get more opportunities to speak next year.
GitHub says I made 1434 countable contributions (1650 if you count private repositories) across dozens of repositories.
I now maintain 8 published Rust crates (9 to be really correct) as well as 5 unreleased Rust libraries.
I hope to finish up the remaining crates and polish the existing ones (and maybe bump them to a stable 1.0)
I released 6 versions of hiredis, 2 of hiredis-rb, 4 of hiredis-node and 2 of hiredis-py.
My plan for 2016 is to mark hiredis as stable, push out the 1.0 release and then update the others as well
(considering it might be used in Rails soon, this seems to be a good idea)
About 158 mails on the Redis mailing list were sent by me.
I posted 196 photos on Instagram and my ~/photos/2015 directory now contains about 4600 more photos.
I wrote more than 8600 tweets, more than half of them in reply to someone.
I didn’t quite reach my own goal of writing a bit more,
but 12 blog posts still come down to about one per month.
My year in photos and words
After the busy ending of 2014, 2015 started just as busy.
Away from university, I spend more time working, but I found enough time for conferences and a quick one-week visit in San Francisco in April.
University and work kept me busy the whole summer, but I still catched a bit of the Sun.
After finishing up the Summer semester, I left for Norway in August.
I came back for a weekend to run otsconf. It was a success, but see for yourself:
Back in Norway I had the absolute best time.
For example hiking up a hill, sitting on the Kjeragbolten thousand meter over the Fjord.
My semester ended early on the first of December, so I had another chance to travel around Norway.
Even without a lot of light, the Lofoten are a beautiful place to stay.
With 2015 coming to an end, so are other things. I had to replace my old Laptop, which stayed with me for the last four years.
I really enjoyed living & traveling in Norway and I already put it on my todo list to come back in the summer.
I was lucky to be part of so many different but welcoming communities. It’s a joy every time I meet these people again.
This year was so great because of all the great people I met along the way.
Thanks to the otsconf team, Ola, Shelly, Carsten, Leif and Hendrik.
Again thanks to my employer rrbone and my boss Dominik for giving me opportunities to learn and work.
Thanks to the the new friends I made while living in Norway. I hope we manage to meet up again soon.
Knowing people everywhere is great if you travel and I’m very grateful to all people that hosted me, like Lotte in Hamburg and Tobias in Tromsø.
And thanks to all those I didn’t name explicitely, but who made this year so much fun.
2016 won’t start any less busy.
With my next university semester only starting in April, I will make the best of that time. The next trip starts in less than five days.
Last Monday the Redis Dev Day took place in London, followed by a small Unconference on Tuesday.
The Redis Dev Day is a gathering of all people involved in the Redis development,
that means Redis creator Salvatore as well developers and engineers from several companies
are there to discuss the future development of Redis.
Thanks to Rackspace and especially Nikki I was able to attend as well.
The Dev Day itself was packed with proposals and interesting ideas about improvements and new features for Redis.
In the following I’m trying to sum up some of them, listed by their relevance as I see them (most relevant first).
NoNoSQL for Redis
Salvatore itself proposed this one: Native indexing in Redis.
He recently published an article on indexing based on Sorted Sets.
While this method is manual, it could very well be hidden behind a nice client interface (and indeed there are some out there, I just can’t find a good example).
But having it right inside Redis might be more memory-efficient, faster, avoids transactions and might be easier to use.
Salvatore proposed new commands for that, for example to select based on a previously defined index:
IDXSELECT myindex IFI FIELDS $3 WHERE $1 == 56 and $2 >= 10.00 AND $2 <= 30.00
None of this is final yet, there are a lot of things to get right before this can be implemented.
For example it’s not done with providing the commands for selection based on indexes, but needing to add, update and remove the index is necessary as well.
More in-depth discussions happened the next day, prior to the Unconf.
Even though this kinda goes against the current idea of Redis
– provide the basic tools with a simple API and not much more –
there is the possibility to implement it right and make it as usuable as Redis is right now.
This proposal needs more design effort to get right (both on the exposed API and internal design).
Redis as a Cloud Native
Bill – yes, the real one – always was a heavy user of Sentinel and thus had the most insight on what works and what doesn’t.
And in fact one big thing where Redis still does not work in a way that anyone can be satisfied with is inside a Docker container.
Because of how Sentinel (or Cluster) announce themselves (or monitored instances) and the way Docker remaps ports,
it is currently hardly possible to run it inside a container without unusual configuration (like --net=host).
This needs improvements like making it possible to specify the announce address and port for all running modes.
Another thing that should be doable is configuration replication across nodes in a pod or Cluster.
This could easily be handled by a new command.
Instead of replicating all configuration automatically, this needs to be triggered by an admin, making it easy to only selectively replicate configuration options.
Both things seem necessary and not too hard.
Other proposals include:
Save metadata inside Redis: Additional keyspace, but only exposed through special commands.
I get why this might be wanted by big providers, personally I don’t have a use case for it currently.
Config/Persistence stored in the cloud (Persistence on AWS, Config in etcd/consul/…)
Seems like a lot to add. I’m not convinced this belongs into the Redis core
Redis for Memory as a Service: malloc, but in the cloud
Not sure what would be necessary. SET/GET and GETRANGE already provide a lot. Why not implement this client-side?
Because of a security issue access to the debug feature in Redis was disabled.
This also breaks some of the available options to properly debug Lua scripts.
Debug functionality is needed once you go this route, so bringing it back eventually is a good idea and maybe finally closing very old issues.
For some commands we have STORE options (SORT has it as an option, SINTERSTORE and others are their own command).
A more general form like STORE dest SINTER keyA keyB could make some users happy.
The current code base doesn’t support that in a generic way, but it’s not impossible to change that.
This might need a bit more design effort to be applied to all data types though.
Every time Redis gets discussed the issue about modularity comes up.
Most of the time I am a fan of making components reusable, modularize them where possible and abstract away the hard stuff.
Redis is different here.
A lot of the stuff in Redis interacts with each other and there is hardly a clear cut to make.
Should all underlying data type implementations be extracted?
They are useful for sure elsewhere, but then they won’t benefit from shortcuts made.
Should the IO be completely separated from parsing and dispatching the commands?
Sounds useful for sure, especially now that the base is used in Disque as well.
But again, the coupling allows for some shortcuts.
Should hiredis be integrated and be part of the project? No way, hiredis is also a stand-alone client used by many others.
Keeping it in-tree would make it harder to develop on its on.
One thing we will do for sure is to unify the code base again.
The in-tree hiredis is currently not the same as the stand-alone one, partly due to the updated sds (the string implementation)
and partly because some bugs where fixed in the stand-alone project that don’t affect Redis (I hope so)
There are thousands of ways to note down a date and time.
The international date format is standardized as ISO8601, though it still allows a widespread of different formats.
The basic format looks like this:
And that’s what we will parse today using nom,
a parser combinator library created by Geoffroy Couprie.
The idea is that you write small self-contained parsers, which all do only one simple thing, like parsing the year in our string, and then combine these small parsers to a bigger one to parse the full format.
nom comes with a wide variety of small parsers: handling different integers, reading simple byte arrays, optional fields, mapping parsed data over a function, …
Most of them are provided as combinable macros.
It’s very easy to implement your own small parsers, either by providing a method that handles a short byte buffer or by combining existing parsers.
So let’s dive right in and see how to use nom in real code.
This is what we want to parse:
It has several parts we need to parse:
with the following meaning:
The year, can be negative or null and can be extended if necessary
Month from 1 to 12 (0-prefixed)
Day from 1 to 31 (0-prefixed)
Separator between date and time
Hour, 0-23 (0-prefixed)
Minutes, 0-59 (0-prefixed)
Seconds, 0-59 (0-prefixed)
Timezone offset, separated by a + or - sign or Z for UTC
Parts like the seconds and the timezone offset are optional. Datetime strings without them will default to a zero value for that field.
The date parts are separated by a dash (-) and the time parts by a colon (:).
We will built a small parser for each of these parts and at the end combine them to parse a full date time string.
Parsing the date: 2015-07-16
Let’s start with the sign. As we need it several times, we create its own parser for that.
Parsers are created by giving them a name, stating the return value (or defaulting to a byte slice) and the parser combinators to handle the input.
First, we parse either a plus or a minus sign.
This combines two already existing parsers: tag!, which will match the given byte array (in our case a single character) and alt!, which will try a list of parsers, returning on the first successful one.
We can directly map the result of the sub-parsers to either -1 or 1, so we don’t need to deal with the byte slice later.
Next we parse the year, which consists of an optional sign and 4 digits (I know, I know, it is possible to extend this to more digits, but let’s keep it simple for now).
This creates a new named parser, that again returns the remaining input and an 32-bit integer.
To work, it first calls take_4_digits and then maps that result to the corresponding integer (using a small helper function).
take_4_digits is another small helper parser. We also got one for 2 digits:
This takes 4 (or 2) characters from the input and checks that each character is a digit.
flat_map! and check! are quite generic, so they are useful for a lot of cases.
The year is also returned as a 32-bit integer (there’s a pattern!).
Using the chain! macro, we can chain together multiple parsers and work with the sub-results.
Our sign is directly followed by 4 digits. It’s optional though, that’s why we use opt!.
~ is the concatenation operator in the chain! macro.
We save the sub-results to variables (pref and y).
To get the final result, we multiply the prefix (which comes back as either 1 or -1) with the year.
Don’t forget the , (comma) right before the closure.
This is a small syntactic hint for the chain! macro that the mapping function will follow and no more parsers.
Our nom parser will return an IResult. If all went well, we get Done(I,O) with I and O being the appropriate types.
For our case I is the same as the input, a buffer slice (&[u8]), and O is the output of the parser itself, an integer (i32).
The return value could also be an Error(Err), if something went completely wrong, or Incomplete(u32), requesting more data to be able to satisfy the parser (you can’t parse a 4-digit year with only 3 characters input).
Parsing the month and day is a bit easier now: we simply take the digits and map them to an integer:
As you can see, even chain! parsers can be nested.
The sub-parts then must be mapped once for the inner parser and once into the final value of the outer parser.
empty_or! returns an Option. Either None if there is no input left or it applies the nested parser. If this parser doesn’t fail, Some(value) is returned.
Above are three variants of valid dates with timezones.
The timezone in an ISO8601 string is either an appended Z, indicating UTC,
or it’s separated using a sign (+ or -) and appends the offset from UTC in hours and minutes (with the minutes being optional).
We can re-use our already existing parsers and once again chain them to get what we want.
The minutes are optional (and might be separated using a colon).
Instead of keeping this as is, we’re mapping it to the offset in seconds.
We will see why later.
We could also just map it to a tuple like (s, h, m.unwrap_or(0)) and handle conversion at a later point.
But this is fine for now. We can handle the actual validation in a later step.
For example, we could use chrono, a time library, to handle this for us.
Using chrono it’s obvious why we already multiplied our timezone offset to be in seconds: this time we can just hand it off to chrono as is.
The full code for this ISO8601 parser is available in easy.rs. The repository also includes a more complex parser, that does some validation while parsing
(it checks that the time and date are reasonable values, but it does not check that it is a valid date for example)
These simple parsers or even some more complex ones are already usable.
At least if you already got all the data at hand and if a simple return value satisfies your needs.
But especially for larger and more complex formats like media files reading everything into memory and spitting out a single large value isn’t sufficient at all.
nom is prepared for that.
Soon it will become as easy as using an object from which nom can Read.
For most things you shouldn’t worry about that, as a simple BufReader will work.
For the other end of the chain, nom has Consumers.
A Consumer handles the complex part of actually requesting data, calling the right sub-parsers and holding the necessary state.
This is what you need to build yourself.
Internally it’s best abstracted using some kind of state machine, so you always know which part of the format to expect next, how to parse it, what to return to the user and so on.
Take a look at the MP4 parser, which has an MP4Consumer handling the different parts of the format.
Soon my own library, rdb-rs, will have this as well.
Small thing aside: Geoffroy created machine to define a state machine and I got microstate for this.
Why am I doing this?
I’m currently developing rdb-rs, a library to parse and analyze Redis dump files.
It’s currently limited to parsing and reformatting into several formats and can be mainly used as a CLI utility.
But there are projects that could benefit from a nicer API to integrate it into another tool.
The current parser is hand-made. It’s fast, it’s working, but it provides a limited, not very extensible API.
I hope to get a proper parser done with nom, that I can build on to provide all necessary methods, while still being super-fast and memory-safe.
Work already started, but I’m far from done for now
Thanks to Geoffroy for the discussions, the help and for reading a draft of this post.
In the last week there were several questions regarding Redis Sentinel and Redis Cluster, if one or the other will go away or if they need to be used in combination.
This post tries to give a short and precise info about both and what they are used for.
Redis Sentinel was born in 2012 and first released when Redis 2.4 was stable.
It is a system designed to help managing Redis instances.
It will monitor your master & slave instances, notify you about changed
behaviour, handle automatic failover in case a master is down and act as a
configuration provider, so your clients can find the current master
Redis Sentinel runs as a seperate program.
You should have atleast 3 Sentinel instances monitoring a master instance and its slaves.
Sentinel instances try to find consensus when doing a failover and only an odd number of instances will prevent most problems, 3 being the minimum.
In this case one of the Sentinel instances can go down and a failover will still work as (hopefully) the other two instances reach consensus which slave to promote.
One thing about the configurable quorum: this is only the number of Sentinel who have to agree a master is down.
You still need N/2 + 1 Sentinels to vote for a slave to be promoted (that N is the total number of all Sentinels ever seen for this pod).
A pod of Sentinels can monitor multiple Redis master & slave nodes. Just make sure you don’t mix up names, add slaves to the right master and so on.
If we go by first commit,
then Cluster is even older than Sentinel, dating back to 2011.
There’s a bit more info in antirez’ blog.
It’s released as stable with version 3.0 as of April 1st, 2015.
Redis Cluster is a data sharding solution with automatic management, handling failover and replication.
With Redis Cluster your data is split across multiple nodes, each one holding a subset of the full data.
Slave instances replicate a single master and act as fallback instances.
In case a master instance will become unavailable due to network splits or software/hardware crashes,
the remaining Master nodes in the Cluster will register this and will reach a state triggering a failover.
A suitable Slave of the unavailable Master node will then step up and will be promoted to takeover as a new Master.
You don’t need additional failover handling when using Redis Cluster and you should definitely not point Sentinel instances at any of the Cluster nodes.
You also want to use a smart client library that knows about Redis Cluster, so it can automatically redirect you to the right nodes when accessing data.
Back in 2011 I got a Kindle 4 (the non-touch version) and for some time it was
the primary device for reading, be it ebooks, technical documentation or slides
and transcripts from university.
But then I was using it less and less and for the last one and a half years it basically layed around unused.
While it is a good device for book reading, it isn’t for other content.
It’s slow, it can’t handle PDFs properly (zooming is just awful) and adding notes is really annoying with that on-screen keyboard.
Well, what better to do with a lazy holiday then doing some hacking with the Kindle? And so I did and this is the current result: It displays the weather forecast.
As the original article is quite short on the precise steps to get this finished, I wanted to write them up here.
(Just in case: I’m not responsible if you break your kindle while hacking around with it.)
First you need to jailbreak your Kindle, this will make the following things a bit easier. You should get it done using this short guide.
The next step is to set up SSH to get shell access on the Kindle.
I used the USBnet variant described in the Kindle 4 NT Hacking Guide (yes, that’s the same as the Jailbreak one).
Despite its name this can enable the SSH daemon on the WiFi interface too.
Attach the Kindle via USB, mount it and then open the usbnet/etc/config and add:
Now you can also enable auto-starting USBnet. Caution: As long as USBnet is running, you can’t mount the Kindle.
# the Kindle should be mounted into /mnt/sdb1
mv /mnt/sdb1/usbnet/DISABLED_auto /mnt/sdb1/usbnet/auto
Next, reboot your device. Once it’s back up you should be able to connect to it via SSH on the IP it has in your WiFi network.
The root password is either mario or of the form fionaABCD. Use the Kindle root password tool to find out based on the serial number.
There’s just one more tool: Kite, the application launcher.
You can get it in this forum post. Installation is easy once you got the kite.gz.
Copy the kite file to the kindle, then execute it:
One thing to note: You just downloaded some binary blob from some random forum and executed it.
But you did that with the jailbreak and USBnet above anyway.
And hey, that’s how these things worked back in the old days, it actually was totally normal in the PSP scene too
Back to our project: Reboot the Kindle and in the start screen you should see some note that Kite is started as well.
The Kindle will also contain some new directories:
root@kindle# ls -l /mnt/us/kite
drwxr-xr-x 2 root root 8192 May 14 12:13 onboot
drwxr-xr-x 2 root root 8192 May 14 11:57 ondrop
onboot is the relevant one. All scripts in there are executed by Kite on startup of the Kindle.
That’s where we disable some stuff and display our image for the first time.
Write the following code to a file init-weather.sh and place it in onboot (or just get it from the repository):
This will disable the framework (= the Kindle UI basically) and the power management daemon (= responsible for disabling WiFi and switching to the screensaver if idle for too long).
In case you want to get back to the old state, just enable framework and powerd again (and first remove the init-weather.sh which will otherwise directly disable them again).
The display-weather.sh script now does the hard stuff, which is pretty easy: Clear the screen, get a new image, display it.
The script will now be executed every day at 7:00 and 19:00, showing a picture from the internet (well, at best it’s a picture you generated).
As this post is already getting quite long, I leave the server-side up to you.
All files (for both the Kindle and the server part) are in the GitHub repository: kindle-weather-display.
This is the final result: My Kindle hanging on the wall right under the calendar. :)
Thanks to @e2b for proofreading a draft of this post.