<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: src/proto/grpc/testing/messages.proto

namespace Grpc\Testing;

use UnexpectedValueException;

/**
 * The type of route that a client took to reach a server w.r.t. gRPCLB.
 * The server must fill in "fallback" if it detects that the RPC reached
 * the server via the "gRPCLB fallback" path, and "backend" if it detects
 * that the RPC reached the server via "gRPCLB backend" path (i.e. if it got
 * the address of this server from the gRPCLB server BalanceLoad RPC). Exactly
 * how this detection is done is context and server dependent.
 *
 * Protobuf type <code>grpc.testing.GrpclbRouteType</code>
 */
class GrpclbRouteType
{
    /**
     * Server didn't detect the route that a client took to reach it.
     *
     * Generated from protobuf enum <code>GRPCLB_ROUTE_TYPE_UNKNOWN = 0;</code>
     */
    const GRPCLB_ROUTE_TYPE_UNKNOWN = 0;
    /**
     * Indicates that a client reached a server via gRPCLB fallback.
     *
     * Generated from protobuf enum <code>GRPCLB_ROUTE_TYPE_FALLBACK = 1;</code>
     */
    const GRPCLB_ROUTE_TYPE_FALLBACK = 1;
    /**
     * Indicates that a client reached a server as a gRPCLB-given backend.
     *
     * Generated from protobuf enum <code>GRPCLB_ROUTE_TYPE_BACKEND = 2;</code>
     */
    const GRPCLB_ROUTE_TYPE_BACKEND = 2;

    private static $valueToName = [
        self::GRPCLB_ROUTE_TYPE_UNKNOWN => 'GRPCLB_ROUTE_TYPE_UNKNOWN',
        self::GRPCLB_ROUTE_TYPE_FALLBACK => 'GRPCLB_ROUTE_TYPE_FALLBACK',
        self::GRPCLB_ROUTE_TYPE_BACKEND => 'GRPCLB_ROUTE_TYPE_BACKEND',
    ];

    public static function name($value)
    {
        if (!isset(self::$valueToName[$value])) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no name defined for value %s', __CLASS__, $value));
        }
        return self::$valueToName[$value];
    }


    public static function value($name)
    {
        $const = __CLASS__ . '::' . strtoupper($name);
        if (!defined($const)) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no value defined for name %s', __CLASS__, $name));
        }
        return constant($const);
    }
}

