kv.pb.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. // Code generated by protoc-gen-gogo.
  2. // source: kv.proto
  3. // DO NOT EDIT!
  4. /*
  5. Package storagepb is a generated protocol buffer package.
  6. It is generated from these files:
  7. kv.proto
  8. It has these top-level messages:
  9. KeyValue
  10. Event
  11. */
  12. package storagepb
  13. import proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
  14. // discarding unused import gogoproto "github.com/coreos/etcd/Godeps/_workspace/src/gogoproto"
  15. import io "io"
  16. import fmt "fmt"
  17. // Reference imports to suppress errors if they are not otherwise used.
  18. var _ = proto.Marshal
  19. type Event_EventType int32
  20. const (
  21. PUT Event_EventType = 0
  22. DELETE Event_EventType = 1
  23. EXPIRE Event_EventType = 2
  24. )
  25. var Event_EventType_name = map[int32]string{
  26. 0: "PUT",
  27. 1: "DELETE",
  28. 2: "EXPIRE",
  29. }
  30. var Event_EventType_value = map[string]int32{
  31. "PUT": 0,
  32. "DELETE": 1,
  33. "EXPIRE": 2,
  34. }
  35. func (x Event_EventType) String() string {
  36. return proto.EnumName(Event_EventType_name, int32(x))
  37. }
  38. type KeyValue struct {
  39. Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
  40. CreateRevision int64 `protobuf:"varint,2,opt,name=create_revision,proto3" json:"create_revision,omitempty"`
  41. // mod_revision is the last modified revision of the key.
  42. ModRevision int64 `protobuf:"varint,3,opt,name=mod_revision,proto3" json:"mod_revision,omitempty"`
  43. // version is the version of the key. A deletion resets
  44. // the version to zero and any modification of the key
  45. // increases its version.
  46. Version int64 `protobuf:"varint,4,opt,name=version,proto3" json:"version,omitempty"`
  47. Value []byte `protobuf:"bytes,5,opt,name=value,proto3" json:"value,omitempty"`
  48. // lease is the ID of the lease that attached to key.
  49. // When the attached lease expires, the key will be deleted.
  50. Lease int64 `protobuf:"varint,6,opt,name=lease,proto3" json:"lease,omitempty"`
  51. }
  52. func (m *KeyValue) Reset() { *m = KeyValue{} }
  53. func (m *KeyValue) String() string { return proto.CompactTextString(m) }
  54. func (*KeyValue) ProtoMessage() {}
  55. type Event struct {
  56. Type Event_EventType `protobuf:"varint,1,opt,name=type,proto3,enum=storagepb.Event_EventType" json:"type,omitempty"`
  57. // a put event contains the current key-value
  58. // a delete/expire event contains the previous
  59. // key-value
  60. Kv *KeyValue `protobuf:"bytes,2,opt,name=kv" json:"kv,omitempty"`
  61. // watchID is the ID of watching this event is sent to.
  62. WatchID int64 `protobuf:"varint,3,opt,name=watchID,proto3" json:"watchID,omitempty"`
  63. }
  64. func (m *Event) Reset() { *m = Event{} }
  65. func (m *Event) String() string { return proto.CompactTextString(m) }
  66. func (*Event) ProtoMessage() {}
  67. func init() {
  68. proto.RegisterEnum("storagepb.Event_EventType", Event_EventType_name, Event_EventType_value)
  69. }
  70. func (m *KeyValue) Marshal() (data []byte, err error) {
  71. size := m.Size()
  72. data = make([]byte, size)
  73. n, err := m.MarshalTo(data)
  74. if err != nil {
  75. return nil, err
  76. }
  77. return data[:n], nil
  78. }
  79. func (m *KeyValue) MarshalTo(data []byte) (int, error) {
  80. var i int
  81. _ = i
  82. var l int
  83. _ = l
  84. if m.Key != nil {
  85. if len(m.Key) > 0 {
  86. data[i] = 0xa
  87. i++
  88. i = encodeVarintKv(data, i, uint64(len(m.Key)))
  89. i += copy(data[i:], m.Key)
  90. }
  91. }
  92. if m.CreateRevision != 0 {
  93. data[i] = 0x10
  94. i++
  95. i = encodeVarintKv(data, i, uint64(m.CreateRevision))
  96. }
  97. if m.ModRevision != 0 {
  98. data[i] = 0x18
  99. i++
  100. i = encodeVarintKv(data, i, uint64(m.ModRevision))
  101. }
  102. if m.Version != 0 {
  103. data[i] = 0x20
  104. i++
  105. i = encodeVarintKv(data, i, uint64(m.Version))
  106. }
  107. if m.Value != nil {
  108. if len(m.Value) > 0 {
  109. data[i] = 0x2a
  110. i++
  111. i = encodeVarintKv(data, i, uint64(len(m.Value)))
  112. i += copy(data[i:], m.Value)
  113. }
  114. }
  115. if m.Lease != 0 {
  116. data[i] = 0x30
  117. i++
  118. i = encodeVarintKv(data, i, uint64(m.Lease))
  119. }
  120. return i, nil
  121. }
  122. func (m *Event) Marshal() (data []byte, err error) {
  123. size := m.Size()
  124. data = make([]byte, size)
  125. n, err := m.MarshalTo(data)
  126. if err != nil {
  127. return nil, err
  128. }
  129. return data[:n], nil
  130. }
  131. func (m *Event) MarshalTo(data []byte) (int, error) {
  132. var i int
  133. _ = i
  134. var l int
  135. _ = l
  136. if m.Type != 0 {
  137. data[i] = 0x8
  138. i++
  139. i = encodeVarintKv(data, i, uint64(m.Type))
  140. }
  141. if m.Kv != nil {
  142. data[i] = 0x12
  143. i++
  144. i = encodeVarintKv(data, i, uint64(m.Kv.Size()))
  145. n1, err := m.Kv.MarshalTo(data[i:])
  146. if err != nil {
  147. return 0, err
  148. }
  149. i += n1
  150. }
  151. if m.WatchID != 0 {
  152. data[i] = 0x18
  153. i++
  154. i = encodeVarintKv(data, i, uint64(m.WatchID))
  155. }
  156. return i, nil
  157. }
  158. func encodeFixed64Kv(data []byte, offset int, v uint64) int {
  159. data[offset] = uint8(v)
  160. data[offset+1] = uint8(v >> 8)
  161. data[offset+2] = uint8(v >> 16)
  162. data[offset+3] = uint8(v >> 24)
  163. data[offset+4] = uint8(v >> 32)
  164. data[offset+5] = uint8(v >> 40)
  165. data[offset+6] = uint8(v >> 48)
  166. data[offset+7] = uint8(v >> 56)
  167. return offset + 8
  168. }
  169. func encodeFixed32Kv(data []byte, offset int, v uint32) int {
  170. data[offset] = uint8(v)
  171. data[offset+1] = uint8(v >> 8)
  172. data[offset+2] = uint8(v >> 16)
  173. data[offset+3] = uint8(v >> 24)
  174. return offset + 4
  175. }
  176. func encodeVarintKv(data []byte, offset int, v uint64) int {
  177. for v >= 1<<7 {
  178. data[offset] = uint8(v&0x7f | 0x80)
  179. v >>= 7
  180. offset++
  181. }
  182. data[offset] = uint8(v)
  183. return offset + 1
  184. }
  185. func (m *KeyValue) Size() (n int) {
  186. var l int
  187. _ = l
  188. if m.Key != nil {
  189. l = len(m.Key)
  190. if l > 0 {
  191. n += 1 + l + sovKv(uint64(l))
  192. }
  193. }
  194. if m.CreateRevision != 0 {
  195. n += 1 + sovKv(uint64(m.CreateRevision))
  196. }
  197. if m.ModRevision != 0 {
  198. n += 1 + sovKv(uint64(m.ModRevision))
  199. }
  200. if m.Version != 0 {
  201. n += 1 + sovKv(uint64(m.Version))
  202. }
  203. if m.Value != nil {
  204. l = len(m.Value)
  205. if l > 0 {
  206. n += 1 + l + sovKv(uint64(l))
  207. }
  208. }
  209. if m.Lease != 0 {
  210. n += 1 + sovKv(uint64(m.Lease))
  211. }
  212. return n
  213. }
  214. func (m *Event) Size() (n int) {
  215. var l int
  216. _ = l
  217. if m.Type != 0 {
  218. n += 1 + sovKv(uint64(m.Type))
  219. }
  220. if m.Kv != nil {
  221. l = m.Kv.Size()
  222. n += 1 + l + sovKv(uint64(l))
  223. }
  224. if m.WatchID != 0 {
  225. n += 1 + sovKv(uint64(m.WatchID))
  226. }
  227. return n
  228. }
  229. func sovKv(x uint64) (n int) {
  230. for {
  231. n++
  232. x >>= 7
  233. if x == 0 {
  234. break
  235. }
  236. }
  237. return n
  238. }
  239. func sozKv(x uint64) (n int) {
  240. return sovKv(uint64((x << 1) ^ uint64((int64(x) >> 63))))
  241. }
  242. func (m *KeyValue) Unmarshal(data []byte) error {
  243. l := len(data)
  244. iNdEx := 0
  245. for iNdEx < l {
  246. var wire uint64
  247. for shift := uint(0); ; shift += 7 {
  248. if iNdEx >= l {
  249. return io.ErrUnexpectedEOF
  250. }
  251. b := data[iNdEx]
  252. iNdEx++
  253. wire |= (uint64(b) & 0x7F) << shift
  254. if b < 0x80 {
  255. break
  256. }
  257. }
  258. fieldNum := int32(wire >> 3)
  259. wireType := int(wire & 0x7)
  260. switch fieldNum {
  261. case 1:
  262. if wireType != 2 {
  263. return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
  264. }
  265. var byteLen int
  266. for shift := uint(0); ; shift += 7 {
  267. if iNdEx >= l {
  268. return io.ErrUnexpectedEOF
  269. }
  270. b := data[iNdEx]
  271. iNdEx++
  272. byteLen |= (int(b) & 0x7F) << shift
  273. if b < 0x80 {
  274. break
  275. }
  276. }
  277. if byteLen < 0 {
  278. return ErrInvalidLengthKv
  279. }
  280. postIndex := iNdEx + byteLen
  281. if postIndex > l {
  282. return io.ErrUnexpectedEOF
  283. }
  284. m.Key = append([]byte{}, data[iNdEx:postIndex]...)
  285. iNdEx = postIndex
  286. case 2:
  287. if wireType != 0 {
  288. return fmt.Errorf("proto: wrong wireType = %d for field CreateRevision", wireType)
  289. }
  290. m.CreateRevision = 0
  291. for shift := uint(0); ; shift += 7 {
  292. if iNdEx >= l {
  293. return io.ErrUnexpectedEOF
  294. }
  295. b := data[iNdEx]
  296. iNdEx++
  297. m.CreateRevision |= (int64(b) & 0x7F) << shift
  298. if b < 0x80 {
  299. break
  300. }
  301. }
  302. case 3:
  303. if wireType != 0 {
  304. return fmt.Errorf("proto: wrong wireType = %d for field ModRevision", wireType)
  305. }
  306. m.ModRevision = 0
  307. for shift := uint(0); ; shift += 7 {
  308. if iNdEx >= l {
  309. return io.ErrUnexpectedEOF
  310. }
  311. b := data[iNdEx]
  312. iNdEx++
  313. m.ModRevision |= (int64(b) & 0x7F) << shift
  314. if b < 0x80 {
  315. break
  316. }
  317. }
  318. case 4:
  319. if wireType != 0 {
  320. return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType)
  321. }
  322. m.Version = 0
  323. for shift := uint(0); ; shift += 7 {
  324. if iNdEx >= l {
  325. return io.ErrUnexpectedEOF
  326. }
  327. b := data[iNdEx]
  328. iNdEx++
  329. m.Version |= (int64(b) & 0x7F) << shift
  330. if b < 0x80 {
  331. break
  332. }
  333. }
  334. case 5:
  335. if wireType != 2 {
  336. return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType)
  337. }
  338. var byteLen int
  339. for shift := uint(0); ; shift += 7 {
  340. if iNdEx >= l {
  341. return io.ErrUnexpectedEOF
  342. }
  343. b := data[iNdEx]
  344. iNdEx++
  345. byteLen |= (int(b) & 0x7F) << shift
  346. if b < 0x80 {
  347. break
  348. }
  349. }
  350. if byteLen < 0 {
  351. return ErrInvalidLengthKv
  352. }
  353. postIndex := iNdEx + byteLen
  354. if postIndex > l {
  355. return io.ErrUnexpectedEOF
  356. }
  357. m.Value = append([]byte{}, data[iNdEx:postIndex]...)
  358. iNdEx = postIndex
  359. case 6:
  360. if wireType != 0 {
  361. return fmt.Errorf("proto: wrong wireType = %d for field Lease", wireType)
  362. }
  363. m.Lease = 0
  364. for shift := uint(0); ; shift += 7 {
  365. if iNdEx >= l {
  366. return io.ErrUnexpectedEOF
  367. }
  368. b := data[iNdEx]
  369. iNdEx++
  370. m.Lease |= (int64(b) & 0x7F) << shift
  371. if b < 0x80 {
  372. break
  373. }
  374. }
  375. default:
  376. var sizeOfWire int
  377. for {
  378. sizeOfWire++
  379. wire >>= 7
  380. if wire == 0 {
  381. break
  382. }
  383. }
  384. iNdEx -= sizeOfWire
  385. skippy, err := skipKv(data[iNdEx:])
  386. if err != nil {
  387. return err
  388. }
  389. if skippy < 0 {
  390. return ErrInvalidLengthKv
  391. }
  392. if (iNdEx + skippy) > l {
  393. return io.ErrUnexpectedEOF
  394. }
  395. iNdEx += skippy
  396. }
  397. }
  398. return nil
  399. }
  400. func (m *Event) Unmarshal(data []byte) error {
  401. l := len(data)
  402. iNdEx := 0
  403. for iNdEx < l {
  404. var wire uint64
  405. for shift := uint(0); ; shift += 7 {
  406. if iNdEx >= l {
  407. return io.ErrUnexpectedEOF
  408. }
  409. b := data[iNdEx]
  410. iNdEx++
  411. wire |= (uint64(b) & 0x7F) << shift
  412. if b < 0x80 {
  413. break
  414. }
  415. }
  416. fieldNum := int32(wire >> 3)
  417. wireType := int(wire & 0x7)
  418. switch fieldNum {
  419. case 1:
  420. if wireType != 0 {
  421. return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
  422. }
  423. m.Type = 0
  424. for shift := uint(0); ; shift += 7 {
  425. if iNdEx >= l {
  426. return io.ErrUnexpectedEOF
  427. }
  428. b := data[iNdEx]
  429. iNdEx++
  430. m.Type |= (Event_EventType(b) & 0x7F) << shift
  431. if b < 0x80 {
  432. break
  433. }
  434. }
  435. case 2:
  436. if wireType != 2 {
  437. return fmt.Errorf("proto: wrong wireType = %d for field Kv", wireType)
  438. }
  439. var msglen int
  440. for shift := uint(0); ; shift += 7 {
  441. if iNdEx >= l {
  442. return io.ErrUnexpectedEOF
  443. }
  444. b := data[iNdEx]
  445. iNdEx++
  446. msglen |= (int(b) & 0x7F) << shift
  447. if b < 0x80 {
  448. break
  449. }
  450. }
  451. if msglen < 0 {
  452. return ErrInvalidLengthKv
  453. }
  454. postIndex := iNdEx + msglen
  455. if postIndex > l {
  456. return io.ErrUnexpectedEOF
  457. }
  458. if m.Kv == nil {
  459. m.Kv = &KeyValue{}
  460. }
  461. if err := m.Kv.Unmarshal(data[iNdEx:postIndex]); err != nil {
  462. return err
  463. }
  464. iNdEx = postIndex
  465. case 3:
  466. if wireType != 0 {
  467. return fmt.Errorf("proto: wrong wireType = %d for field WatchID", wireType)
  468. }
  469. m.WatchID = 0
  470. for shift := uint(0); ; shift += 7 {
  471. if iNdEx >= l {
  472. return io.ErrUnexpectedEOF
  473. }
  474. b := data[iNdEx]
  475. iNdEx++
  476. m.WatchID |= (int64(b) & 0x7F) << shift
  477. if b < 0x80 {
  478. break
  479. }
  480. }
  481. default:
  482. var sizeOfWire int
  483. for {
  484. sizeOfWire++
  485. wire >>= 7
  486. if wire == 0 {
  487. break
  488. }
  489. }
  490. iNdEx -= sizeOfWire
  491. skippy, err := skipKv(data[iNdEx:])
  492. if err != nil {
  493. return err
  494. }
  495. if skippy < 0 {
  496. return ErrInvalidLengthKv
  497. }
  498. if (iNdEx + skippy) > l {
  499. return io.ErrUnexpectedEOF
  500. }
  501. iNdEx += skippy
  502. }
  503. }
  504. return nil
  505. }
  506. func skipKv(data []byte) (n int, err error) {
  507. l := len(data)
  508. iNdEx := 0
  509. for iNdEx < l {
  510. var wire uint64
  511. for shift := uint(0); ; shift += 7 {
  512. if iNdEx >= l {
  513. return 0, io.ErrUnexpectedEOF
  514. }
  515. b := data[iNdEx]
  516. iNdEx++
  517. wire |= (uint64(b) & 0x7F) << shift
  518. if b < 0x80 {
  519. break
  520. }
  521. }
  522. wireType := int(wire & 0x7)
  523. switch wireType {
  524. case 0:
  525. for {
  526. if iNdEx >= l {
  527. return 0, io.ErrUnexpectedEOF
  528. }
  529. iNdEx++
  530. if data[iNdEx-1] < 0x80 {
  531. break
  532. }
  533. }
  534. return iNdEx, nil
  535. case 1:
  536. iNdEx += 8
  537. return iNdEx, nil
  538. case 2:
  539. var length int
  540. for shift := uint(0); ; shift += 7 {
  541. if iNdEx >= l {
  542. return 0, io.ErrUnexpectedEOF
  543. }
  544. b := data[iNdEx]
  545. iNdEx++
  546. length |= (int(b) & 0x7F) << shift
  547. if b < 0x80 {
  548. break
  549. }
  550. }
  551. iNdEx += length
  552. if length < 0 {
  553. return 0, ErrInvalidLengthKv
  554. }
  555. return iNdEx, nil
  556. case 3:
  557. for {
  558. var innerWire uint64
  559. var start int = iNdEx
  560. for shift := uint(0); ; shift += 7 {
  561. if iNdEx >= l {
  562. return 0, io.ErrUnexpectedEOF
  563. }
  564. b := data[iNdEx]
  565. iNdEx++
  566. innerWire |= (uint64(b) & 0x7F) << shift
  567. if b < 0x80 {
  568. break
  569. }
  570. }
  571. innerWireType := int(innerWire & 0x7)
  572. if innerWireType == 4 {
  573. break
  574. }
  575. next, err := skipKv(data[start:])
  576. if err != nil {
  577. return 0, err
  578. }
  579. iNdEx = start + next
  580. }
  581. return iNdEx, nil
  582. case 4:
  583. return iNdEx, nil
  584. case 5:
  585. iNdEx += 4
  586. return iNdEx, nil
  587. default:
  588. return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
  589. }
  590. }
  591. panic("unreachable")
  592. }
  593. var (
  594. ErrInvalidLengthKv = fmt.Errorf("proto: negative length found during unmarshaling")
  595. )