kv.pb.go 14 KB

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