title: Varnish VCL - how can I examine req.backend_hint?
body: <p>I have the following VCL file:</p>
  
  <pre><code>vcl 4.0;
  
  import std;
  import directors;
  
  backend one {
      .host = "localhost";
      .port = "3333";
  }
  backend two {
      .host = "127.0.0.1";
      .port = "3334";
  }
  
  sub vcl_init {
    new random_director = directors.random();
    random_director.add_backend(one, 10);  # 2/3 to backend one
    random_director.add_backend(two, 5);   # 1/3 to backend two
  }
  
  sub vcl_recv {
      set req.backend_hint = random_director.backend();
      std.log(req.backend_hint.host);
  }
  </code></pre>
  
  <p>The concept is that I want to re-write the req.url after randomly assigning the user to a backend.</p>
  
  <p>So when a new user arrives, they will be randomly assigned to a backend.  Then I will add some logic with an if statement to re-write the URL path one way if they are assigned to backed one, and another way if they are assigned to backend two.</p>
  
  <p>My problem is that after the line </p>
  
  <pre><code>set req.backend_hint = random_director.backend();
  </code></pre>
  
  <p>I can't figure out which backend the user got assigned to.  In other words, I don't know how to examine req.backend_hint.</p>
  
  <p>I tried to use</p>
  
  <p>std.log(req.backend_hint.host);</p>
  
  <p>but that throws a compilation error (not a STRING_LIST).</p>
  
  <p>The example I have above is adapted from here: <a href="http://book.varnish-software.com/4.0/chapters/Saving_a_Request.html" rel="nofollow noreferrer">http://book.varnish-software.com/4.0/chapters/Saving_a_Request.html</a></p>
  
  <p>So, my question is: how can I inspect req.backend_hint?</p>