kv.pb.go 12 KB

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