starpc 0.22.7 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/integration/integration.js +2 -2
- package/dist/srpc/client.js +2 -2
- package/dist/srpc/conn.d.ts +3 -4
- package/dist/srpc/conn.js +5 -1
- package/dist/srpc/index.d.ts +1 -1
- package/dist/srpc/index.js +1 -1
- package/dist/srpc/length-prefix.d.ts +0 -0
- package/dist/srpc/length-prefix.js +1 -0
- package/dist/srpc/message.js +5 -5
- package/dist/srpc/packet.d.ts +19 -4
- package/dist/srpc/packet.js +35 -7
- package/dist/srpc/websocket.d.ts +1 -1
- package/dist/srpc/websocket.js +4 -1
- package/e2e/mock/mock.pb.go +2 -2
- package/e2e/mock/mock_srpc.pb.go +1 -1
- package/e2e/mock/mock_vtproto.pb.go +12 -115
- package/echo/echo.pb.go +2 -2
- package/echo/echo_srpc.pb.go +1 -1
- package/echo/echo_vtproto.pb.go +12 -115
- package/go.mod +5 -3
- package/go.sum +15 -8
- package/integration/integration.bash +1 -1
- package/integration/integration.ts +3 -3
- package/package.json +6 -6
- package/srpc/client.ts +2 -2
- package/srpc/conn.ts +9 -3
- package/srpc/index.ts +7 -0
- package/srpc/length-prefix.ts +0 -0
- package/srpc/message.ts +4 -4
- package/srpc/packet.ts +56 -14
- package/srpc/rpcproto.pb.go +2 -2
- package/srpc/rpcproto_vtproto.pb.go +65 -172
- package/srpc/websocket.ts +9 -2
|
@@ -7,12 +7,12 @@ async function runRPC() {
|
|
|
7
7
|
const ws = new WebSocket(addr);
|
|
8
8
|
const channel = new WebSocketConn(ws, 'outbound');
|
|
9
9
|
const client = channel.buildClient();
|
|
10
|
-
console.log('Running RpcStream test via WebSocket..');
|
|
11
|
-
await runRpcStreamTest(client);
|
|
12
10
|
console.log('Running client test via WebSocket..');
|
|
13
11
|
await runClientTest(client);
|
|
14
12
|
console.log('Running abort controller test via WebSocket..');
|
|
15
13
|
await runAbortControllerTest(client);
|
|
14
|
+
console.log('Running RpcStream test via WebSocket..');
|
|
15
|
+
await runRpcStreamTest(client);
|
|
16
16
|
}
|
|
17
17
|
process.on('unhandledRejection', (ev) => {
|
|
18
18
|
console.error('Unhandled rejection', ev);
|
package/dist/srpc/client.js
CHANGED
|
@@ -44,7 +44,7 @@ export class Client {
|
|
|
44
44
|
.then(async (call) => {
|
|
45
45
|
return writeToPushable(call.rpcDataSource, serverData);
|
|
46
46
|
})
|
|
47
|
-
.catch(err => serverData.end(err));
|
|
47
|
+
.catch((err) => serverData.end(err));
|
|
48
48
|
return serverData;
|
|
49
49
|
}
|
|
50
50
|
// bidirectionalStreamingRequest starts a two-way streaming request.
|
|
@@ -63,7 +63,7 @@ export class Client {
|
|
|
63
63
|
serverData.end(err);
|
|
64
64
|
}
|
|
65
65
|
})
|
|
66
|
-
.catch(err => serverData.end(err));
|
|
66
|
+
.catch((err) => serverData.end(err));
|
|
67
67
|
return serverData;
|
|
68
68
|
}
|
|
69
69
|
// startRpc is a common utility function to begin a rpc call.
|
package/dist/srpc/conn.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { Direction, Stream } from '@libp2p/interface
|
|
2
|
-
import type { StreamMuxerFactory } from '@libp2p/interface/stream-muxer';
|
|
1
|
+
import type { Direction, Stream, StreamMuxerFactory } from '@libp2p/interface';
|
|
3
2
|
import type { Duplex, Source } from 'it-stream-types';
|
|
4
3
|
import { Uint8ArrayList } from 'uint8arraylist';
|
|
5
4
|
import type { OpenStreamFunc, Stream as SRPCStream } from './stream.js';
|
|
@@ -16,8 +15,8 @@ export declare class Conn implements Duplex<AsyncGenerator<Uint8Array | Uint8Arr
|
|
|
16
15
|
private muxer;
|
|
17
16
|
private server?;
|
|
18
17
|
constructor(server?: StreamHandler, connParams?: ConnParams);
|
|
19
|
-
get sink(): import("it-stream-types").Sink<
|
|
20
|
-
get source(): AsyncGenerator<Uint8Array, any, unknown>;
|
|
18
|
+
get sink(): import("it-stream-types").Sink<AsyncGenerator<Uint8Array | Uint8ArrayList, any, unknown>, unknown>;
|
|
19
|
+
get source(): AsyncGenerator<Uint8Array | Uint8ArrayList, any, unknown>;
|
|
21
20
|
get streams(): Stream[];
|
|
22
21
|
buildClient(): Client;
|
|
23
22
|
openStream(): Promise<SRPCStream>;
|
package/dist/srpc/conn.js
CHANGED
|
@@ -2,6 +2,7 @@ import { yamux } from '@chainsafe/libp2p-yamux';
|
|
|
2
2
|
import { pipe } from 'it-pipe';
|
|
3
3
|
import isPromise from 'is-promise';
|
|
4
4
|
import { pushable } from 'it-pushable';
|
|
5
|
+
import { defaultLogger } from '@libp2p/logger';
|
|
5
6
|
import { Client } from './client.js';
|
|
6
7
|
import { combineUint8ArrayListTransform } from './array-list.js';
|
|
7
8
|
import { parseLengthPrefixTransform, prependLengthPrefixTransform, } from './packet.js';
|
|
@@ -25,7 +26,10 @@ export class Conn {
|
|
|
25
26
|
if (server) {
|
|
26
27
|
this.server = server;
|
|
27
28
|
}
|
|
28
|
-
const muxerFactory = connParams?.muxerFactory ??
|
|
29
|
+
const muxerFactory = connParams?.muxerFactory ??
|
|
30
|
+
yamux({ enableKeepAlive: false })({
|
|
31
|
+
logger: defaultLogger(),
|
|
32
|
+
});
|
|
29
33
|
this.muxer = muxerFactory.createStreamMuxer({
|
|
30
34
|
onIncomingStream: this.handleIncomingStream.bind(this),
|
|
31
35
|
direction: connParams?.direction || 'outbound',
|
package/dist/srpc/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { Mux, StaticMux, createMux } from './mux.js';
|
|
|
11
11
|
export { BroadcastChannelDuplex, newBroadcastChannelDuplex, BroadcastChannelConn, } from './broadcast-channel.js';
|
|
12
12
|
export { MessagePortDuplex, newMessagePortDuplex, MessagePortConn, } from './message-port.js';
|
|
13
13
|
export { MessageDefinition, DecodeMessageTransform, buildDecodeMessageTransform, EncodeMessageTransform, buildEncodeMessageTransform, memoProto, memoProtoDecode, } from './message.js';
|
|
14
|
-
export { parseLengthPrefixTransform, prependLengthPrefixTransform, decodePacketSource, encodePacketSource, } from './packet.js';
|
|
14
|
+
export { parseLengthPrefixTransform, prependLengthPrefixTransform, decodePacketSource, encodePacketSource, uint32LEDecode, uint32LEEncode, decodeUint32Le, encodeUint32Le, lengthPrefixDecode, lengthPrefixEncode, prependPacketLen, } from './packet.js';
|
|
15
15
|
export { combineUint8ArrayListTransform } from './array-list.js';
|
|
16
16
|
export { ValueCtr } from './value-ctr.js';
|
|
17
17
|
export { OpenStreamCtr } from './open-stream-ctr.js';
|
package/dist/srpc/index.js
CHANGED
|
@@ -10,7 +10,7 @@ export { StaticMux, createMux } from './mux.js';
|
|
|
10
10
|
export { BroadcastChannelDuplex, newBroadcastChannelDuplex, BroadcastChannelConn, } from './broadcast-channel.js';
|
|
11
11
|
export { MessagePortDuplex, newMessagePortDuplex, MessagePortConn, } from './message-port.js';
|
|
12
12
|
export { buildDecodeMessageTransform, buildEncodeMessageTransform, memoProto, memoProtoDecode, } from './message.js';
|
|
13
|
-
export { parseLengthPrefixTransform, prependLengthPrefixTransform, decodePacketSource, encodePacketSource, } from './packet.js';
|
|
13
|
+
export { parseLengthPrefixTransform, prependLengthPrefixTransform, decodePacketSource, encodePacketSource, uint32LEDecode, uint32LEEncode, decodeUint32Le, encodeUint32Le, lengthPrefixDecode, lengthPrefixEncode, prependPacketLen, } from './packet.js';
|
|
14
14
|
export { combineUint8ArrayListTransform } from './array-list.js';
|
|
15
15
|
export { ValueCtr } from './value-ctr.js';
|
|
16
16
|
export { OpenStreamCtr } from './open-stream-ctr.js';
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/dist/srpc/message.js
CHANGED
|
@@ -15,7 +15,7 @@ export function memoProtoDecode(def) {
|
|
|
15
15
|
//
|
|
16
16
|
// set memoize if you expect to repeatedly see the same message.
|
|
17
17
|
export function buildDecodeMessageTransform(def, memoize) {
|
|
18
|
-
const decode = memoize ?
|
|
18
|
+
const decode = !memoize ? def.decode.bind(def) : memoProtoDecode(def);
|
|
19
19
|
// decodeMessageSource unmarshals and async yields encoded Messages.
|
|
20
20
|
return async function* decodeMessageSource(source) {
|
|
21
21
|
for await (const pkt of source) {
|
|
@@ -33,11 +33,11 @@ export function buildDecodeMessageTransform(def, memoize) {
|
|
|
33
33
|
// buildEncodeMessageTransform builds a source of decoded messages.
|
|
34
34
|
// set memoize if you expect to repeatedly encode the same message.
|
|
35
35
|
export function buildEncodeMessageTransform(def, memoize) {
|
|
36
|
-
const encode = memoize
|
|
37
|
-
?
|
|
38
|
-
: (msg) => {
|
|
36
|
+
const encode = !memoize
|
|
37
|
+
? (msg) => {
|
|
39
38
|
return def.encode(msg).finish();
|
|
40
|
-
}
|
|
39
|
+
}
|
|
40
|
+
: memoProto(def);
|
|
41
41
|
// encodeMessageSource encodes messages to byte arrays.
|
|
42
42
|
return async function* encodeMessageSource(source) {
|
|
43
43
|
for await (const pkt of source) {
|
package/dist/srpc/packet.d.ts
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
import { Uint8ArrayList } from 'uint8arraylist';
|
|
2
|
-
import { Packet } from './rpcproto.pb.js';
|
|
3
2
|
import { Source, Transform } from 'it-stream-types';
|
|
3
|
+
import { Packet } from './rpcproto.pb.js';
|
|
4
4
|
export declare const decodePacketSource: import("./message.js").DecodeMessageTransform<Packet>;
|
|
5
5
|
export declare const encodePacketSource: import("./message.js").EncodeMessageTransform<Packet>;
|
|
6
|
-
export declare
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export declare const uint32LEDecode: {
|
|
7
|
+
(data: Uint8ArrayList): number;
|
|
8
|
+
bytes: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const uint32LEEncode: {
|
|
11
|
+
(value: number): Uint8ArrayList;
|
|
12
|
+
bytes: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function lengthPrefixEncode(source: Source<Uint8Array | Uint8ArrayList>, lengthEncoder: typeof uint32LEEncode): AsyncGenerator<Uint8ArrayList, void, unknown>;
|
|
15
|
+
export declare function lengthPrefixDecode(source: Source<Uint8Array | Uint8ArrayList>, lengthDecoder: typeof uint32LEDecode): AsyncGenerator<Uint8ArrayList, void, unknown>;
|
|
16
|
+
export declare function prependLengthPrefixTransform(lengthEncoder?: {
|
|
17
|
+
(value: number): Uint8ArrayList;
|
|
18
|
+
bytes: number;
|
|
19
|
+
}): Transform<Source<Uint8Array | Uint8ArrayList>, AsyncGenerator<Uint8ArrayList, void, undefined> | Generator<Uint8ArrayList, void, undefined>>;
|
|
20
|
+
export declare function parseLengthPrefixTransform(lengthDecoder?: {
|
|
21
|
+
(data: Uint8ArrayList): number;
|
|
22
|
+
bytes: number;
|
|
23
|
+
}): Transform<Source<Uint8Array | Uint8ArrayList>, AsyncGenerator<Uint8ArrayList, void, unknown> | Generator<Uint8ArrayList, void, unknown>>;
|
|
9
24
|
export declare function encodeUint32Le(value: number): Uint8Array;
|
|
10
25
|
export declare function decodeUint32Le(data: Uint8Array): number;
|
|
11
26
|
export declare function prependPacketLen(msgData: Uint8Array): Uint8Array;
|
package/dist/srpc/packet.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { encode as lengthPrefixEncode, decode as lengthPrefixDecode, } from 'it-length-prefixed';
|
|
2
1
|
import { Uint8ArrayList } from 'uint8arraylist';
|
|
3
2
|
import { Packet } from './rpcproto.pb.js';
|
|
4
3
|
import { buildDecodeMessageTransform, buildEncodeMessageTransform, } from './message.js';
|
|
@@ -7,7 +6,7 @@ export const decodePacketSource = buildDecodeMessageTransform(Packet);
|
|
|
7
6
|
// encodePacketSource encodes packets from a packet object stream.
|
|
8
7
|
export const encodePacketSource = buildEncodeMessageTransform(Packet);
|
|
9
8
|
// uint32LEDecode removes the length prefix.
|
|
10
|
-
const uint32LEDecode = (data) => {
|
|
9
|
+
export const uint32LEDecode = (data) => {
|
|
11
10
|
if (data.length < 4) {
|
|
12
11
|
throw RangeError('Could not decode int32BE');
|
|
13
12
|
}
|
|
@@ -15,24 +14,53 @@ const uint32LEDecode = (data) => {
|
|
|
15
14
|
};
|
|
16
15
|
uint32LEDecode.bytes = 4;
|
|
17
16
|
// uint32LEEncode adds the length prefix.
|
|
18
|
-
const uint32LEEncode = (value) => {
|
|
17
|
+
export const uint32LEEncode = (value) => {
|
|
19
18
|
const data = new Uint8ArrayList(new Uint8Array(4));
|
|
20
19
|
data.setUint32(0, value, true);
|
|
21
20
|
return data;
|
|
22
21
|
};
|
|
23
22
|
uint32LEEncode.bytes = 4;
|
|
23
|
+
// lengthPrefixEncode transforms a source to a length-prefixed Uint8ArrayList stream.
|
|
24
|
+
export async function* lengthPrefixEncode(source, lengthEncoder) {
|
|
25
|
+
for await (const chunk of source) {
|
|
26
|
+
// Encode the length of the chunk.
|
|
27
|
+
const length = chunk instanceof Uint8Array ? chunk.length : chunk.byteLength;
|
|
28
|
+
const lengthEncoded = lengthEncoder(length);
|
|
29
|
+
// Concatenate the length prefix and the data.
|
|
30
|
+
yield new Uint8ArrayList(lengthEncoded, chunk);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// lengthPrefixDecode decodes a length-prefixed source to a Uint8ArrayList stream.
|
|
34
|
+
export async function* lengthPrefixDecode(source, lengthDecoder) {
|
|
35
|
+
const buffer = new Uint8ArrayList();
|
|
36
|
+
for await (const chunk of source) {
|
|
37
|
+
buffer.append(chunk);
|
|
38
|
+
// Continue extracting messages while buffer contains enough data for decoding.
|
|
39
|
+
while (buffer.length >= lengthDecoder.bytes) {
|
|
40
|
+
const messageLength = lengthDecoder(buffer);
|
|
41
|
+
const totalLength = lengthDecoder.bytes + messageLength;
|
|
42
|
+
if (buffer.length < totalLength)
|
|
43
|
+
break; // Wait for more data if the full message hasn't arrived.
|
|
44
|
+
// Extract the message excluding the length prefix.
|
|
45
|
+
const message = buffer.sublist(lengthDecoder.bytes, totalLength);
|
|
46
|
+
yield message;
|
|
47
|
+
// Remove the processed message from the buffer.
|
|
48
|
+
buffer.consume(totalLength);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
24
52
|
// prependLengthPrefixTransform adds a length prefix to a message source.
|
|
25
53
|
// little-endian uint32
|
|
26
|
-
export function prependLengthPrefixTransform() {
|
|
54
|
+
export function prependLengthPrefixTransform(lengthEncoder = uint32LEEncode) {
|
|
27
55
|
return (source) => {
|
|
28
|
-
return lengthPrefixEncode(source,
|
|
56
|
+
return lengthPrefixEncode(source, lengthEncoder);
|
|
29
57
|
};
|
|
30
58
|
}
|
|
31
59
|
// parseLengthPrefixTransform parses the length prefix from a message source.
|
|
32
60
|
// little-endian uint32
|
|
33
|
-
export function parseLengthPrefixTransform() {
|
|
61
|
+
export function parseLengthPrefixTransform(lengthDecoder = uint32LEDecode) {
|
|
34
62
|
return (source) => {
|
|
35
|
-
return lengthPrefixDecode(source,
|
|
63
|
+
return lengthPrefixDecode(source, lengthDecoder);
|
|
36
64
|
};
|
|
37
65
|
}
|
|
38
66
|
// encodeUint32Le encodes the number as a uint32 with little endian.
|
package/dist/srpc/websocket.d.ts
CHANGED
package/dist/srpc/websocket.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { pipe } from 'it-pipe';
|
|
2
2
|
import duplex from '@aptre/it-ws/duplex';
|
|
3
3
|
import { Conn } from './conn.js';
|
|
4
|
+
import { combineUint8ArrayListTransform } from './array-list.js';
|
|
4
5
|
// WebSocketConn implements a connection with a WebSocket and optional Server.
|
|
5
6
|
export class WebSocketConn extends Conn {
|
|
6
7
|
constructor(socket, direction, server) {
|
|
7
8
|
super(server, { direction });
|
|
8
9
|
this.socket = socket;
|
|
9
10
|
const socketDuplex = duplex(socket);
|
|
10
|
-
pipe(socketDuplex, this,
|
|
11
|
+
pipe(socketDuplex, this,
|
|
12
|
+
// it-ws only supports sending Uint8Array.
|
|
13
|
+
combineUint8ArrayListTransform(), socketDuplex);
|
|
11
14
|
}
|
|
12
15
|
// getSocket returns the websocket.
|
|
13
16
|
getSocket() {
|
package/e2e/mock/mock.pb.go
CHANGED
package/e2e/mock/mock_srpc.pb.go
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Code generated by protoc-gen-go-vtproto. DO NOT EDIT.
|
|
2
|
-
// protoc-gen-go-vtproto version: v0.
|
|
2
|
+
// protoc-gen-go-vtproto version: v0.6.0
|
|
3
3
|
// source: github.com/aperturerobotics/starpc/e2e/mock/mock.proto
|
|
4
4
|
|
|
5
5
|
package e2e_mock
|
|
@@ -7,8 +7,8 @@ package e2e_mock
|
|
|
7
7
|
import (
|
|
8
8
|
fmt "fmt"
|
|
9
9
|
io "io"
|
|
10
|
-
bits "math/bits"
|
|
11
10
|
|
|
11
|
+
protohelpers "github.com/planetscale/vtprotobuf/protohelpers"
|
|
12
12
|
proto "google.golang.org/protobuf/proto"
|
|
13
13
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
14
14
|
)
|
|
@@ -24,9 +24,8 @@ func (m *MockMsg) CloneVT() *MockMsg {
|
|
|
24
24
|
if m == nil {
|
|
25
25
|
return (*MockMsg)(nil)
|
|
26
26
|
}
|
|
27
|
-
r :=
|
|
28
|
-
|
|
29
|
-
}
|
|
27
|
+
r := new(MockMsg)
|
|
28
|
+
r.Body = m.Body
|
|
30
29
|
if len(m.unknownFields) > 0 {
|
|
31
30
|
r.unknownFields = make([]byte, len(m.unknownFields))
|
|
32
31
|
copy(r.unknownFields, m.unknownFields)
|
|
@@ -90,24 +89,13 @@ func (m *MockMsg) MarshalToSizedBufferVT(dAtA []byte) (int, error) {
|
|
|
90
89
|
if len(m.Body) > 0 {
|
|
91
90
|
i -= len(m.Body)
|
|
92
91
|
copy(dAtA[i:], m.Body)
|
|
93
|
-
i =
|
|
92
|
+
i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Body)))
|
|
94
93
|
i--
|
|
95
94
|
dAtA[i] = 0xa
|
|
96
95
|
}
|
|
97
96
|
return len(dAtA) - i, nil
|
|
98
97
|
}
|
|
99
98
|
|
|
100
|
-
func encodeVarint(dAtA []byte, offset int, v uint64) int {
|
|
101
|
-
offset -= sov(v)
|
|
102
|
-
base := offset
|
|
103
|
-
for v >= 1<<7 {
|
|
104
|
-
dAtA[offset] = uint8(v&0x7f | 0x80)
|
|
105
|
-
v >>= 7
|
|
106
|
-
offset++
|
|
107
|
-
}
|
|
108
|
-
dAtA[offset] = uint8(v)
|
|
109
|
-
return base
|
|
110
|
-
}
|
|
111
99
|
func (m *MockMsg) SizeVT() (n int) {
|
|
112
100
|
if m == nil {
|
|
113
101
|
return 0
|
|
@@ -116,18 +104,12 @@ func (m *MockMsg) SizeVT() (n int) {
|
|
|
116
104
|
_ = l
|
|
117
105
|
l = len(m.Body)
|
|
118
106
|
if l > 0 {
|
|
119
|
-
n += 1 + l +
|
|
107
|
+
n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
|
|
120
108
|
}
|
|
121
109
|
n += len(m.unknownFields)
|
|
122
110
|
return n
|
|
123
111
|
}
|
|
124
112
|
|
|
125
|
-
func sov(x uint64) (n int) {
|
|
126
|
-
return (bits.Len64(x|1) + 6) / 7
|
|
127
|
-
}
|
|
128
|
-
func soz(x uint64) (n int) {
|
|
129
|
-
return sov(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
|
130
|
-
}
|
|
131
113
|
func (m *MockMsg) UnmarshalVT(dAtA []byte) error {
|
|
132
114
|
l := len(dAtA)
|
|
133
115
|
iNdEx := 0
|
|
@@ -136,7 +118,7 @@ func (m *MockMsg) UnmarshalVT(dAtA []byte) error {
|
|
|
136
118
|
var wire uint64
|
|
137
119
|
for shift := uint(0); ; shift += 7 {
|
|
138
120
|
if shift >= 64 {
|
|
139
|
-
return ErrIntOverflow
|
|
121
|
+
return protohelpers.ErrIntOverflow
|
|
140
122
|
}
|
|
141
123
|
if iNdEx >= l {
|
|
142
124
|
return io.ErrUnexpectedEOF
|
|
@@ -164,7 +146,7 @@ func (m *MockMsg) UnmarshalVT(dAtA []byte) error {
|
|
|
164
146
|
var stringLen uint64
|
|
165
147
|
for shift := uint(0); ; shift += 7 {
|
|
166
148
|
if shift >= 64 {
|
|
167
|
-
return ErrIntOverflow
|
|
149
|
+
return protohelpers.ErrIntOverflow
|
|
168
150
|
}
|
|
169
151
|
if iNdEx >= l {
|
|
170
152
|
return io.ErrUnexpectedEOF
|
|
@@ -178,11 +160,11 @@ func (m *MockMsg) UnmarshalVT(dAtA []byte) error {
|
|
|
178
160
|
}
|
|
179
161
|
intStringLen := int(stringLen)
|
|
180
162
|
if intStringLen < 0 {
|
|
181
|
-
return ErrInvalidLength
|
|
163
|
+
return protohelpers.ErrInvalidLength
|
|
182
164
|
}
|
|
183
165
|
postIndex := iNdEx + intStringLen
|
|
184
166
|
if postIndex < 0 {
|
|
185
|
-
return ErrInvalidLength
|
|
167
|
+
return protohelpers.ErrInvalidLength
|
|
186
168
|
}
|
|
187
169
|
if postIndex > l {
|
|
188
170
|
return io.ErrUnexpectedEOF
|
|
@@ -191,12 +173,12 @@ func (m *MockMsg) UnmarshalVT(dAtA []byte) error {
|
|
|
191
173
|
iNdEx = postIndex
|
|
192
174
|
default:
|
|
193
175
|
iNdEx = preIndex
|
|
194
|
-
skippy, err :=
|
|
176
|
+
skippy, err := protohelpers.Skip(dAtA[iNdEx:])
|
|
195
177
|
if err != nil {
|
|
196
178
|
return err
|
|
197
179
|
}
|
|
198
180
|
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
|
199
|
-
return ErrInvalidLength
|
|
181
|
+
return protohelpers.ErrInvalidLength
|
|
200
182
|
}
|
|
201
183
|
if (iNdEx + skippy) > l {
|
|
202
184
|
return io.ErrUnexpectedEOF
|
|
@@ -211,88 +193,3 @@ func (m *MockMsg) UnmarshalVT(dAtA []byte) error {
|
|
|
211
193
|
}
|
|
212
194
|
return nil
|
|
213
195
|
}
|
|
214
|
-
|
|
215
|
-
func skip(dAtA []byte) (n int, err error) {
|
|
216
|
-
l := len(dAtA)
|
|
217
|
-
iNdEx := 0
|
|
218
|
-
depth := 0
|
|
219
|
-
for iNdEx < l {
|
|
220
|
-
var wire uint64
|
|
221
|
-
for shift := uint(0); ; shift += 7 {
|
|
222
|
-
if shift >= 64 {
|
|
223
|
-
return 0, ErrIntOverflow
|
|
224
|
-
}
|
|
225
|
-
if iNdEx >= l {
|
|
226
|
-
return 0, io.ErrUnexpectedEOF
|
|
227
|
-
}
|
|
228
|
-
b := dAtA[iNdEx]
|
|
229
|
-
iNdEx++
|
|
230
|
-
wire |= (uint64(b) & 0x7F) << shift
|
|
231
|
-
if b < 0x80 {
|
|
232
|
-
break
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
wireType := int(wire & 0x7)
|
|
236
|
-
switch wireType {
|
|
237
|
-
case 0:
|
|
238
|
-
for shift := uint(0); ; shift += 7 {
|
|
239
|
-
if shift >= 64 {
|
|
240
|
-
return 0, ErrIntOverflow
|
|
241
|
-
}
|
|
242
|
-
if iNdEx >= l {
|
|
243
|
-
return 0, io.ErrUnexpectedEOF
|
|
244
|
-
}
|
|
245
|
-
iNdEx++
|
|
246
|
-
if dAtA[iNdEx-1] < 0x80 {
|
|
247
|
-
break
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
case 1:
|
|
251
|
-
iNdEx += 8
|
|
252
|
-
case 2:
|
|
253
|
-
var length int
|
|
254
|
-
for shift := uint(0); ; shift += 7 {
|
|
255
|
-
if shift >= 64 {
|
|
256
|
-
return 0, ErrIntOverflow
|
|
257
|
-
}
|
|
258
|
-
if iNdEx >= l {
|
|
259
|
-
return 0, io.ErrUnexpectedEOF
|
|
260
|
-
}
|
|
261
|
-
b := dAtA[iNdEx]
|
|
262
|
-
iNdEx++
|
|
263
|
-
length |= (int(b) & 0x7F) << shift
|
|
264
|
-
if b < 0x80 {
|
|
265
|
-
break
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
if length < 0 {
|
|
269
|
-
return 0, ErrInvalidLength
|
|
270
|
-
}
|
|
271
|
-
iNdEx += length
|
|
272
|
-
case 3:
|
|
273
|
-
depth++
|
|
274
|
-
case 4:
|
|
275
|
-
if depth == 0 {
|
|
276
|
-
return 0, ErrUnexpectedEndOfGroup
|
|
277
|
-
}
|
|
278
|
-
depth--
|
|
279
|
-
case 5:
|
|
280
|
-
iNdEx += 4
|
|
281
|
-
default:
|
|
282
|
-
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
|
283
|
-
}
|
|
284
|
-
if iNdEx < 0 {
|
|
285
|
-
return 0, ErrInvalidLength
|
|
286
|
-
}
|
|
287
|
-
if depth == 0 {
|
|
288
|
-
return iNdEx, nil
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
return 0, io.ErrUnexpectedEOF
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
var (
|
|
295
|
-
ErrInvalidLength = fmt.Errorf("proto: negative length found during unmarshaling")
|
|
296
|
-
ErrIntOverflow = fmt.Errorf("proto: integer overflow")
|
|
297
|
-
ErrUnexpectedEndOfGroup = fmt.Errorf("proto: unexpected end of group")
|
|
298
|
-
)
|
package/echo/echo.pb.go
CHANGED
package/echo/echo_srpc.pb.go
CHANGED