librelist archives

« back to archive

Brando usage question ...

Brando usage question ...

From:
Alex Curtis
Date:
2014-09-20 @ 13:08
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <font size="-1"><font face="Arial">hi there,<br>
        <br>
        I'm just trying out Brando and so far it seems great - very well
        done. <br>
        <br>
        I'm not sure what scala structure I should / can use within the
        provided response extractors to cope with the case that the
        request fails. eg from your guide I already have : <br>
        <font face="Courier New, Courier, monospace"><br>
          val redisLookup = for {<br>
            brando.Response.AsString(value) <- redis ?
          brando.Request("GET", "key")<br>
          } yield value match {<br>
            case None => <br>
              < need to handle error ><br>
            case s:String =><br>
              log.info("Got a string from Redis, value : " + s)<br>
            case _ =><br>
              log.info("Response from Redis was unknown.")<br>
          }<br>
        </font><br>
        but how can I modify this to also cope with a NULL coming back 
        ? Since I'm already "AsString" ing it, it will only ever be a
        string. <br>
        <br>
        Can you offer any advice, help, suggestions please ? <br>
        <br>
        Many thanks,<br>
        Alex<br>
      </font></font>
  </body>
</html>

Re: Brando usage question ...

From:
Alex Curtis
Date:
2014-09-20 @ 15:04
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <font size="-1"><font face="Arial">..as with most help questions ..
        they sort themselves out in the end. Think I've got it working
        as I want with ...<br>
        <br>
        <font face="Courier New, Courier, monospace">  for {<br>
              r <- redis ? brando.Request("GET", "key")<br>
            } yield {<br>
              r match {<br>
                case brando.Response.AsString(s) 
=> log.info("Got a
          string from Brando : " + s)   <br>
                case Failure 
=>                    
log.info("Got a
          failure from Brando")<br>
                case None => 
                      
log.info("Got a
          none from Brando")<br>
                case _ 
=>                          
log.info("Got
          some unknown reply from Brando")<br>
              }<br>
            }<br>
        </font><br>
        <br>
        Sry for being email trigger happy (and asleep !) before ...<br>
        <br>
        <br>
      </font></font>
    <div class="moz-cite-prefix">On 20/09/2014 15:08, Alex Curtis wrote:<br>
    </div>
    <blockquote cite="mid:541D7C36.9080401@outlook.com" type="cite">
      <meta http-equiv="content-type" content="text/html;
        charset=ISO-8859-1">
      <font size="-1"><font face="Arial">hi there,<br>
          <br>
          I'm just trying out Brando and so far it seems great - very
          well done. <br>
          <br>
          I'm not sure what scala structure I should / can use within
          the provided response extractors to cope with the case that
          the request fails. eg from your guide I already have : <br>
          <font face="Courier New, Courier, monospace"><br>
            val redisLookup = for {<br>
              brando.Response.AsString(value) <- redis ?
            brando.Request("GET", "key")<br>
            } yield value match {<br>
              case None => <br>
                < need to handle error ><br>
              case s:String =><br>
                log.info("Got a string from Redis, value : " + s)<br>
              case _ =><br>
                log.info("Response from Redis was unknown.")<br>
            }<br>
          </font><br>
          but how can I modify this to also cope with a NULL coming
          back  ? Since I'm already "AsString" ing it, it will only ever
          be a string. <br>
          <br>
          Can you offer any advice, help, suggestions please ? <br>
          <br>
          Many thanks,<br>
          Alex<br>
        </font></font> </blockquote>
    <br>
  </body>
</html>