Imported Upstream version 1.41.0
[platform/upstream/grpc.git] / src / php / tests / interop / Grpc / Testing / GrpclbRouteType.php
1 <?php
2 # Generated by the protocol buffer compiler.  DO NOT EDIT!
3 # source: src/proto/grpc/testing/messages.proto
4
5 namespace Grpc\Testing;
6
7 use UnexpectedValueException;
8
9 /**
10  * The type of route that a client took to reach a server w.r.t. gRPCLB.
11  * The server must fill in "fallback" if it detects that the RPC reached
12  * the server via the "gRPCLB fallback" path, and "backend" if it detects
13  * that the RPC reached the server via "gRPCLB backend" path (i.e. if it got
14  * the address of this server from the gRPCLB server BalanceLoad RPC). Exactly
15  * how this detection is done is context and server dependent.
16  *
17  * Protobuf type <code>grpc.testing.GrpclbRouteType</code>
18  */
19 class GrpclbRouteType
20 {
21     /**
22      * Server didn't detect the route that a client took to reach it.
23      *
24      * Generated from protobuf enum <code>GRPCLB_ROUTE_TYPE_UNKNOWN = 0;</code>
25      */
26     const GRPCLB_ROUTE_TYPE_UNKNOWN = 0;
27     /**
28      * Indicates that a client reached a server via gRPCLB fallback.
29      *
30      * Generated from protobuf enum <code>GRPCLB_ROUTE_TYPE_FALLBACK = 1;</code>
31      */
32     const GRPCLB_ROUTE_TYPE_FALLBACK = 1;
33     /**
34      * Indicates that a client reached a server as a gRPCLB-given backend.
35      *
36      * Generated from protobuf enum <code>GRPCLB_ROUTE_TYPE_BACKEND = 2;</code>
37      */
38     const GRPCLB_ROUTE_TYPE_BACKEND = 2;
39
40     private static $valueToName = [
41         self::GRPCLB_ROUTE_TYPE_UNKNOWN => 'GRPCLB_ROUTE_TYPE_UNKNOWN',
42         self::GRPCLB_ROUTE_TYPE_FALLBACK => 'GRPCLB_ROUTE_TYPE_FALLBACK',
43         self::GRPCLB_ROUTE_TYPE_BACKEND => 'GRPCLB_ROUTE_TYPE_BACKEND',
44     ];
45
46     public static function name($value)
47     {
48         if (!isset(self::$valueToName[$value])) {
49             throw new UnexpectedValueException(sprintf(
50                     'Enum %s has no name defined for value %s', __CLASS__, $value));
51         }
52         return self::$valueToName[$value];
53     }
54
55
56     public static function value($name)
57     {
58         $const = __CLASS__ . '::' . strtoupper($name);
59         if (!defined($const)) {
60             throw new UnexpectedValueException(sprintf(
61                     'Enum %s has no value defined for name %s', __CLASS__, $name));
62         }
63         return constant($const);
64     }
65 }
66