librelist archives

« back to archive

Re: [brando] Using Response extractors

Re: [brando] Using Response extractors

From:
Gaetan Hervouet
Date:
2014-04-09 @ 16:37
Hi MG,

I put up a gist together to help you with the extractors 
: https://gist.github.com/gramk/10289838

Basically, the exactors uses the unapply method. This can be used anywhere
you are doing pattern matching (for yield loop, receive… )

In this example, brando is going to reply with a List[Option[ByteString]] 
to the actor.

Response.AsStringsHash matches on that and extracts a Map[String,String] 
from it. That’s what you’ll get in the hash variable.

Hope this helps.

Cheers,
GH 


> Hey All,
>
> Relatively new to scala and trying out Brando as part of a boilerplate 
learning project.
>
> I'm a little confused how to use the response extractors?  Right now, I 
just match in my receive method on Some[ByteString] to see the responses 
from my brando actor instance.  Is there a way to match directly on the 
type of response?  Could someone provide a usage example of this that 
doesn't use the ask pattern in the wiki?  Thanks!
>
> ~MG

Re: [brando] Using Response extractors

From:
Mark Grey
Date:
2014-04-09 @ 18:33
Many many thanks Gaetan, this is great!

~MGII


On Wed, Apr 9, 2014 at 12:37 PM, Gaetan Hervouet <ghervouet@mdialog.com>wrote:

> Hi MG,
>
> I put up a gist together to help you with the extractors :
> https://gist.github.com/gramk/10289838
>
> Basically, the exactors uses the unapply method. This can be used anywhere
> you are doing pattern matching (for yield loop, receive... )
>
> In this example, brando is going to reply with a List[Option[ByteString]]
> to the actor.
>
> Response.AsStringsHash matches on that and extracts a Map[Stri ng,String]
> from it. That's what you'll get in the hash variable.
>
> Hope this helps.
>
> Cheers,
> GH
>
>
> > Hey All,
> >
> > Relatively new to scala and trying out Brando as part of a boilerplate
> learning project.
> >
> > I'm a little confused how to use the response extractors?  Right now, I
> just match in my receive method on Some[ByteString] to see the responses
> from my brando actor instance.  Is there a way to match directly on the
> type of response?  Could someone provide a usage example of this that
> doesn't use the ask pattern in the wiki?  Thanks!
> >
> > ~MG
>
>