kv.pb.go 14 KB

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