ConsistencyMode.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. # Generated by the protocol buffer compiler. DO NOT EDIT!
  3. # source: protos/ydb_coordination.proto
  4. namespace Ydb\Coordination;
  5. use UnexpectedValueException;
  6. /**
  7. **
  8. * Consistency mode
  9. *
  10. * Protobuf type <code>Ydb.Coordination.ConsistencyMode</code>
  11. */
  12. class ConsistencyMode
  13. {
  14. /**
  15. * The default or current value
  16. *
  17. * Generated from protobuf enum <code>CONSISTENCY_MODE_UNSET = 0;</code>
  18. */
  19. const CONSISTENCY_MODE_UNSET = 0;
  20. /**
  21. * Strict mode makes sure operations may only complete on current leader
  22. *
  23. * Generated from protobuf enum <code>CONSISTENCY_MODE_STRICT = 1;</code>
  24. */
  25. const CONSISTENCY_MODE_STRICT = 1;
  26. /**
  27. * Relaxed mode allows operations to complete on stale masters
  28. *
  29. * Generated from protobuf enum <code>CONSISTENCY_MODE_RELAXED = 2;</code>
  30. */
  31. const CONSISTENCY_MODE_RELAXED = 2;
  32. private static $valueToName = [
  33. self::CONSISTENCY_MODE_UNSET => 'CONSISTENCY_MODE_UNSET',
  34. self::CONSISTENCY_MODE_STRICT => 'CONSISTENCY_MODE_STRICT',
  35. self::CONSISTENCY_MODE_RELAXED => 'CONSISTENCY_MODE_RELAXED',
  36. ];
  37. public static function name($value)
  38. {
  39. if (!isset(self::$valueToName[$value])) {
  40. throw new UnexpectedValueException(sprintf(
  41. 'Enum %s has no name defined for value %s', __CLASS__, $value));
  42. }
  43. return self::$valueToName[$value];
  44. }
  45. public static function value($name)
  46. {
  47. $const = __CLASS__ . '::' . strtoupper($name);
  48. if (!defined($const)) {
  49. throw new UnexpectedValueException(sprintf(
  50. 'Enum %s has no value defined for name %s', __CLASS__, $name));
  51. }
  52. return constant($const);
  53. }
  54. }