kv.pb.go 12 KB

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