backtracking parsers

This may be obvious in retrospect, but I was having some issues with my citation parser – it wasn’t backtracking through disjunctions properly:

lazy val authors: PackratParser[Authors] = (
      author ~ "," ~ authors |
      author ~ "and" ~ author <~ endOfAuthors |
      author ~ "," ~ etal <~ endOfAuthors |
      author ~ etal <~ endOfAuthors

It turns out that it’s a bad idea to try and match together Packrat and normal parsers if you don’t know what you’re doing (aka, if you’re me). I had a parser definition for names that I was using:

lazy val word: Parser[String] = "[p{L}0-9]+".r

Simply forcing this to be a PackratParser cleared things up:

lazy val word: PackratParser[String] = regex("[p{L}0-9]+".r)

sending large messages

Somehow it took me a long time to find this, even though it’s listed in the Akka configuration reference quite plainly.

If you have messages with larger payload sizes – as in you see these kinds of TooLongFrameException errors:

Error[org.jboss.netty.handler.codec.frame.TooLongFrameException:Adjusted frame length exceeds 1048576: 1292205 - discarded

you can adjust the default maximum frame size from 1MB using the following config line:

akka {
    remote.netty.message-frame-size = 100 MiB

It would be really nice if the error message dumped out when a frame is overfilled mentioned this…