kv.pb.go 12 KB

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