kv.pb.go 14 KB

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