twitter/finagle — pull request #157 by mosesn (2013-04-09 03:38:54+00:00)
Title: lets finagle-mysql clients add a hook to be executed after the connection is established

## motivation
I want to be able to be able to set session variables at connection time.

## implementation
I talked to a Database guy at Tumblr, and he said that the way that he had seen it implemented before was usually that when you established the connection, you had the option to pass in arbitrary code that would be executed (ie a block in ruby). This permits a similar syntax, with the added restriction that the session variable must be set before the Service may begin to serve requests (via the map on `hook(service)`).

I chose the type of hooks to be Service[Request, Result] => Future[Unit] so that users don't get confused about how the return value is used. Because the user must discard any computation they do in the callback, it is transparent that the computation is ignored.

## feedback I'd like
I don't really like the name `hooks`. Does anyone have a better idea for what it should be?

## testing
I tried it out by changing a session variable, pretty sure it worked.