kv.pb.go 12 KB

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