kv.pb.go 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  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 the current key-value
  63. // a delete/expire event contains the previous
  64. // key-value
  65. Kv *KeyValue `protobuf:"bytes,2,opt,name=kv" json:"kv,omitempty"`
  66. }
  67. func (m *Event) Reset() { *m = Event{} }
  68. func (m *Event) String() string { return proto.CompactTextString(m) }
  69. func (*Event) ProtoMessage() {}
  70. func init() {
  71. proto.RegisterType((*KeyValue)(nil), "storagepb.KeyValue")
  72. proto.RegisterType((*Event)(nil), "storagepb.Event")
  73. proto.RegisterEnum("storagepb.Event_EventType", Event_EventType_name, Event_EventType_value)
  74. }
  75. func (m *KeyValue) Marshal() (data []byte, err error) {
  76. size := m.Size()
  77. data = make([]byte, size)
  78. n, err := m.MarshalTo(data)
  79. if err != nil {
  80. return nil, err
  81. }
  82. return data[:n], nil
  83. }
  84. func (m *KeyValue) MarshalTo(data []byte) (int, error) {
  85. var i int
  86. _ = i
  87. var l int
  88. _ = l
  89. if m.Key != nil {
  90. if len(m.Key) > 0 {
  91. data[i] = 0xa
  92. i++
  93. i = encodeVarintKv(data, i, uint64(len(m.Key)))
  94. i += copy(data[i:], m.Key)
  95. }
  96. }
  97. if m.CreateRevision != 0 {
  98. data[i] = 0x10
  99. i++
  100. i = encodeVarintKv(data, i, uint64(m.CreateRevision))
  101. }
  102. if m.ModRevision != 0 {
  103. data[i] = 0x18
  104. i++
  105. i = encodeVarintKv(data, i, uint64(m.ModRevision))
  106. }
  107. if m.Version != 0 {
  108. data[i] = 0x20
  109. i++
  110. i = encodeVarintKv(data, i, uint64(m.Version))
  111. }
  112. if m.Value != nil {
  113. if len(m.Value) > 0 {
  114. data[i] = 0x2a
  115. i++
  116. i = encodeVarintKv(data, i, uint64(len(m.Value)))
  117. i += copy(data[i:], m.Value)
  118. }
  119. }
  120. if m.Lease != 0 {
  121. data[i] = 0x30
  122. i++
  123. i = encodeVarintKv(data, i, uint64(m.Lease))
  124. }
  125. return i, nil
  126. }
  127. func (m *Event) Marshal() (data []byte, err error) {
  128. size := m.Size()
  129. data = make([]byte, size)
  130. n, err := m.MarshalTo(data)
  131. if err != nil {
  132. return nil, err
  133. }
  134. return data[:n], nil
  135. }
  136. func (m *Event) MarshalTo(data []byte) (int, error) {
  137. var i int
  138. _ = i
  139. var l int
  140. _ = l
  141. if m.Type != 0 {
  142. data[i] = 0x8
  143. i++
  144. i = encodeVarintKv(data, i, uint64(m.Type))
  145. }
  146. if m.Kv != nil {
  147. data[i] = 0x12
  148. i++
  149. i = encodeVarintKv(data, i, uint64(m.Kv.Size()))
  150. n1, err := m.Kv.MarshalTo(data[i:])
  151. if err != nil {
  152. return 0, err
  153. }
  154. i += n1
  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. return n
  225. }
  226. func sovKv(x uint64) (n int) {
  227. for {
  228. n++
  229. x >>= 7
  230. if x == 0 {
  231. break
  232. }
  233. }
  234. return n
  235. }
  236. func sozKv(x uint64) (n int) {
  237. return sovKv(uint64((x << 1) ^ uint64((int64(x) >> 63))))
  238. }
  239. func (m *KeyValue) Unmarshal(data []byte) error {
  240. l := len(data)
  241. iNdEx := 0
  242. for iNdEx < l {
  243. preIndex := iNdEx
  244. var wire uint64
  245. for shift := uint(0); ; shift += 7 {
  246. if shift >= 64 {
  247. return ErrIntOverflowKv
  248. }
  249. if iNdEx >= l {
  250. return io.ErrUnexpectedEOF
  251. }
  252. b := data[iNdEx]
  253. iNdEx++
  254. wire |= (uint64(b) & 0x7F) << shift
  255. if b < 0x80 {
  256. break
  257. }
  258. }
  259. fieldNum := int32(wire >> 3)
  260. wireType := int(wire & 0x7)
  261. if wireType == 4 {
  262. return fmt.Errorf("proto: KeyValue: wiretype end group for non-group")
  263. }
  264. if fieldNum <= 0 {
  265. return fmt.Errorf("proto: KeyValue: illegal tag %d (wire type %d)", fieldNum, wire)
  266. }
  267. switch fieldNum {
  268. case 1:
  269. if wireType != 2 {
  270. return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
  271. }
  272. var byteLen int
  273. for shift := uint(0); ; shift += 7 {
  274. if shift >= 64 {
  275. return ErrIntOverflowKv
  276. }
  277. if iNdEx >= l {
  278. return io.ErrUnexpectedEOF
  279. }
  280. b := data[iNdEx]
  281. iNdEx++
  282. byteLen |= (int(b) & 0x7F) << shift
  283. if b < 0x80 {
  284. break
  285. }
  286. }
  287. if byteLen < 0 {
  288. return ErrInvalidLengthKv
  289. }
  290. postIndex := iNdEx + byteLen
  291. if postIndex > l {
  292. return io.ErrUnexpectedEOF
  293. }
  294. m.Key = append(m.Key[:0], data[iNdEx:postIndex]...)
  295. if m.Key == nil {
  296. m.Key = []byte{}
  297. }
  298. iNdEx = postIndex
  299. case 2:
  300. if wireType != 0 {
  301. return fmt.Errorf("proto: wrong wireType = %d for field CreateRevision", wireType)
  302. }
  303. m.CreateRevision = 0
  304. for shift := uint(0); ; shift += 7 {
  305. if shift >= 64 {
  306. return ErrIntOverflowKv
  307. }
  308. if iNdEx >= l {
  309. return io.ErrUnexpectedEOF
  310. }
  311. b := data[iNdEx]
  312. iNdEx++
  313. m.CreateRevision |= (int64(b) & 0x7F) << shift
  314. if b < 0x80 {
  315. break
  316. }
  317. }
  318. case 3:
  319. if wireType != 0 {
  320. return fmt.Errorf("proto: wrong wireType = %d for field ModRevision", wireType)
  321. }
  322. m.ModRevision = 0
  323. for shift := uint(0); ; shift += 7 {
  324. if shift >= 64 {
  325. return ErrIntOverflowKv
  326. }
  327. if iNdEx >= l {
  328. return io.ErrUnexpectedEOF
  329. }
  330. b := data[iNdEx]
  331. iNdEx++
  332. m.ModRevision |= (int64(b) & 0x7F) << shift
  333. if b < 0x80 {
  334. break
  335. }
  336. }
  337. case 4:
  338. if wireType != 0 {
  339. return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType)
  340. }
  341. m.Version = 0
  342. for shift := uint(0); ; shift += 7 {
  343. if shift >= 64 {
  344. return ErrIntOverflowKv
  345. }
  346. if iNdEx >= l {
  347. return io.ErrUnexpectedEOF
  348. }
  349. b := data[iNdEx]
  350. iNdEx++
  351. m.Version |= (int64(b) & 0x7F) << shift
  352. if b < 0x80 {
  353. break
  354. }
  355. }
  356. case 5:
  357. if wireType != 2 {
  358. return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType)
  359. }
  360. var byteLen int
  361. for shift := uint(0); ; shift += 7 {
  362. if shift >= 64 {
  363. return ErrIntOverflowKv
  364. }
  365. if iNdEx >= l {
  366. return io.ErrUnexpectedEOF
  367. }
  368. b := data[iNdEx]
  369. iNdEx++
  370. byteLen |= (int(b) & 0x7F) << shift
  371. if b < 0x80 {
  372. break
  373. }
  374. }
  375. if byteLen < 0 {
  376. return ErrInvalidLengthKv
  377. }
  378. postIndex := iNdEx + byteLen
  379. if postIndex > l {
  380. return io.ErrUnexpectedEOF
  381. }
  382. m.Value = append(m.Value[:0], data[iNdEx:postIndex]...)
  383. if m.Value == nil {
  384. m.Value = []byte{}
  385. }
  386. iNdEx = postIndex
  387. case 6:
  388. if wireType != 0 {
  389. return fmt.Errorf("proto: wrong wireType = %d for field Lease", wireType)
  390. }
  391. m.Lease = 0
  392. for shift := uint(0); ; shift += 7 {
  393. if shift >= 64 {
  394. return ErrIntOverflowKv
  395. }
  396. if iNdEx >= l {
  397. return io.ErrUnexpectedEOF
  398. }
  399. b := data[iNdEx]
  400. iNdEx++
  401. m.Lease |= (int64(b) & 0x7F) << shift
  402. if b < 0x80 {
  403. break
  404. }
  405. }
  406. default:
  407. iNdEx = preIndex
  408. skippy, err := skipKv(data[iNdEx:])
  409. if err != nil {
  410. return err
  411. }
  412. if skippy < 0 {
  413. return ErrInvalidLengthKv
  414. }
  415. if (iNdEx + skippy) > l {
  416. return io.ErrUnexpectedEOF
  417. }
  418. iNdEx += skippy
  419. }
  420. }
  421. if iNdEx > l {
  422. return io.ErrUnexpectedEOF
  423. }
  424. return nil
  425. }
  426. func (m *Event) Unmarshal(data []byte) error {
  427. l := len(data)
  428. iNdEx := 0
  429. for iNdEx < l {
  430. preIndex := iNdEx
  431. var wire uint64
  432. for shift := uint(0); ; shift += 7 {
  433. if shift >= 64 {
  434. return ErrIntOverflowKv
  435. }
  436. if iNdEx >= l {
  437. return io.ErrUnexpectedEOF
  438. }
  439. b := data[iNdEx]
  440. iNdEx++
  441. wire |= (uint64(b) & 0x7F) << shift
  442. if b < 0x80 {
  443. break
  444. }
  445. }
  446. fieldNum := int32(wire >> 3)
  447. wireType := int(wire & 0x7)
  448. if wireType == 4 {
  449. return fmt.Errorf("proto: Event: wiretype end group for non-group")
  450. }
  451. if fieldNum <= 0 {
  452. return fmt.Errorf("proto: Event: illegal tag %d (wire type %d)", fieldNum, wire)
  453. }
  454. switch fieldNum {
  455. case 1:
  456. if wireType != 0 {
  457. return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
  458. }
  459. m.Type = 0
  460. for shift := uint(0); ; shift += 7 {
  461. if shift >= 64 {
  462. return ErrIntOverflowKv
  463. }
  464. if iNdEx >= l {
  465. return io.ErrUnexpectedEOF
  466. }
  467. b := data[iNdEx]
  468. iNdEx++
  469. m.Type |= (Event_EventType(b) & 0x7F) << shift
  470. if b < 0x80 {
  471. break
  472. }
  473. }
  474. case 2:
  475. if wireType != 2 {
  476. return fmt.Errorf("proto: wrong wireType = %d for field Kv", wireType)
  477. }
  478. var msglen int
  479. for shift := uint(0); ; shift += 7 {
  480. if shift >= 64 {
  481. return ErrIntOverflowKv
  482. }
  483. if iNdEx >= l {
  484. return io.ErrUnexpectedEOF
  485. }
  486. b := data[iNdEx]
  487. iNdEx++
  488. msglen |= (int(b) & 0x7F) << shift
  489. if b < 0x80 {
  490. break
  491. }
  492. }
  493. if msglen < 0 {
  494. return ErrInvalidLengthKv
  495. }
  496. postIndex := iNdEx + msglen
  497. if postIndex > l {
  498. return io.ErrUnexpectedEOF
  499. }
  500. if m.Kv == nil {
  501. m.Kv = &KeyValue{}
  502. }
  503. if err := m.Kv.Unmarshal(data[iNdEx:postIndex]); err != nil {
  504. return err
  505. }
  506. iNdEx = postIndex
  507. default:
  508. iNdEx = preIndex
  509. skippy, err := skipKv(data[iNdEx:])
  510. if err != nil {
  511. return err
  512. }
  513. if skippy < 0 {
  514. return ErrInvalidLengthKv
  515. }
  516. if (iNdEx + skippy) > l {
  517. return io.ErrUnexpectedEOF
  518. }
  519. iNdEx += skippy
  520. }
  521. }
  522. if iNdEx > l {
  523. return io.ErrUnexpectedEOF
  524. }
  525. return nil
  526. }
  527. func skipKv(data []byte) (n int, err error) {
  528. l := len(data)
  529. iNdEx := 0
  530. for iNdEx < l {
  531. var wire uint64
  532. for shift := uint(0); ; shift += 7 {
  533. if shift >= 64 {
  534. return 0, ErrIntOverflowKv
  535. }
  536. if iNdEx >= l {
  537. return 0, io.ErrUnexpectedEOF
  538. }
  539. b := data[iNdEx]
  540. iNdEx++
  541. wire |= (uint64(b) & 0x7F) << shift
  542. if b < 0x80 {
  543. break
  544. }
  545. }
  546. wireType := int(wire & 0x7)
  547. switch wireType {
  548. case 0:
  549. for shift := uint(0); ; shift += 7 {
  550. if shift >= 64 {
  551. return 0, ErrIntOverflowKv
  552. }
  553. if iNdEx >= l {
  554. return 0, io.ErrUnexpectedEOF
  555. }
  556. iNdEx++
  557. if data[iNdEx-1] < 0x80 {
  558. break
  559. }
  560. }
  561. return iNdEx, nil
  562. case 1:
  563. iNdEx += 8
  564. return iNdEx, nil
  565. case 2:
  566. var length int
  567. for shift := uint(0); ; shift += 7 {
  568. if shift >= 64 {
  569. return 0, ErrIntOverflowKv
  570. }
  571. if iNdEx >= l {
  572. return 0, io.ErrUnexpectedEOF
  573. }
  574. b := data[iNdEx]
  575. iNdEx++
  576. length |= (int(b) & 0x7F) << shift
  577. if b < 0x80 {
  578. break
  579. }
  580. }
  581. iNdEx += length
  582. if length < 0 {
  583. return 0, ErrInvalidLengthKv
  584. }
  585. return iNdEx, nil
  586. case 3:
  587. for {
  588. var innerWire uint64
  589. var start int = iNdEx
  590. for shift := uint(0); ; shift += 7 {
  591. if shift >= 64 {
  592. return 0, ErrIntOverflowKv
  593. }
  594. if iNdEx >= l {
  595. return 0, io.ErrUnexpectedEOF
  596. }
  597. b := data[iNdEx]
  598. iNdEx++
  599. innerWire |= (uint64(b) & 0x7F) << shift
  600. if b < 0x80 {
  601. break
  602. }
  603. }
  604. innerWireType := int(innerWire & 0x7)
  605. if innerWireType == 4 {
  606. break
  607. }
  608. next, err := skipKv(data[start:])
  609. if err != nil {
  610. return 0, err
  611. }
  612. iNdEx = start + next
  613. }
  614. return iNdEx, nil
  615. case 4:
  616. return iNdEx, nil
  617. case 5:
  618. iNdEx += 4
  619. return iNdEx, nil
  620. default:
  621. return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
  622. }
  623. }
  624. panic("unreachable")
  625. }
  626. var (
  627. ErrInvalidLengthKv = fmt.Errorf("proto: negative length found during unmarshaling")
  628. ErrIntOverflowKv = fmt.Errorf("proto: integer overflow")
  629. )