From e53754e5e86d20b991f18befb3fca5acebf46372 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Mon, 18 Oct 2021 00:20:58 +0800 Subject: [PATCH 01/13] feat(js-sdk): add Node.js SDK Client https://github.com/mosn/layotto/issues/258 --- .gitignore | 2 + sdk/js-sdk/.github/workflows/nodejs.yml | 46 + sdk/js-sdk/README.md | 56 + sdk/js-sdk/demo/helloworld.ts | 12 + sdk/js-sdk/demo/package.json | 12 + sdk/js-sdk/demo/state.js | 21 + sdk/js-sdk/demo/state.mjs | 21 + sdk/js-sdk/demo/state.ts | 24 + sdk/js-sdk/jest.config.js | 5 + sdk/js-sdk/package.json | 65 + sdk/js-sdk/proto/appcallback_grpc_pb.d.ts | 59 + sdk/js-sdk/proto/appcallback_grpc_pb.js | 85 + sdk/js-sdk/proto/appcallback_pb.d.ts | 128 + sdk/js-sdk/proto/appcallback_pb.js | 965 ++ sdk/js-sdk/proto/runtime_grpc_pb.d.ts | 382 + sdk/js-sdk/proto/runtime_grpc_pb.js | 644 ++ sdk/js-sdk/proto/runtime_pb.d.ts | 1283 +++ sdk/js-sdk/proto/runtime_pb.js | 10020 ++++++++++++++++++++ sdk/js-sdk/scripts/build-grpc.sh | 60 + sdk/js-sdk/src/API.ts | 8 + sdk/js-sdk/src/Client.ts | 31 + sdk/js-sdk/src/Hello.ts | 21 + sdk/js-sdk/src/State.ts | 123 + sdk/js-sdk/src/index.ts | 5 + sdk/js-sdk/test/unit/Client.test.ts | 17 + sdk/js-sdk/test/unit/State.test.ts | 51 + sdk/js-sdk/tsconfig.json | 11 + 27 files changed, 14157 insertions(+) create mode 100644 sdk/js-sdk/.github/workflows/nodejs.yml create mode 100644 sdk/js-sdk/README.md create mode 100644 sdk/js-sdk/demo/helloworld.ts create mode 100644 sdk/js-sdk/demo/package.json create mode 100644 sdk/js-sdk/demo/state.js create mode 100644 sdk/js-sdk/demo/state.mjs create mode 100644 sdk/js-sdk/demo/state.ts create mode 100644 sdk/js-sdk/jest.config.js create mode 100644 sdk/js-sdk/package.json create mode 100644 sdk/js-sdk/proto/appcallback_grpc_pb.d.ts create mode 100644 sdk/js-sdk/proto/appcallback_grpc_pb.js create mode 100644 sdk/js-sdk/proto/appcallback_pb.d.ts create mode 100644 sdk/js-sdk/proto/appcallback_pb.js create mode 100644 sdk/js-sdk/proto/runtime_grpc_pb.d.ts create mode 100644 sdk/js-sdk/proto/runtime_grpc_pb.js create mode 100644 sdk/js-sdk/proto/runtime_pb.d.ts create mode 100644 sdk/js-sdk/proto/runtime_pb.js create mode 100755 sdk/js-sdk/scripts/build-grpc.sh create mode 100644 sdk/js-sdk/src/API.ts create mode 100644 sdk/js-sdk/src/Client.ts create mode 100644 sdk/js-sdk/src/Hello.ts create mode 100644 sdk/js-sdk/src/State.ts create mode 100644 sdk/js-sdk/src/index.ts create mode 100644 sdk/js-sdk/test/unit/Client.test.ts create mode 100644 sdk/js-sdk/test/unit/State.test.ts create mode 100644 sdk/js-sdk/tsconfig.json diff --git a/.gitignore b/.gitignore index 3a9c3f9bec..e71b0c8753 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ logs/ /cover.out vendor/ demo/state/redis/client +sdk/js-sdk/node_modules +sdk/js-sdk/dist diff --git a/sdk/js-sdk/.github/workflows/nodejs.yml b/sdk/js-sdk/.github/workflows/nodejs.yml new file mode 100644 index 0000000000..734409e777 --- /dev/null +++ b/sdk/js-sdk/.github/workflows/nodejs.yml @@ -0,0 +1,46 @@ +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Node.js CI + +on: + push: + branches: + - main + - master + pull_request: + branches: + - main + - master + schedule: + - cron: '0 2 * * *' + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + node-version: [14, 16] + os: [ubuntu-latest, macos-latest] + + steps: + - name: Checkout Git Source + uses: actions/checkout@v2 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Install Dependencies + run: npm i -g npminstall && npminstall + + - name: Continuous Integration + run: npm run ci + + - name: Code Coverage + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/sdk/js-sdk/README.md b/sdk/js-sdk/README.md new file mode 100644 index 0000000000..e252191eab --- /dev/null +++ b/sdk/js-sdk/README.md @@ -0,0 +1,56 @@ +# Layotto Node.js SDK + +The Layotto Node.js SDK to build your application. + +## Usage + +### State + +`demo/state.ts` + +```ts +import { Client } from 'layotto'; + +const storeName = 'redis'; +const key = 'foo-js-sdk'; +const value = `bar, from js-sdk, ${Date()}`; + +await client.state.save(storeName, { key, value }); +console.log('saveState success, key: %j, value: %j', key, value); + +const resValue = await client.state.get(storeName, key); +console.log('getState success, key: %j, value: %j, toString: %j', key, resValue, Buffer.from(resValue).toString('utf8')); +``` + +## Development + +### Install dependencies + +```bash +npm install +``` + +### Generate gRPC files + +```bash +npm run build:grpc +``` + +### Run Tests + +run the unit tests in your local env: + +- Start Layotto first, see [How to run layotto](https://mosn.io/layotto/#/zh/start/state/start?id=%e7%ac%ac%e4%ba%8c%e6%ad%a5%ef%bc%9a%e8%bf%90%e8%a1%8clayotto) + +```bash +cd ${projectpath}/cmd/layotto +go build + +./layotto start -c ../../configs/config_state_redis.json +``` + +- Then, run unit tests script by npm + +```bash +npm run test:unit +``` diff --git a/sdk/js-sdk/demo/helloworld.ts b/sdk/js-sdk/demo/helloworld.ts new file mode 100644 index 0000000000..b4a7776496 --- /dev/null +++ b/sdk/js-sdk/demo/helloworld.ts @@ -0,0 +1,12 @@ +import { strict as assert } from 'assert'; +import { Client } from 'layotto'; + +const client = new Client(); +assert(client); + +async function main() { + const hello = await client.hello.sayHello('helloworld', 'js-sdk'); + console.log('%s', hello); +} + +main(); diff --git a/sdk/js-sdk/demo/package.json b/sdk/js-sdk/demo/package.json new file mode 100644 index 0000000000..09481ddaae --- /dev/null +++ b/sdk/js-sdk/demo/package.json @@ -0,0 +1,12 @@ +{ + "name": "layotto-demo", + "version": "0.0.0", + "description": "Layotto Node.js SDK Demo", + "private": true, + "scripts": { + "test:all": "npm run test:cjs && npm run test:esm && npm run test:ts", + "test:cjs": "node ./state.js", + "test:esm": "node ./state.mjs", + "test:ts": "ts-node ./state.ts" + } +} diff --git a/sdk/js-sdk/demo/state.js b/sdk/js-sdk/demo/state.js new file mode 100644 index 0000000000..5e0d5bbf7c --- /dev/null +++ b/sdk/js-sdk/demo/state.js @@ -0,0 +1,21 @@ +const { strict: assert } = require('assert'); +const { Client } = require('layotto'); + +const client = new Client(); +assert(client); + +async function main() { + const storeName = 'redis'; + const key = 'foo-js-sdk'; + const value = `bar, from js-sdk, ${Date()}`; + + await client.state.save(storeName, [ + { key, value }, + ]); + console.log('saveState success, key: %j, value: %j', key, value); + + const resValue = await client.state.get(storeName, key); + console.log('getState success, key: %j, value: %j, toString: %j', key, resValue, Buffer.from(resValue).toString('utf8')); +} + +main(); diff --git a/sdk/js-sdk/demo/state.mjs b/sdk/js-sdk/demo/state.mjs new file mode 100644 index 0000000000..d812be561d --- /dev/null +++ b/sdk/js-sdk/demo/state.mjs @@ -0,0 +1,21 @@ +import { strict as assert } from 'assert'; +import { Client } from 'layotto'; + +const client = new Client(); +assert(client); + +async function main() { + const storeName = 'redis'; + const key = 'foo-js-sdk'; + const value = `bar, from js-sdk, ${Date()}`; + + await client.state.save(storeName, [ + { key, value }, + ]); + console.log('saveState success, key: %j, value: %j', key, value); + + const resValue = await client.state.get(storeName, key); + console.log('getState success, key: %j, value: %j, toString: %j', key, resValue, Buffer.from(resValue).toString('utf8')); +} + +main(); diff --git a/sdk/js-sdk/demo/state.ts b/sdk/js-sdk/demo/state.ts new file mode 100644 index 0000000000..0aab508ccc --- /dev/null +++ b/sdk/js-sdk/demo/state.ts @@ -0,0 +1,24 @@ +import { strict as assert } from 'assert' +import { Client } from 'layotto'; + +const client = new Client(); +assert(client); + +async function main() { + const storeName = 'redis'; + const key = 'foo-js-sdk'; + const value = `bar, from js-sdk, ${Date()}`; + + await client.state.save(storeName, [ + { key, value }, + ]); + console.log('saveState success, key: %j, value: %j', key, value); + + await client.state.save(storeName, { key, value }); + console.log('saveState success, key: %j, value: %j', key, value); + + const resValue = await client.state.get(storeName, key); + console.log('getState success, key: %j, value: %j, toString: %j', key, resValue, Buffer.from(resValue).toString('utf8')); +} + +main(); diff --git a/sdk/js-sdk/jest.config.js b/sdk/js-sdk/jest.config.js new file mode 100644 index 0000000000..e86e13bab9 --- /dev/null +++ b/sdk/js-sdk/jest.config.js @@ -0,0 +1,5 @@ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'node', +}; diff --git a/sdk/js-sdk/package.json b/sdk/js-sdk/package.json new file mode 100644 index 0000000000..340d04b179 --- /dev/null +++ b/sdk/js-sdk/package.json @@ -0,0 +1,65 @@ +{ + "name": "layotto", + "version": "0.0.0", + "description": "Layotto Node.js SDK", + "main": "dist/index.js", + "files": [ + "dist", + "proto", + "package.json", + "README.md" + ], + "scripts": { + "ci": "npm run lint && npm run build && npm run test:unit && npm run test:demo", + "test": "jest --runInBand --detectOpenHandles", + "test:unit": "NODE_ENV=test npm run test 'test/unit/.*\\.test\\.ts'", + "test:demo": "cd demo && npm run test:all", + "lint": "tslint -p tsconfig.json", + "build:grpc": "scripts/build-grpc.sh", + "tsc:clean": "rm -rf dist", + "tsc:cjs": "tsc -p tsconfig.json", + "build": "npm run tsc:clean && npm run tsc:cjs", + "rename:cjs": "for f in cjs/*.js; do mv -- \"$f\" \"${f/.js/.cjs}\"; done", + "prepublishOnly": "npm run build" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/mosn/layotto.git" + }, + "keywords": [ + "layotto", + "mosn" + ], + "author": "fengmk2", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/mosn/layotto/issues" + }, + "homepage": "https://github.com/mosn/layotto#readme", + "devDependencies": { + "@eggjs/tsconfig": "^1.0.0", + "@types/jest": "^27.0.2", + "egg-ci": "^1.19.0", + "grpc-tools": "^1.11.2", + "grpc_tools_node_protoc_ts": "^5.3.2", + "jest": "^27.2.5", + "ts-jest": "^27.0.7", + "ts-node": "^10.3.0", + "tslint": "^6.1.3", + "typescript": "^4.4.4" + }, + "dependencies": { + "@grpc/grpc-js": "^1.4.1", + "google-protobuf": "^3.19.0-rc.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "ci": { + "version": "14, 16", + "type": "github", + "os": { + "github": "linux, macos" + } + } +} diff --git a/sdk/js-sdk/proto/appcallback_grpc_pb.d.ts b/sdk/js-sdk/proto/appcallback_grpc_pb.d.ts new file mode 100644 index 0000000000..5cb6357b5b --- /dev/null +++ b/sdk/js-sdk/proto/appcallback_grpc_pb.d.ts @@ -0,0 +1,59 @@ +// package: spec.proto.runtime.v1 +// file: appcallback.proto + +/* tslint:disable */ +/* eslint-disable */ + +import * as grpc from "@grpc/grpc-js"; +import * as appcallback_pb from "./appcallback_pb"; +import * as google_protobuf_empty_pb from "google-protobuf/google/protobuf/empty_pb"; + +interface IAppCallbackService extends grpc.ServiceDefinition { + listTopicSubscriptions: IAppCallbackService_IListTopicSubscriptions; + onTopicEvent: IAppCallbackService_IOnTopicEvent; +} + +interface IAppCallbackService_IListTopicSubscriptions extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.AppCallback/ListTopicSubscriptions"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface IAppCallbackService_IOnTopicEvent extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.AppCallback/OnTopicEvent"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} + +export const AppCallbackService: IAppCallbackService; + +export interface IAppCallbackServer extends grpc.UntypedServiceImplementation { + listTopicSubscriptions: grpc.handleUnaryCall; + onTopicEvent: grpc.handleUnaryCall; +} + +export interface IAppCallbackClient { + listTopicSubscriptions(request: google_protobuf_empty_pb.Empty, callback: (error: grpc.ServiceError | null, response: appcallback_pb.ListTopicSubscriptionsResponse) => void): grpc.ClientUnaryCall; + listTopicSubscriptions(request: google_protobuf_empty_pb.Empty, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: appcallback_pb.ListTopicSubscriptionsResponse) => void): grpc.ClientUnaryCall; + listTopicSubscriptions(request: google_protobuf_empty_pb.Empty, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: appcallback_pb.ListTopicSubscriptionsResponse) => void): grpc.ClientUnaryCall; + onTopicEvent(request: appcallback_pb.TopicEventRequest, callback: (error: grpc.ServiceError | null, response: appcallback_pb.TopicEventResponse) => void): grpc.ClientUnaryCall; + onTopicEvent(request: appcallback_pb.TopicEventRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: appcallback_pb.TopicEventResponse) => void): grpc.ClientUnaryCall; + onTopicEvent(request: appcallback_pb.TopicEventRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: appcallback_pb.TopicEventResponse) => void): grpc.ClientUnaryCall; +} + +export class AppCallbackClient extends grpc.Client implements IAppCallbackClient { + constructor(address: string, credentials: grpc.ChannelCredentials, options?: Partial); + public listTopicSubscriptions(request: google_protobuf_empty_pb.Empty, callback: (error: grpc.ServiceError | null, response: appcallback_pb.ListTopicSubscriptionsResponse) => void): grpc.ClientUnaryCall; + public listTopicSubscriptions(request: google_protobuf_empty_pb.Empty, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: appcallback_pb.ListTopicSubscriptionsResponse) => void): grpc.ClientUnaryCall; + public listTopicSubscriptions(request: google_protobuf_empty_pb.Empty, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: appcallback_pb.ListTopicSubscriptionsResponse) => void): grpc.ClientUnaryCall; + public onTopicEvent(request: appcallback_pb.TopicEventRequest, callback: (error: grpc.ServiceError | null, response: appcallback_pb.TopicEventResponse) => void): grpc.ClientUnaryCall; + public onTopicEvent(request: appcallback_pb.TopicEventRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: appcallback_pb.TopicEventResponse) => void): grpc.ClientUnaryCall; + public onTopicEvent(request: appcallback_pb.TopicEventRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: appcallback_pb.TopicEventResponse) => void): grpc.ClientUnaryCall; +} diff --git a/sdk/js-sdk/proto/appcallback_grpc_pb.js b/sdk/js-sdk/proto/appcallback_grpc_pb.js new file mode 100644 index 0000000000..044a4b54fb --- /dev/null +++ b/sdk/js-sdk/proto/appcallback_grpc_pb.js @@ -0,0 +1,85 @@ +// GENERATED CODE -- DO NOT EDIT! + +'use strict'; +var grpc = require('@grpc/grpc-js'); +var appcallback_pb = require('./appcallback_pb.js'); +var google_protobuf_empty_pb = require('google-protobuf/google/protobuf/empty_pb.js'); + +function serialize_google_protobuf_Empty(arg) { + if (!(arg instanceof google_protobuf_empty_pb.Empty)) { + throw new Error('Expected argument of type google.protobuf.Empty'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_google_protobuf_Empty(buffer_arg) { + return google_protobuf_empty_pb.Empty.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_ListTopicSubscriptionsResponse(arg) { + if (!(arg instanceof appcallback_pb.ListTopicSubscriptionsResponse)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.ListTopicSubscriptionsResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_ListTopicSubscriptionsResponse(buffer_arg) { + return appcallback_pb.ListTopicSubscriptionsResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_TopicEventRequest(arg) { + if (!(arg instanceof appcallback_pb.TopicEventRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.TopicEventRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_TopicEventRequest(buffer_arg) { + return appcallback_pb.TopicEventRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_TopicEventResponse(arg) { + if (!(arg instanceof appcallback_pb.TopicEventResponse)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.TopicEventResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_TopicEventResponse(buffer_arg) { + return appcallback_pb.TopicEventResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + + +// AppCallback V1 allows user application to interact with runtime. +// User application needs to implement AppCallback service if it needs to +// receive message from runtime. +var AppCallbackService = exports.AppCallbackService = { + // Lists all topics subscribed by this app. +listTopicSubscriptions: { + path: '/spec.proto.runtime.v1.AppCallback/ListTopicSubscriptions', + requestStream: false, + responseStream: false, + requestType: google_protobuf_empty_pb.Empty, + responseType: appcallback_pb.ListTopicSubscriptionsResponse, + requestSerialize: serialize_google_protobuf_Empty, + requestDeserialize: deserialize_google_protobuf_Empty, + responseSerialize: serialize_spec_proto_runtime_v1_ListTopicSubscriptionsResponse, + responseDeserialize: deserialize_spec_proto_runtime_v1_ListTopicSubscriptionsResponse, + }, + // Subscribes events from Pubsub +onTopicEvent: { + path: '/spec.proto.runtime.v1.AppCallback/OnTopicEvent', + requestStream: false, + responseStream: false, + requestType: appcallback_pb.TopicEventRequest, + responseType: appcallback_pb.TopicEventResponse, + requestSerialize: serialize_spec_proto_runtime_v1_TopicEventRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_TopicEventRequest, + responseSerialize: serialize_spec_proto_runtime_v1_TopicEventResponse, + responseDeserialize: deserialize_spec_proto_runtime_v1_TopicEventResponse, + }, +}; + +exports.AppCallbackClient = grpc.makeGenericClientConstructor(AppCallbackService); +// // Invokes service method with InvokeRequest. +// rpc OnInvoke (InvokeRequest) returns (InvokeResponse) {} diff --git a/sdk/js-sdk/proto/appcallback_pb.d.ts b/sdk/js-sdk/proto/appcallback_pb.d.ts new file mode 100644 index 0000000000..5807b6e124 --- /dev/null +++ b/sdk/js-sdk/proto/appcallback_pb.d.ts @@ -0,0 +1,128 @@ +// package: spec.proto.runtime.v1 +// file: appcallback.proto + +/* tslint:disable */ +/* eslint-disable */ + +import * as jspb from "google-protobuf"; +import * as google_protobuf_empty_pb from "google-protobuf/google/protobuf/empty_pb"; + +export class TopicEventRequest extends jspb.Message { + getId(): string; + setId(value: string): TopicEventRequest; + getSource(): string; + setSource(value: string): TopicEventRequest; + getType(): string; + setType(value: string): TopicEventRequest; + getSpecVersion(): string; + setSpecVersion(value: string): TopicEventRequest; + getDataContentType(): string; + setDataContentType(value: string): TopicEventRequest; + getData(): Uint8Array | string; + getData_asU8(): Uint8Array; + getData_asB64(): string; + setData(value: Uint8Array | string): TopicEventRequest; + getTopic(): string; + setTopic(value: string): TopicEventRequest; + getPubsubName(): string; + setPubsubName(value: string): TopicEventRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): TopicEventRequest.AsObject; + static toObject(includeInstance: boolean, msg: TopicEventRequest): TopicEventRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: TopicEventRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): TopicEventRequest; + static deserializeBinaryFromReader(message: TopicEventRequest, reader: jspb.BinaryReader): TopicEventRequest; +} + +export namespace TopicEventRequest { + export type AsObject = { + id: string, + source: string, + type: string, + specVersion: string, + dataContentType: string, + data: Uint8Array | string, + topic: string, + pubsubName: string, + } +} + +export class TopicEventResponse extends jspb.Message { + getStatus(): TopicEventResponse.TopicEventResponseStatus; + setStatus(value: TopicEventResponse.TopicEventResponseStatus): TopicEventResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): TopicEventResponse.AsObject; + static toObject(includeInstance: boolean, msg: TopicEventResponse): TopicEventResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: TopicEventResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): TopicEventResponse; + static deserializeBinaryFromReader(message: TopicEventResponse, reader: jspb.BinaryReader): TopicEventResponse; +} + +export namespace TopicEventResponse { + export type AsObject = { + status: TopicEventResponse.TopicEventResponseStatus, + } + + export enum TopicEventResponseStatus { + SUCCESS = 0, + RETRY = 1, + DROP = 2, + } + +} + +export class ListTopicSubscriptionsResponse extends jspb.Message { + clearSubscriptionsList(): void; + getSubscriptionsList(): Array; + setSubscriptionsList(value: Array): ListTopicSubscriptionsResponse; + addSubscriptions(value?: TopicSubscription, index?: number): TopicSubscription; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ListTopicSubscriptionsResponse.AsObject; + static toObject(includeInstance: boolean, msg: ListTopicSubscriptionsResponse): ListTopicSubscriptionsResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: ListTopicSubscriptionsResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ListTopicSubscriptionsResponse; + static deserializeBinaryFromReader(message: ListTopicSubscriptionsResponse, reader: jspb.BinaryReader): ListTopicSubscriptionsResponse; +} + +export namespace ListTopicSubscriptionsResponse { + export type AsObject = { + subscriptionsList: Array, + } +} + +export class TopicSubscription extends jspb.Message { + getPubsubName(): string; + setPubsubName(value: string): TopicSubscription; + getTopic(): string; + setTopic(value: string): TopicSubscription; + + getMetadataMap(): jspb.Map; + clearMetadataMap(): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): TopicSubscription.AsObject; + static toObject(includeInstance: boolean, msg: TopicSubscription): TopicSubscription.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: TopicSubscription, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): TopicSubscription; + static deserializeBinaryFromReader(message: TopicSubscription, reader: jspb.BinaryReader): TopicSubscription; +} + +export namespace TopicSubscription { + export type AsObject = { + pubsubName: string, + topic: string, + + metadataMap: Array<[string, string]>, + } +} diff --git a/sdk/js-sdk/proto/appcallback_pb.js b/sdk/js-sdk/proto/appcallback_pb.js new file mode 100644 index 0000000000..021406fecc --- /dev/null +++ b/sdk/js-sdk/proto/appcallback_pb.js @@ -0,0 +1,965 @@ +// source: appcallback.proto +/** + * @fileoverview + * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = Function('return this')(); + +var google_protobuf_empty_pb = require('google-protobuf/google/protobuf/empty_pb.js'); +goog.object.extend(proto, google_protobuf_empty_pb); +goog.exportSymbol('proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.TopicEventRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.TopicEventResponse', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.TopicEventResponse.TopicEventResponseStatus', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.TopicSubscription', null, global); +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.TopicEventRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.TopicEventRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.TopicEventRequest.displayName = 'proto.spec.proto.runtime.v1.TopicEventRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.TopicEventResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.TopicEventResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.TopicEventResponse.displayName = 'proto.spec.proto.runtime.v1.TopicEventResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse.repeatedFields_, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse.displayName = 'proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.TopicSubscription = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.TopicSubscription, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.TopicSubscription.displayName = 'proto.spec.proto.runtime.v1.TopicSubscription'; +} + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.TopicEventRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.TopicEventRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.TopicEventRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.TopicEventRequest.toObject = function(includeInstance, msg) { + var f, obj = { + id: jspb.Message.getFieldWithDefault(msg, 1, ""), + source: jspb.Message.getFieldWithDefault(msg, 2, ""), + type: jspb.Message.getFieldWithDefault(msg, 3, ""), + specVersion: jspb.Message.getFieldWithDefault(msg, 4, ""), + dataContentType: jspb.Message.getFieldWithDefault(msg, 5, ""), + data: msg.getData_asB64(), + topic: jspb.Message.getFieldWithDefault(msg, 6, ""), + pubsubName: jspb.Message.getFieldWithDefault(msg, 8, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.TopicEventRequest} + */ +proto.spec.proto.runtime.v1.TopicEventRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.TopicEventRequest; + return proto.spec.proto.runtime.v1.TopicEventRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.TopicEventRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.TopicEventRequest} + */ +proto.spec.proto.runtime.v1.TopicEventRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setId(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setSource(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setType(value); + break; + case 4: + var value = /** @type {string} */ (reader.readString()); + msg.setSpecVersion(value); + break; + case 5: + var value = /** @type {string} */ (reader.readString()); + msg.setDataContentType(value); + break; + case 7: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setData(value); + break; + case 6: + var value = /** @type {string} */ (reader.readString()); + msg.setTopic(value); + break; + case 8: + var value = /** @type {string} */ (reader.readString()); + msg.setPubsubName(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.TopicEventRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.TopicEventRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.TopicEventRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.TopicEventRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getId(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getSource(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getType(); + if (f.length > 0) { + writer.writeString( + 3, + f + ); + } + f = message.getSpecVersion(); + if (f.length > 0) { + writer.writeString( + 4, + f + ); + } + f = message.getDataContentType(); + if (f.length > 0) { + writer.writeString( + 5, + f + ); + } + f = message.getData_asU8(); + if (f.length > 0) { + writer.writeBytes( + 7, + f + ); + } + f = message.getTopic(); + if (f.length > 0) { + writer.writeString( + 6, + f + ); + } + f = message.getPubsubName(); + if (f.length > 0) { + writer.writeString( + 8, + f + ); + } +}; + + +/** + * optional string id = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.TopicEventRequest.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.TopicEventRequest} returns this + */ +proto.spec.proto.runtime.v1.TopicEventRequest.prototype.setId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string source = 2; + * @return {string} + */ +proto.spec.proto.runtime.v1.TopicEventRequest.prototype.getSource = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.TopicEventRequest} returns this + */ +proto.spec.proto.runtime.v1.TopicEventRequest.prototype.setSource = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional string type = 3; + * @return {string} + */ +proto.spec.proto.runtime.v1.TopicEventRequest.prototype.getType = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.TopicEventRequest} returns this + */ +proto.spec.proto.runtime.v1.TopicEventRequest.prototype.setType = function(value) { + return jspb.Message.setProto3StringField(this, 3, value); +}; + + +/** + * optional string spec_version = 4; + * @return {string} + */ +proto.spec.proto.runtime.v1.TopicEventRequest.prototype.getSpecVersion = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.TopicEventRequest} returns this + */ +proto.spec.proto.runtime.v1.TopicEventRequest.prototype.setSpecVersion = function(value) { + return jspb.Message.setProto3StringField(this, 4, value); +}; + + +/** + * optional string data_content_type = 5; + * @return {string} + */ +proto.spec.proto.runtime.v1.TopicEventRequest.prototype.getDataContentType = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.TopicEventRequest} returns this + */ +proto.spec.proto.runtime.v1.TopicEventRequest.prototype.setDataContentType = function(value) { + return jspb.Message.setProto3StringField(this, 5, value); +}; + + +/** + * optional bytes data = 7; + * @return {!(string|Uint8Array)} + */ +proto.spec.proto.runtime.v1.TopicEventRequest.prototype.getData = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 7, "")); +}; + + +/** + * optional bytes data = 7; + * This is a type-conversion wrapper around `getData()` + * @return {string} + */ +proto.spec.proto.runtime.v1.TopicEventRequest.prototype.getData_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getData())); +}; + + +/** + * optional bytes data = 7; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getData()` + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.TopicEventRequest.prototype.getData_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getData())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.spec.proto.runtime.v1.TopicEventRequest} returns this + */ +proto.spec.proto.runtime.v1.TopicEventRequest.prototype.setData = function(value) { + return jspb.Message.setProto3BytesField(this, 7, value); +}; + + +/** + * optional string topic = 6; + * @return {string} + */ +proto.spec.proto.runtime.v1.TopicEventRequest.prototype.getTopic = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.TopicEventRequest} returns this + */ +proto.spec.proto.runtime.v1.TopicEventRequest.prototype.setTopic = function(value) { + return jspb.Message.setProto3StringField(this, 6, value); +}; + + +/** + * optional string pubsub_name = 8; + * @return {string} + */ +proto.spec.proto.runtime.v1.TopicEventRequest.prototype.getPubsubName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 8, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.TopicEventRequest} returns this + */ +proto.spec.proto.runtime.v1.TopicEventRequest.prototype.setPubsubName = function(value) { + return jspb.Message.setProto3StringField(this, 8, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.TopicEventResponse.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.TopicEventResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.TopicEventResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.TopicEventResponse.toObject = function(includeInstance, msg) { + var f, obj = { + status: jspb.Message.getFieldWithDefault(msg, 1, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.TopicEventResponse} + */ +proto.spec.proto.runtime.v1.TopicEventResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.TopicEventResponse; + return proto.spec.proto.runtime.v1.TopicEventResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.TopicEventResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.TopicEventResponse} + */ +proto.spec.proto.runtime.v1.TopicEventResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!proto.spec.proto.runtime.v1.TopicEventResponse.TopicEventResponseStatus} */ (reader.readEnum()); + msg.setStatus(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.TopicEventResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.TopicEventResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.TopicEventResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.TopicEventResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStatus(); + if (f !== 0.0) { + writer.writeEnum( + 1, + f + ); + } +}; + + +/** + * @enum {number} + */ +proto.spec.proto.runtime.v1.TopicEventResponse.TopicEventResponseStatus = { + SUCCESS: 0, + RETRY: 1, + DROP: 2 +}; + +/** + * optional TopicEventResponseStatus status = 1; + * @return {!proto.spec.proto.runtime.v1.TopicEventResponse.TopicEventResponseStatus} + */ +proto.spec.proto.runtime.v1.TopicEventResponse.prototype.getStatus = function() { + return /** @type {!proto.spec.proto.runtime.v1.TopicEventResponse.TopicEventResponseStatus} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {!proto.spec.proto.runtime.v1.TopicEventResponse.TopicEventResponseStatus} value + * @return {!proto.spec.proto.runtime.v1.TopicEventResponse} returns this + */ +proto.spec.proto.runtime.v1.TopicEventResponse.prototype.setStatus = function(value) { + return jspb.Message.setProto3EnumField(this, 1, value); +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse.repeatedFields_ = [1]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse.toObject = function(includeInstance, msg) { + var f, obj = { + subscriptionsList: jspb.Message.toObjectList(msg.getSubscriptionsList(), + proto.spec.proto.runtime.v1.TopicSubscription.toObject, includeInstance) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse} + */ +proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse; + return proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse} + */ +proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.spec.proto.runtime.v1.TopicSubscription; + reader.readMessage(value,proto.spec.proto.runtime.v1.TopicSubscription.deserializeBinaryFromReader); + msg.addSubscriptions(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getSubscriptionsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 1, + f, + proto.spec.proto.runtime.v1.TopicSubscription.serializeBinaryToWriter + ); + } +}; + + +/** + * repeated TopicSubscription subscriptions = 1; + * @return {!Array} + */ +proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse.prototype.getSubscriptionsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.spec.proto.runtime.v1.TopicSubscription, 1)); +}; + + +/** + * @param {!Array} value + * @return {!proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse} returns this +*/ +proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse.prototype.setSubscriptionsList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); +}; + + +/** + * @param {!proto.spec.proto.runtime.v1.TopicSubscription=} opt_value + * @param {number=} opt_index + * @return {!proto.spec.proto.runtime.v1.TopicSubscription} + */ +proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse.prototype.addSubscriptions = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.spec.proto.runtime.v1.TopicSubscription, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse} returns this + */ +proto.spec.proto.runtime.v1.ListTopicSubscriptionsResponse.prototype.clearSubscriptionsList = function() { + return this.setSubscriptionsList([]); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.TopicSubscription.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.TopicSubscription.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.TopicSubscription} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.TopicSubscription.toObject = function(includeInstance, msg) { + var f, obj = { + pubsubName: jspb.Message.getFieldWithDefault(msg, 1, ""), + topic: jspb.Message.getFieldWithDefault(msg, 2, ""), + metadataMap: (f = msg.getMetadataMap()) ? f.toObject(includeInstance, undefined) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.TopicSubscription} + */ +proto.spec.proto.runtime.v1.TopicSubscription.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.TopicSubscription; + return proto.spec.proto.runtime.v1.TopicSubscription.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.TopicSubscription} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.TopicSubscription} + */ +proto.spec.proto.runtime.v1.TopicSubscription.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setPubsubName(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setTopic(value); + break; + case 3: + var value = msg.getMetadataMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.TopicSubscription.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.TopicSubscription.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.TopicSubscription} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.TopicSubscription.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getPubsubName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getTopic(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getMetadataMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(3, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } +}; + + +/** + * optional string pubsub_name = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.TopicSubscription.prototype.getPubsubName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.TopicSubscription} returns this + */ +proto.spec.proto.runtime.v1.TopicSubscription.prototype.setPubsubName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string topic = 2; + * @return {string} + */ +proto.spec.proto.runtime.v1.TopicSubscription.prototype.getTopic = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.TopicSubscription} returns this + */ +proto.spec.proto.runtime.v1.TopicSubscription.prototype.setTopic = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * map metadata = 3; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.spec.proto.runtime.v1.TopicSubscription.prototype.getMetadataMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 3, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.spec.proto.runtime.v1.TopicSubscription} returns this + */ +proto.spec.proto.runtime.v1.TopicSubscription.prototype.clearMetadataMap = function() { + this.getMetadataMap().clear(); + return this;}; + + +goog.object.extend(exports, proto.spec.proto.runtime.v1); diff --git a/sdk/js-sdk/proto/runtime_grpc_pb.d.ts b/sdk/js-sdk/proto/runtime_grpc_pb.d.ts new file mode 100644 index 0000000000..52ea7d87db --- /dev/null +++ b/sdk/js-sdk/proto/runtime_grpc_pb.d.ts @@ -0,0 +1,382 @@ +// package: spec.proto.runtime.v1 +// file: runtime.proto + +/* tslint:disable */ +/* eslint-disable */ + +import * as grpc from "@grpc/grpc-js"; +import * as runtime_pb from "./runtime_pb"; +import * as google_protobuf_empty_pb from "google-protobuf/google/protobuf/empty_pb"; +import * as google_protobuf_any_pb from "google-protobuf/google/protobuf/any_pb"; + +interface IRuntimeService extends grpc.ServiceDefinition { + sayHello: IRuntimeService_ISayHello; + invokeService: IRuntimeService_IInvokeService; + getConfiguration: IRuntimeService_IGetConfiguration; + saveConfiguration: IRuntimeService_ISaveConfiguration; + deleteConfiguration: IRuntimeService_IDeleteConfiguration; + subscribeConfiguration: IRuntimeService_ISubscribeConfiguration; + tryLock: IRuntimeService_ITryLock; + unlock: IRuntimeService_IUnlock; + getNextId: IRuntimeService_IGetNextId; + getState: IRuntimeService_IGetState; + getBulkState: IRuntimeService_IGetBulkState; + saveState: IRuntimeService_ISaveState; + deleteState: IRuntimeService_IDeleteState; + deleteBulkState: IRuntimeService_IDeleteBulkState; + executeStateTransaction: IRuntimeService_IExecuteStateTransaction; + publishEvent: IRuntimeService_IPublishEvent; + getFile: IRuntimeService_IGetFile; + putFile: IRuntimeService_IPutFile; + listFile: IRuntimeService_IListFile; + delFile: IRuntimeService_IDelFile; + invokeBinding: IRuntimeService_IInvokeBinding; +} + +interface IRuntimeService_ISayHello extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.Runtime/SayHello"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface IRuntimeService_IInvokeService extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.Runtime/InvokeService"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface IRuntimeService_IGetConfiguration extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.Runtime/GetConfiguration"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface IRuntimeService_ISaveConfiguration extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.Runtime/SaveConfiguration"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface IRuntimeService_IDeleteConfiguration extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.Runtime/DeleteConfiguration"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface IRuntimeService_ISubscribeConfiguration extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.Runtime/SubscribeConfiguration"; + requestStream: true; + responseStream: true; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface IRuntimeService_ITryLock extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.Runtime/TryLock"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface IRuntimeService_IUnlock extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.Runtime/Unlock"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface IRuntimeService_IGetNextId extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.Runtime/GetNextId"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface IRuntimeService_IGetState extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.Runtime/GetState"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface IRuntimeService_IGetBulkState extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.Runtime/GetBulkState"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface IRuntimeService_ISaveState extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.Runtime/SaveState"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface IRuntimeService_IDeleteState extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.Runtime/DeleteState"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface IRuntimeService_IDeleteBulkState extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.Runtime/DeleteBulkState"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface IRuntimeService_IExecuteStateTransaction extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.Runtime/ExecuteStateTransaction"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface IRuntimeService_IPublishEvent extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.Runtime/PublishEvent"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface IRuntimeService_IGetFile extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.Runtime/GetFile"; + requestStream: false; + responseStream: true; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface IRuntimeService_IPutFile extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.Runtime/PutFile"; + requestStream: true; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface IRuntimeService_IListFile extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.Runtime/ListFile"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface IRuntimeService_IDelFile extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.Runtime/DelFile"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} +interface IRuntimeService_IInvokeBinding extends grpc.MethodDefinition { + path: "/spec.proto.runtime.v1.Runtime/InvokeBinding"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} + +export const RuntimeService: IRuntimeService; + +export interface IRuntimeServer extends grpc.UntypedServiceImplementation { + sayHello: grpc.handleUnaryCall; + invokeService: grpc.handleUnaryCall; + getConfiguration: grpc.handleUnaryCall; + saveConfiguration: grpc.handleUnaryCall; + deleteConfiguration: grpc.handleUnaryCall; + subscribeConfiguration: grpc.handleBidiStreamingCall; + tryLock: grpc.handleUnaryCall; + unlock: grpc.handleUnaryCall; + getNextId: grpc.handleUnaryCall; + getState: grpc.handleUnaryCall; + getBulkState: grpc.handleUnaryCall; + saveState: grpc.handleUnaryCall; + deleteState: grpc.handleUnaryCall; + deleteBulkState: grpc.handleUnaryCall; + executeStateTransaction: grpc.handleUnaryCall; + publishEvent: grpc.handleUnaryCall; + getFile: grpc.handleServerStreamingCall; + putFile: grpc.handleClientStreamingCall; + listFile: grpc.handleUnaryCall; + delFile: grpc.handleUnaryCall; + invokeBinding: grpc.handleUnaryCall; +} + +export interface IRuntimeClient { + sayHello(request: runtime_pb.SayHelloRequest, callback: (error: grpc.ServiceError | null, response: runtime_pb.SayHelloResponse) => void): grpc.ClientUnaryCall; + sayHello(request: runtime_pb.SayHelloRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: runtime_pb.SayHelloResponse) => void): grpc.ClientUnaryCall; + sayHello(request: runtime_pb.SayHelloRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: runtime_pb.SayHelloResponse) => void): grpc.ClientUnaryCall; + invokeService(request: runtime_pb.InvokeServiceRequest, callback: (error: grpc.ServiceError | null, response: runtime_pb.InvokeResponse) => void): grpc.ClientUnaryCall; + invokeService(request: runtime_pb.InvokeServiceRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: runtime_pb.InvokeResponse) => void): grpc.ClientUnaryCall; + invokeService(request: runtime_pb.InvokeServiceRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: runtime_pb.InvokeResponse) => void): grpc.ClientUnaryCall; + getConfiguration(request: runtime_pb.GetConfigurationRequest, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetConfigurationResponse) => void): grpc.ClientUnaryCall; + getConfiguration(request: runtime_pb.GetConfigurationRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetConfigurationResponse) => void): grpc.ClientUnaryCall; + getConfiguration(request: runtime_pb.GetConfigurationRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetConfigurationResponse) => void): grpc.ClientUnaryCall; + saveConfiguration(request: runtime_pb.SaveConfigurationRequest, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + saveConfiguration(request: runtime_pb.SaveConfigurationRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + saveConfiguration(request: runtime_pb.SaveConfigurationRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + deleteConfiguration(request: runtime_pb.DeleteConfigurationRequest, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + deleteConfiguration(request: runtime_pb.DeleteConfigurationRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + deleteConfiguration(request: runtime_pb.DeleteConfigurationRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + subscribeConfiguration(): grpc.ClientDuplexStream; + subscribeConfiguration(options: Partial): grpc.ClientDuplexStream; + subscribeConfiguration(metadata: grpc.Metadata, options?: Partial): grpc.ClientDuplexStream; + tryLock(request: runtime_pb.TryLockRequest, callback: (error: grpc.ServiceError | null, response: runtime_pb.TryLockResponse) => void): grpc.ClientUnaryCall; + tryLock(request: runtime_pb.TryLockRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: runtime_pb.TryLockResponse) => void): grpc.ClientUnaryCall; + tryLock(request: runtime_pb.TryLockRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: runtime_pb.TryLockResponse) => void): grpc.ClientUnaryCall; + unlock(request: runtime_pb.UnlockRequest, callback: (error: grpc.ServiceError | null, response: runtime_pb.UnlockResponse) => void): grpc.ClientUnaryCall; + unlock(request: runtime_pb.UnlockRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: runtime_pb.UnlockResponse) => void): grpc.ClientUnaryCall; + unlock(request: runtime_pb.UnlockRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: runtime_pb.UnlockResponse) => void): grpc.ClientUnaryCall; + getNextId(request: runtime_pb.GetNextIdRequest, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetNextIdResponse) => void): grpc.ClientUnaryCall; + getNextId(request: runtime_pb.GetNextIdRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetNextIdResponse) => void): grpc.ClientUnaryCall; + getNextId(request: runtime_pb.GetNextIdRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetNextIdResponse) => void): grpc.ClientUnaryCall; + getState(request: runtime_pb.GetStateRequest, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetStateResponse) => void): grpc.ClientUnaryCall; + getState(request: runtime_pb.GetStateRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetStateResponse) => void): grpc.ClientUnaryCall; + getState(request: runtime_pb.GetStateRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetStateResponse) => void): grpc.ClientUnaryCall; + getBulkState(request: runtime_pb.GetBulkStateRequest, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetBulkStateResponse) => void): grpc.ClientUnaryCall; + getBulkState(request: runtime_pb.GetBulkStateRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetBulkStateResponse) => void): grpc.ClientUnaryCall; + getBulkState(request: runtime_pb.GetBulkStateRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetBulkStateResponse) => void): grpc.ClientUnaryCall; + saveState(request: runtime_pb.SaveStateRequest, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + saveState(request: runtime_pb.SaveStateRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + saveState(request: runtime_pb.SaveStateRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + deleteState(request: runtime_pb.DeleteStateRequest, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + deleteState(request: runtime_pb.DeleteStateRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + deleteState(request: runtime_pb.DeleteStateRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + deleteBulkState(request: runtime_pb.DeleteBulkStateRequest, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + deleteBulkState(request: runtime_pb.DeleteBulkStateRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + deleteBulkState(request: runtime_pb.DeleteBulkStateRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + executeStateTransaction(request: runtime_pb.ExecuteStateTransactionRequest, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + executeStateTransaction(request: runtime_pb.ExecuteStateTransactionRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + executeStateTransaction(request: runtime_pb.ExecuteStateTransactionRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + publishEvent(request: runtime_pb.PublishEventRequest, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + publishEvent(request: runtime_pb.PublishEventRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + publishEvent(request: runtime_pb.PublishEventRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + getFile(request: runtime_pb.GetFileRequest, options?: Partial): grpc.ClientReadableStream; + getFile(request: runtime_pb.GetFileRequest, metadata?: grpc.Metadata, options?: Partial): grpc.ClientReadableStream; + putFile(callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientWritableStream; + putFile(metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientWritableStream; + putFile(options: Partial, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientWritableStream; + putFile(metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientWritableStream; + listFile(request: runtime_pb.ListFileRequest, callback: (error: grpc.ServiceError | null, response: runtime_pb.ListFileResp) => void): grpc.ClientUnaryCall; + listFile(request: runtime_pb.ListFileRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: runtime_pb.ListFileResp) => void): grpc.ClientUnaryCall; + listFile(request: runtime_pb.ListFileRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: runtime_pb.ListFileResp) => void): grpc.ClientUnaryCall; + delFile(request: runtime_pb.DelFileRequest, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + delFile(request: runtime_pb.DelFileRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + delFile(request: runtime_pb.DelFileRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + invokeBinding(request: runtime_pb.InvokeBindingRequest, callback: (error: grpc.ServiceError | null, response: runtime_pb.InvokeBindingResponse) => void): grpc.ClientUnaryCall; + invokeBinding(request: runtime_pb.InvokeBindingRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: runtime_pb.InvokeBindingResponse) => void): grpc.ClientUnaryCall; + invokeBinding(request: runtime_pb.InvokeBindingRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: runtime_pb.InvokeBindingResponse) => void): grpc.ClientUnaryCall; +} + +export class RuntimeClient extends grpc.Client implements IRuntimeClient { + constructor(address: string, credentials: grpc.ChannelCredentials, options?: Partial); + public sayHello(request: runtime_pb.SayHelloRequest, callback: (error: grpc.ServiceError | null, response: runtime_pb.SayHelloResponse) => void): grpc.ClientUnaryCall; + public sayHello(request: runtime_pb.SayHelloRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: runtime_pb.SayHelloResponse) => void): grpc.ClientUnaryCall; + public sayHello(request: runtime_pb.SayHelloRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: runtime_pb.SayHelloResponse) => void): grpc.ClientUnaryCall; + public invokeService(request: runtime_pb.InvokeServiceRequest, callback: (error: grpc.ServiceError | null, response: runtime_pb.InvokeResponse) => void): grpc.ClientUnaryCall; + public invokeService(request: runtime_pb.InvokeServiceRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: runtime_pb.InvokeResponse) => void): grpc.ClientUnaryCall; + public invokeService(request: runtime_pb.InvokeServiceRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: runtime_pb.InvokeResponse) => void): grpc.ClientUnaryCall; + public getConfiguration(request: runtime_pb.GetConfigurationRequest, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetConfigurationResponse) => void): grpc.ClientUnaryCall; + public getConfiguration(request: runtime_pb.GetConfigurationRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetConfigurationResponse) => void): grpc.ClientUnaryCall; + public getConfiguration(request: runtime_pb.GetConfigurationRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetConfigurationResponse) => void): grpc.ClientUnaryCall; + public saveConfiguration(request: runtime_pb.SaveConfigurationRequest, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public saveConfiguration(request: runtime_pb.SaveConfigurationRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public saveConfiguration(request: runtime_pb.SaveConfigurationRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public deleteConfiguration(request: runtime_pb.DeleteConfigurationRequest, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public deleteConfiguration(request: runtime_pb.DeleteConfigurationRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public deleteConfiguration(request: runtime_pb.DeleteConfigurationRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public subscribeConfiguration(options?: Partial): grpc.ClientDuplexStream; + public subscribeConfiguration(metadata?: grpc.Metadata, options?: Partial): grpc.ClientDuplexStream; + public tryLock(request: runtime_pb.TryLockRequest, callback: (error: grpc.ServiceError | null, response: runtime_pb.TryLockResponse) => void): grpc.ClientUnaryCall; + public tryLock(request: runtime_pb.TryLockRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: runtime_pb.TryLockResponse) => void): grpc.ClientUnaryCall; + public tryLock(request: runtime_pb.TryLockRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: runtime_pb.TryLockResponse) => void): grpc.ClientUnaryCall; + public unlock(request: runtime_pb.UnlockRequest, callback: (error: grpc.ServiceError | null, response: runtime_pb.UnlockResponse) => void): grpc.ClientUnaryCall; + public unlock(request: runtime_pb.UnlockRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: runtime_pb.UnlockResponse) => void): grpc.ClientUnaryCall; + public unlock(request: runtime_pb.UnlockRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: runtime_pb.UnlockResponse) => void): grpc.ClientUnaryCall; + public getNextId(request: runtime_pb.GetNextIdRequest, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetNextIdResponse) => void): grpc.ClientUnaryCall; + public getNextId(request: runtime_pb.GetNextIdRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetNextIdResponse) => void): grpc.ClientUnaryCall; + public getNextId(request: runtime_pb.GetNextIdRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetNextIdResponse) => void): grpc.ClientUnaryCall; + public getState(request: runtime_pb.GetStateRequest, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetStateResponse) => void): grpc.ClientUnaryCall; + public getState(request: runtime_pb.GetStateRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetStateResponse) => void): grpc.ClientUnaryCall; + public getState(request: runtime_pb.GetStateRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetStateResponse) => void): grpc.ClientUnaryCall; + public getBulkState(request: runtime_pb.GetBulkStateRequest, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetBulkStateResponse) => void): grpc.ClientUnaryCall; + public getBulkState(request: runtime_pb.GetBulkStateRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetBulkStateResponse) => void): grpc.ClientUnaryCall; + public getBulkState(request: runtime_pb.GetBulkStateRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: runtime_pb.GetBulkStateResponse) => void): grpc.ClientUnaryCall; + public saveState(request: runtime_pb.SaveStateRequest, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public saveState(request: runtime_pb.SaveStateRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public saveState(request: runtime_pb.SaveStateRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public deleteState(request: runtime_pb.DeleteStateRequest, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public deleteState(request: runtime_pb.DeleteStateRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public deleteState(request: runtime_pb.DeleteStateRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public deleteBulkState(request: runtime_pb.DeleteBulkStateRequest, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public deleteBulkState(request: runtime_pb.DeleteBulkStateRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public deleteBulkState(request: runtime_pb.DeleteBulkStateRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public executeStateTransaction(request: runtime_pb.ExecuteStateTransactionRequest, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public executeStateTransaction(request: runtime_pb.ExecuteStateTransactionRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public executeStateTransaction(request: runtime_pb.ExecuteStateTransactionRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public publishEvent(request: runtime_pb.PublishEventRequest, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public publishEvent(request: runtime_pb.PublishEventRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public publishEvent(request: runtime_pb.PublishEventRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public getFile(request: runtime_pb.GetFileRequest, options?: Partial): grpc.ClientReadableStream; + public getFile(request: runtime_pb.GetFileRequest, metadata?: grpc.Metadata, options?: Partial): grpc.ClientReadableStream; + public putFile(callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientWritableStream; + public putFile(metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientWritableStream; + public putFile(options: Partial, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientWritableStream; + public putFile(metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientWritableStream; + public listFile(request: runtime_pb.ListFileRequest, callback: (error: grpc.ServiceError | null, response: runtime_pb.ListFileResp) => void): grpc.ClientUnaryCall; + public listFile(request: runtime_pb.ListFileRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: runtime_pb.ListFileResp) => void): grpc.ClientUnaryCall; + public listFile(request: runtime_pb.ListFileRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: runtime_pb.ListFileResp) => void): grpc.ClientUnaryCall; + public delFile(request: runtime_pb.DelFileRequest, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public delFile(request: runtime_pb.DelFileRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public delFile(request: runtime_pb.DelFileRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: google_protobuf_empty_pb.Empty) => void): grpc.ClientUnaryCall; + public invokeBinding(request: runtime_pb.InvokeBindingRequest, callback: (error: grpc.ServiceError | null, response: runtime_pb.InvokeBindingResponse) => void): grpc.ClientUnaryCall; + public invokeBinding(request: runtime_pb.InvokeBindingRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: runtime_pb.InvokeBindingResponse) => void): grpc.ClientUnaryCall; + public invokeBinding(request: runtime_pb.InvokeBindingRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: runtime_pb.InvokeBindingResponse) => void): grpc.ClientUnaryCall; +} diff --git a/sdk/js-sdk/proto/runtime_grpc_pb.js b/sdk/js-sdk/proto/runtime_grpc_pb.js new file mode 100644 index 0000000000..157074bac8 --- /dev/null +++ b/sdk/js-sdk/proto/runtime_grpc_pb.js @@ -0,0 +1,644 @@ +// GENERATED CODE -- DO NOT EDIT! + +'use strict'; +var grpc = require('@grpc/grpc-js'); +var runtime_pb = require('./runtime_pb.js'); +var google_protobuf_empty_pb = require('google-protobuf/google/protobuf/empty_pb.js'); +var google_protobuf_any_pb = require('google-protobuf/google/protobuf/any_pb.js'); + +function serialize_google_protobuf_Empty(arg) { + if (!(arg instanceof google_protobuf_empty_pb.Empty)) { + throw new Error('Expected argument of type google.protobuf.Empty'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_google_protobuf_Empty(buffer_arg) { + return google_protobuf_empty_pb.Empty.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_DelFileRequest(arg) { + if (!(arg instanceof runtime_pb.DelFileRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.DelFileRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_DelFileRequest(buffer_arg) { + return runtime_pb.DelFileRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_DeleteBulkStateRequest(arg) { + if (!(arg instanceof runtime_pb.DeleteBulkStateRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.DeleteBulkStateRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_DeleteBulkStateRequest(buffer_arg) { + return runtime_pb.DeleteBulkStateRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_DeleteConfigurationRequest(arg) { + if (!(arg instanceof runtime_pb.DeleteConfigurationRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.DeleteConfigurationRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_DeleteConfigurationRequest(buffer_arg) { + return runtime_pb.DeleteConfigurationRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_DeleteStateRequest(arg) { + if (!(arg instanceof runtime_pb.DeleteStateRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.DeleteStateRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_DeleteStateRequest(buffer_arg) { + return runtime_pb.DeleteStateRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_ExecuteStateTransactionRequest(arg) { + if (!(arg instanceof runtime_pb.ExecuteStateTransactionRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.ExecuteStateTransactionRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_ExecuteStateTransactionRequest(buffer_arg) { + return runtime_pb.ExecuteStateTransactionRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_GetBulkStateRequest(arg) { + if (!(arg instanceof runtime_pb.GetBulkStateRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.GetBulkStateRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_GetBulkStateRequest(buffer_arg) { + return runtime_pb.GetBulkStateRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_GetBulkStateResponse(arg) { + if (!(arg instanceof runtime_pb.GetBulkStateResponse)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.GetBulkStateResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_GetBulkStateResponse(buffer_arg) { + return runtime_pb.GetBulkStateResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_GetConfigurationRequest(arg) { + if (!(arg instanceof runtime_pb.GetConfigurationRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.GetConfigurationRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_GetConfigurationRequest(buffer_arg) { + return runtime_pb.GetConfigurationRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_GetConfigurationResponse(arg) { + if (!(arg instanceof runtime_pb.GetConfigurationResponse)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.GetConfigurationResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_GetConfigurationResponse(buffer_arg) { + return runtime_pb.GetConfigurationResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_GetFileRequest(arg) { + if (!(arg instanceof runtime_pb.GetFileRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.GetFileRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_GetFileRequest(buffer_arg) { + return runtime_pb.GetFileRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_GetFileResponse(arg) { + if (!(arg instanceof runtime_pb.GetFileResponse)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.GetFileResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_GetFileResponse(buffer_arg) { + return runtime_pb.GetFileResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_GetNextIdRequest(arg) { + if (!(arg instanceof runtime_pb.GetNextIdRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.GetNextIdRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_GetNextIdRequest(buffer_arg) { + return runtime_pb.GetNextIdRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_GetNextIdResponse(arg) { + if (!(arg instanceof runtime_pb.GetNextIdResponse)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.GetNextIdResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_GetNextIdResponse(buffer_arg) { + return runtime_pb.GetNextIdResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_GetStateRequest(arg) { + if (!(arg instanceof runtime_pb.GetStateRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.GetStateRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_GetStateRequest(buffer_arg) { + return runtime_pb.GetStateRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_GetStateResponse(arg) { + if (!(arg instanceof runtime_pb.GetStateResponse)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.GetStateResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_GetStateResponse(buffer_arg) { + return runtime_pb.GetStateResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_InvokeBindingRequest(arg) { + if (!(arg instanceof runtime_pb.InvokeBindingRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.InvokeBindingRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_InvokeBindingRequest(buffer_arg) { + return runtime_pb.InvokeBindingRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_InvokeBindingResponse(arg) { + if (!(arg instanceof runtime_pb.InvokeBindingResponse)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.InvokeBindingResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_InvokeBindingResponse(buffer_arg) { + return runtime_pb.InvokeBindingResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_InvokeResponse(arg) { + if (!(arg instanceof runtime_pb.InvokeResponse)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.InvokeResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_InvokeResponse(buffer_arg) { + return runtime_pb.InvokeResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_InvokeServiceRequest(arg) { + if (!(arg instanceof runtime_pb.InvokeServiceRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.InvokeServiceRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_InvokeServiceRequest(buffer_arg) { + return runtime_pb.InvokeServiceRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_ListFileRequest(arg) { + if (!(arg instanceof runtime_pb.ListFileRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.ListFileRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_ListFileRequest(buffer_arg) { + return runtime_pb.ListFileRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_ListFileResp(arg) { + if (!(arg instanceof runtime_pb.ListFileResp)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.ListFileResp'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_ListFileResp(buffer_arg) { + return runtime_pb.ListFileResp.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_PublishEventRequest(arg) { + if (!(arg instanceof runtime_pb.PublishEventRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.PublishEventRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_PublishEventRequest(buffer_arg) { + return runtime_pb.PublishEventRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_PutFileRequest(arg) { + if (!(arg instanceof runtime_pb.PutFileRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.PutFileRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_PutFileRequest(buffer_arg) { + return runtime_pb.PutFileRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_SaveConfigurationRequest(arg) { + if (!(arg instanceof runtime_pb.SaveConfigurationRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.SaveConfigurationRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_SaveConfigurationRequest(buffer_arg) { + return runtime_pb.SaveConfigurationRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_SaveStateRequest(arg) { + if (!(arg instanceof runtime_pb.SaveStateRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.SaveStateRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_SaveStateRequest(buffer_arg) { + return runtime_pb.SaveStateRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_SayHelloRequest(arg) { + if (!(arg instanceof runtime_pb.SayHelloRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.SayHelloRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_SayHelloRequest(buffer_arg) { + return runtime_pb.SayHelloRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_SayHelloResponse(arg) { + if (!(arg instanceof runtime_pb.SayHelloResponse)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.SayHelloResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_SayHelloResponse(buffer_arg) { + return runtime_pb.SayHelloResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_SubscribeConfigurationRequest(arg) { + if (!(arg instanceof runtime_pb.SubscribeConfigurationRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.SubscribeConfigurationRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_SubscribeConfigurationRequest(buffer_arg) { + return runtime_pb.SubscribeConfigurationRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_SubscribeConfigurationResponse(arg) { + if (!(arg instanceof runtime_pb.SubscribeConfigurationResponse)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.SubscribeConfigurationResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_SubscribeConfigurationResponse(buffer_arg) { + return runtime_pb.SubscribeConfigurationResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_TryLockRequest(arg) { + if (!(arg instanceof runtime_pb.TryLockRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.TryLockRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_TryLockRequest(buffer_arg) { + return runtime_pb.TryLockRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_TryLockResponse(arg) { + if (!(arg instanceof runtime_pb.TryLockResponse)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.TryLockResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_TryLockResponse(buffer_arg) { + return runtime_pb.TryLockResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_UnlockRequest(arg) { + if (!(arg instanceof runtime_pb.UnlockRequest)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.UnlockRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_UnlockRequest(buffer_arg) { + return runtime_pb.UnlockRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_spec_proto_runtime_v1_UnlockResponse(arg) { + if (!(arg instanceof runtime_pb.UnlockResponse)) { + throw new Error('Expected argument of type spec.proto.runtime.v1.UnlockResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_spec_proto_runtime_v1_UnlockResponse(buffer_arg) { + return runtime_pb.UnlockResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + + +var RuntimeService = exports.RuntimeService = { + // SayHello used for test +sayHello: { + path: '/spec.proto.runtime.v1.Runtime/SayHello', + requestStream: false, + responseStream: false, + requestType: runtime_pb.SayHelloRequest, + responseType: runtime_pb.SayHelloResponse, + requestSerialize: serialize_spec_proto_runtime_v1_SayHelloRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_SayHelloRequest, + responseSerialize: serialize_spec_proto_runtime_v1_SayHelloResponse, + responseDeserialize: deserialize_spec_proto_runtime_v1_SayHelloResponse, + }, + // InvokeService do rpc calls +invokeService: { + path: '/spec.proto.runtime.v1.Runtime/InvokeService', + requestStream: false, + responseStream: false, + requestType: runtime_pb.InvokeServiceRequest, + responseType: runtime_pb.InvokeResponse, + requestSerialize: serialize_spec_proto_runtime_v1_InvokeServiceRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_InvokeServiceRequest, + responseSerialize: serialize_spec_proto_runtime_v1_InvokeResponse, + responseDeserialize: deserialize_spec_proto_runtime_v1_InvokeResponse, + }, + // GetConfiguration gets configuration from configuration store. +getConfiguration: { + path: '/spec.proto.runtime.v1.Runtime/GetConfiguration', + requestStream: false, + responseStream: false, + requestType: runtime_pb.GetConfigurationRequest, + responseType: runtime_pb.GetConfigurationResponse, + requestSerialize: serialize_spec_proto_runtime_v1_GetConfigurationRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_GetConfigurationRequest, + responseSerialize: serialize_spec_proto_runtime_v1_GetConfigurationResponse, + responseDeserialize: deserialize_spec_proto_runtime_v1_GetConfigurationResponse, + }, + // SaveConfiguration saves configuration into configuration store. +saveConfiguration: { + path: '/spec.proto.runtime.v1.Runtime/SaveConfiguration', + requestStream: false, + responseStream: false, + requestType: runtime_pb.SaveConfigurationRequest, + responseType: google_protobuf_empty_pb.Empty, + requestSerialize: serialize_spec_proto_runtime_v1_SaveConfigurationRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_SaveConfigurationRequest, + responseSerialize: serialize_google_protobuf_Empty, + responseDeserialize: deserialize_google_protobuf_Empty, + }, + // DeleteConfiguration deletes configuration from configuration store. +deleteConfiguration: { + path: '/spec.proto.runtime.v1.Runtime/DeleteConfiguration', + requestStream: false, + responseStream: false, + requestType: runtime_pb.DeleteConfigurationRequest, + responseType: google_protobuf_empty_pb.Empty, + requestSerialize: serialize_spec_proto_runtime_v1_DeleteConfigurationRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_DeleteConfigurationRequest, + responseSerialize: serialize_google_protobuf_Empty, + responseDeserialize: deserialize_google_protobuf_Empty, + }, + // SubscribeConfiguration gets configuration from configuration store and subscribe the updates. +subscribeConfiguration: { + path: '/spec.proto.runtime.v1.Runtime/SubscribeConfiguration', + requestStream: true, + responseStream: true, + requestType: runtime_pb.SubscribeConfigurationRequest, + responseType: runtime_pb.SubscribeConfigurationResponse, + requestSerialize: serialize_spec_proto_runtime_v1_SubscribeConfigurationRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_SubscribeConfigurationRequest, + responseSerialize: serialize_spec_proto_runtime_v1_SubscribeConfigurationResponse, + responseDeserialize: deserialize_spec_proto_runtime_v1_SubscribeConfigurationResponse, + }, + // Distributed Lock API +// A non-blocking method trying to get a lock with ttl. +tryLock: { + path: '/spec.proto.runtime.v1.Runtime/TryLock', + requestStream: false, + responseStream: false, + requestType: runtime_pb.TryLockRequest, + responseType: runtime_pb.TryLockResponse, + requestSerialize: serialize_spec_proto_runtime_v1_TryLockRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_TryLockRequest, + responseSerialize: serialize_spec_proto_runtime_v1_TryLockResponse, + responseDeserialize: deserialize_spec_proto_runtime_v1_TryLockResponse, + }, + unlock: { + path: '/spec.proto.runtime.v1.Runtime/Unlock', + requestStream: false, + responseStream: false, + requestType: runtime_pb.UnlockRequest, + responseType: runtime_pb.UnlockResponse, + requestSerialize: serialize_spec_proto_runtime_v1_UnlockRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_UnlockRequest, + responseSerialize: serialize_spec_proto_runtime_v1_UnlockResponse, + responseDeserialize: deserialize_spec_proto_runtime_v1_UnlockResponse, + }, + // Sequencer API +// Get next unique id with some auto-increment guarantee +getNextId: { + path: '/spec.proto.runtime.v1.Runtime/GetNextId', + requestStream: false, + responseStream: false, + requestType: runtime_pb.GetNextIdRequest, + responseType: runtime_pb.GetNextIdResponse, + requestSerialize: serialize_spec_proto_runtime_v1_GetNextIdRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_GetNextIdRequest, + responseSerialize: serialize_spec_proto_runtime_v1_GetNextIdResponse, + responseDeserialize: deserialize_spec_proto_runtime_v1_GetNextIdResponse, + }, + // Below are the APIs compatible with Dapr. +// We try to keep them same as Dapr's because we want to work with Dapr to build an API spec for cloud native runtime +// ,like CloudEvent for event data. +// +// Gets the state for a specific key. +getState: { + path: '/spec.proto.runtime.v1.Runtime/GetState', + requestStream: false, + responseStream: false, + requestType: runtime_pb.GetStateRequest, + responseType: runtime_pb.GetStateResponse, + requestSerialize: serialize_spec_proto_runtime_v1_GetStateRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_GetStateRequest, + responseSerialize: serialize_spec_proto_runtime_v1_GetStateResponse, + responseDeserialize: deserialize_spec_proto_runtime_v1_GetStateResponse, + }, + // Gets a bulk of state items for a list of keys +getBulkState: { + path: '/spec.proto.runtime.v1.Runtime/GetBulkState', + requestStream: false, + responseStream: false, + requestType: runtime_pb.GetBulkStateRequest, + responseType: runtime_pb.GetBulkStateResponse, + requestSerialize: serialize_spec_proto_runtime_v1_GetBulkStateRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_GetBulkStateRequest, + responseSerialize: serialize_spec_proto_runtime_v1_GetBulkStateResponse, + responseDeserialize: deserialize_spec_proto_runtime_v1_GetBulkStateResponse, + }, + // Saves an array of state objects +saveState: { + path: '/spec.proto.runtime.v1.Runtime/SaveState', + requestStream: false, + responseStream: false, + requestType: runtime_pb.SaveStateRequest, + responseType: google_protobuf_empty_pb.Empty, + requestSerialize: serialize_spec_proto_runtime_v1_SaveStateRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_SaveStateRequest, + responseSerialize: serialize_google_protobuf_Empty, + responseDeserialize: deserialize_google_protobuf_Empty, + }, + // Deletes the state for a specific key. +deleteState: { + path: '/spec.proto.runtime.v1.Runtime/DeleteState', + requestStream: false, + responseStream: false, + requestType: runtime_pb.DeleteStateRequest, + responseType: google_protobuf_empty_pb.Empty, + requestSerialize: serialize_spec_proto_runtime_v1_DeleteStateRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_DeleteStateRequest, + responseSerialize: serialize_google_protobuf_Empty, + responseDeserialize: deserialize_google_protobuf_Empty, + }, + // Deletes a bulk of state items for a list of keys +deleteBulkState: { + path: '/spec.proto.runtime.v1.Runtime/DeleteBulkState', + requestStream: false, + responseStream: false, + requestType: runtime_pb.DeleteBulkStateRequest, + responseType: google_protobuf_empty_pb.Empty, + requestSerialize: serialize_spec_proto_runtime_v1_DeleteBulkStateRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_DeleteBulkStateRequest, + responseSerialize: serialize_google_protobuf_Empty, + responseDeserialize: deserialize_google_protobuf_Empty, + }, + // Executes transactions for a specified store +executeStateTransaction: { + path: '/spec.proto.runtime.v1.Runtime/ExecuteStateTransaction', + requestStream: false, + responseStream: false, + requestType: runtime_pb.ExecuteStateTransactionRequest, + responseType: google_protobuf_empty_pb.Empty, + requestSerialize: serialize_spec_proto_runtime_v1_ExecuteStateTransactionRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_ExecuteStateTransactionRequest, + responseSerialize: serialize_google_protobuf_Empty, + responseDeserialize: deserialize_google_protobuf_Empty, + }, + // Publishes events to the specific topic +publishEvent: { + path: '/spec.proto.runtime.v1.Runtime/PublishEvent', + requestStream: false, + responseStream: false, + requestType: runtime_pb.PublishEventRequest, + responseType: google_protobuf_empty_pb.Empty, + requestSerialize: serialize_spec_proto_runtime_v1_PublishEventRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_PublishEventRequest, + responseSerialize: serialize_google_protobuf_Empty, + responseDeserialize: deserialize_google_protobuf_Empty, + }, + // Get file with stream +getFile: { + path: '/spec.proto.runtime.v1.Runtime/GetFile', + requestStream: false, + responseStream: true, + requestType: runtime_pb.GetFileRequest, + responseType: runtime_pb.GetFileResponse, + requestSerialize: serialize_spec_proto_runtime_v1_GetFileRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_GetFileRequest, + responseSerialize: serialize_spec_proto_runtime_v1_GetFileResponse, + responseDeserialize: deserialize_spec_proto_runtime_v1_GetFileResponse, + }, + // Put file with stream +putFile: { + path: '/spec.proto.runtime.v1.Runtime/PutFile', + requestStream: true, + responseStream: false, + requestType: runtime_pb.PutFileRequest, + responseType: google_protobuf_empty_pb.Empty, + requestSerialize: serialize_spec_proto_runtime_v1_PutFileRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_PutFileRequest, + responseSerialize: serialize_google_protobuf_Empty, + responseDeserialize: deserialize_google_protobuf_Empty, + }, + // List all files +listFile: { + path: '/spec.proto.runtime.v1.Runtime/ListFile', + requestStream: false, + responseStream: false, + requestType: runtime_pb.ListFileRequest, + responseType: runtime_pb.ListFileResp, + requestSerialize: serialize_spec_proto_runtime_v1_ListFileRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_ListFileRequest, + responseSerialize: serialize_spec_proto_runtime_v1_ListFileResp, + responseDeserialize: deserialize_spec_proto_runtime_v1_ListFileResp, + }, + // Delete specific file +delFile: { + path: '/spec.proto.runtime.v1.Runtime/DelFile', + requestStream: false, + responseStream: false, + requestType: runtime_pb.DelFileRequest, + responseType: google_protobuf_empty_pb.Empty, + requestSerialize: serialize_spec_proto_runtime_v1_DelFileRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_DelFileRequest, + responseSerialize: serialize_google_protobuf_Empty, + responseDeserialize: deserialize_google_protobuf_Empty, + }, + // Invokes binding data to specific output bindings +invokeBinding: { + path: '/spec.proto.runtime.v1.Runtime/InvokeBinding', + requestStream: false, + responseStream: false, + requestType: runtime_pb.InvokeBindingRequest, + responseType: runtime_pb.InvokeBindingResponse, + requestSerialize: serialize_spec_proto_runtime_v1_InvokeBindingRequest, + requestDeserialize: deserialize_spec_proto_runtime_v1_InvokeBindingRequest, + responseSerialize: serialize_spec_proto_runtime_v1_InvokeBindingResponse, + responseDeserialize: deserialize_spec_proto_runtime_v1_InvokeBindingResponse, + }, +}; + +exports.RuntimeClient = grpc.makeGenericClientConstructor(RuntimeService); diff --git a/sdk/js-sdk/proto/runtime_pb.d.ts b/sdk/js-sdk/proto/runtime_pb.d.ts new file mode 100644 index 0000000000..744019fd54 --- /dev/null +++ b/sdk/js-sdk/proto/runtime_pb.d.ts @@ -0,0 +1,1283 @@ +// package: spec.proto.runtime.v1 +// file: runtime.proto + +/* tslint:disable */ +/* eslint-disable */ + +import * as jspb from "google-protobuf"; +import * as google_protobuf_empty_pb from "google-protobuf/google/protobuf/empty_pb"; +import * as google_protobuf_any_pb from "google-protobuf/google/protobuf/any_pb"; + +export class GetFileRequest extends jspb.Message { + getStoreName(): string; + setStoreName(value: string): GetFileRequest; + getName(): string; + setName(value: string): GetFileRequest; + + getMetadataMap(): jspb.Map; + clearMetadataMap(): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetFileRequest.AsObject; + static toObject(includeInstance: boolean, msg: GetFileRequest): GetFileRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetFileRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetFileRequest; + static deserializeBinaryFromReader(message: GetFileRequest, reader: jspb.BinaryReader): GetFileRequest; +} + +export namespace GetFileRequest { + export type AsObject = { + storeName: string, + name: string, + + metadataMap: Array<[string, string]>, + } +} + +export class GetFileResponse extends jspb.Message { + getData(): Uint8Array | string; + getData_asU8(): Uint8Array; + getData_asB64(): string; + setData(value: Uint8Array | string): GetFileResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetFileResponse.AsObject; + static toObject(includeInstance: boolean, msg: GetFileResponse): GetFileResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetFileResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetFileResponse; + static deserializeBinaryFromReader(message: GetFileResponse, reader: jspb.BinaryReader): GetFileResponse; +} + +export namespace GetFileResponse { + export type AsObject = { + data: Uint8Array | string, + } +} + +export class PutFileRequest extends jspb.Message { + getStoreName(): string; + setStoreName(value: string): PutFileRequest; + getName(): string; + setName(value: string): PutFileRequest; + getData(): Uint8Array | string; + getData_asU8(): Uint8Array; + getData_asB64(): string; + setData(value: Uint8Array | string): PutFileRequest; + + getMetadataMap(): jspb.Map; + clearMetadataMap(): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): PutFileRequest.AsObject; + static toObject(includeInstance: boolean, msg: PutFileRequest): PutFileRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: PutFileRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): PutFileRequest; + static deserializeBinaryFromReader(message: PutFileRequest, reader: jspb.BinaryReader): PutFileRequest; +} + +export namespace PutFileRequest { + export type AsObject = { + storeName: string, + name: string, + data: Uint8Array | string, + + metadataMap: Array<[string, string]>, + } +} + +export class FileRequest extends jspb.Message { + getStoreName(): string; + setStoreName(value: string): FileRequest; + getName(): string; + setName(value: string): FileRequest; + + getMetadataMap(): jspb.Map; + clearMetadataMap(): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): FileRequest.AsObject; + static toObject(includeInstance: boolean, msg: FileRequest): FileRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: FileRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): FileRequest; + static deserializeBinaryFromReader(message: FileRequest, reader: jspb.BinaryReader): FileRequest; +} + +export namespace FileRequest { + export type AsObject = { + storeName: string, + name: string, + + metadataMap: Array<[string, string]>, + } +} + +export class ListFileRequest extends jspb.Message { + + hasRequest(): boolean; + clearRequest(): void; + getRequest(): FileRequest | undefined; + setRequest(value?: FileRequest): ListFileRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ListFileRequest.AsObject; + static toObject(includeInstance: boolean, msg: ListFileRequest): ListFileRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: ListFileRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ListFileRequest; + static deserializeBinaryFromReader(message: ListFileRequest, reader: jspb.BinaryReader): ListFileRequest; +} + +export namespace ListFileRequest { + export type AsObject = { + request?: FileRequest.AsObject, + } +} + +export class ListFileResp extends jspb.Message { + clearFileNameList(): void; + getFileNameList(): Array; + setFileNameList(value: Array): ListFileResp; + addFileName(value: string, index?: number): string; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ListFileResp.AsObject; + static toObject(includeInstance: boolean, msg: ListFileResp): ListFileResp.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: ListFileResp, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ListFileResp; + static deserializeBinaryFromReader(message: ListFileResp, reader: jspb.BinaryReader): ListFileResp; +} + +export namespace ListFileResp { + export type AsObject = { + fileNameList: Array, + } +} + +export class DelFileRequest extends jspb.Message { + + hasRequest(): boolean; + clearRequest(): void; + getRequest(): FileRequest | undefined; + setRequest(value?: FileRequest): DelFileRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): DelFileRequest.AsObject; + static toObject(includeInstance: boolean, msg: DelFileRequest): DelFileRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: DelFileRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): DelFileRequest; + static deserializeBinaryFromReader(message: DelFileRequest, reader: jspb.BinaryReader): DelFileRequest; +} + +export namespace DelFileRequest { + export type AsObject = { + request?: FileRequest.AsObject, + } +} + +export class GetNextIdRequest extends jspb.Message { + getStoreName(): string; + setStoreName(value: string): GetNextIdRequest; + getKey(): string; + setKey(value: string): GetNextIdRequest; + + hasOptions(): boolean; + clearOptions(): void; + getOptions(): SequencerOptions | undefined; + setOptions(value?: SequencerOptions): GetNextIdRequest; + + getMetadataMap(): jspb.Map; + clearMetadataMap(): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetNextIdRequest.AsObject; + static toObject(includeInstance: boolean, msg: GetNextIdRequest): GetNextIdRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetNextIdRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetNextIdRequest; + static deserializeBinaryFromReader(message: GetNextIdRequest, reader: jspb.BinaryReader): GetNextIdRequest; +} + +export namespace GetNextIdRequest { + export type AsObject = { + storeName: string, + key: string, + options?: SequencerOptions.AsObject, + + metadataMap: Array<[string, string]>, + } +} + +export class SequencerOptions extends jspb.Message { + getIncrement(): SequencerOptions.AutoIncrement; + setIncrement(value: SequencerOptions.AutoIncrement): SequencerOptions; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): SequencerOptions.AsObject; + static toObject(includeInstance: boolean, msg: SequencerOptions): SequencerOptions.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: SequencerOptions, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): SequencerOptions; + static deserializeBinaryFromReader(message: SequencerOptions, reader: jspb.BinaryReader): SequencerOptions; +} + +export namespace SequencerOptions { + export type AsObject = { + increment: SequencerOptions.AutoIncrement, + } + + export enum AutoIncrement { + WEAK = 0, + STRONG = 1, + } + +} + +export class GetNextIdResponse extends jspb.Message { + getNextId(): number; + setNextId(value: number): GetNextIdResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetNextIdResponse.AsObject; + static toObject(includeInstance: boolean, msg: GetNextIdResponse): GetNextIdResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetNextIdResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetNextIdResponse; + static deserializeBinaryFromReader(message: GetNextIdResponse, reader: jspb.BinaryReader): GetNextIdResponse; +} + +export namespace GetNextIdResponse { + export type AsObject = { + nextId: number, + } +} + +export class TryLockRequest extends jspb.Message { + getStoreName(): string; + setStoreName(value: string): TryLockRequest; + getResourceId(): string; + setResourceId(value: string): TryLockRequest; + getLockOwner(): string; + setLockOwner(value: string): TryLockRequest; + getExpire(): number; + setExpire(value: number): TryLockRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): TryLockRequest.AsObject; + static toObject(includeInstance: boolean, msg: TryLockRequest): TryLockRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: TryLockRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): TryLockRequest; + static deserializeBinaryFromReader(message: TryLockRequest, reader: jspb.BinaryReader): TryLockRequest; +} + +export namespace TryLockRequest { + export type AsObject = { + storeName: string, + resourceId: string, + lockOwner: string, + expire: number, + } +} + +export class TryLockResponse extends jspb.Message { + getSuccess(): boolean; + setSuccess(value: boolean): TryLockResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): TryLockResponse.AsObject; + static toObject(includeInstance: boolean, msg: TryLockResponse): TryLockResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: TryLockResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): TryLockResponse; + static deserializeBinaryFromReader(message: TryLockResponse, reader: jspb.BinaryReader): TryLockResponse; +} + +export namespace TryLockResponse { + export type AsObject = { + success: boolean, + } +} + +export class UnlockRequest extends jspb.Message { + getStoreName(): string; + setStoreName(value: string): UnlockRequest; + getResourceId(): string; + setResourceId(value: string): UnlockRequest; + getLockOwner(): string; + setLockOwner(value: string): UnlockRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UnlockRequest.AsObject; + static toObject(includeInstance: boolean, msg: UnlockRequest): UnlockRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: UnlockRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UnlockRequest; + static deserializeBinaryFromReader(message: UnlockRequest, reader: jspb.BinaryReader): UnlockRequest; +} + +export namespace UnlockRequest { + export type AsObject = { + storeName: string, + resourceId: string, + lockOwner: string, + } +} + +export class UnlockResponse extends jspb.Message { + getStatus(): UnlockResponse.Status; + setStatus(value: UnlockResponse.Status): UnlockResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UnlockResponse.AsObject; + static toObject(includeInstance: boolean, msg: UnlockResponse): UnlockResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: UnlockResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UnlockResponse; + static deserializeBinaryFromReader(message: UnlockResponse, reader: jspb.BinaryReader): UnlockResponse; +} + +export namespace UnlockResponse { + export type AsObject = { + status: UnlockResponse.Status, + } + + export enum Status { + SUCCESS = 0, + LOCK_UNEXIST = 1, + LOCK_BELONG_TO_OTHERS = 2, + INTERNAL_ERROR = 3, + } + +} + +export class SayHelloRequest extends jspb.Message { + getServiceName(): string; + setServiceName(value: string): SayHelloRequest; + getName(): string; + setName(value: string): SayHelloRequest; + + hasData(): boolean; + clearData(): void; + getData(): google_protobuf_any_pb.Any | undefined; + setData(value?: google_protobuf_any_pb.Any): SayHelloRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): SayHelloRequest.AsObject; + static toObject(includeInstance: boolean, msg: SayHelloRequest): SayHelloRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: SayHelloRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): SayHelloRequest; + static deserializeBinaryFromReader(message: SayHelloRequest, reader: jspb.BinaryReader): SayHelloRequest; +} + +export namespace SayHelloRequest { + export type AsObject = { + serviceName: string, + name: string, + data?: google_protobuf_any_pb.Any.AsObject, + } +} + +export class SayHelloResponse extends jspb.Message { + getHello(): string; + setHello(value: string): SayHelloResponse; + + hasData(): boolean; + clearData(): void; + getData(): google_protobuf_any_pb.Any | undefined; + setData(value?: google_protobuf_any_pb.Any): SayHelloResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): SayHelloResponse.AsObject; + static toObject(includeInstance: boolean, msg: SayHelloResponse): SayHelloResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: SayHelloResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): SayHelloResponse; + static deserializeBinaryFromReader(message: SayHelloResponse, reader: jspb.BinaryReader): SayHelloResponse; +} + +export namespace SayHelloResponse { + export type AsObject = { + hello: string, + data?: google_protobuf_any_pb.Any.AsObject, + } +} + +export class InvokeServiceRequest extends jspb.Message { + getId(): string; + setId(value: string): InvokeServiceRequest; + + hasMessage(): boolean; + clearMessage(): void; + getMessage(): CommonInvokeRequest | undefined; + setMessage(value?: CommonInvokeRequest): InvokeServiceRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): InvokeServiceRequest.AsObject; + static toObject(includeInstance: boolean, msg: InvokeServiceRequest): InvokeServiceRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: InvokeServiceRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): InvokeServiceRequest; + static deserializeBinaryFromReader(message: InvokeServiceRequest, reader: jspb.BinaryReader): InvokeServiceRequest; +} + +export namespace InvokeServiceRequest { + export type AsObject = { + id: string, + message?: CommonInvokeRequest.AsObject, + } +} + +export class CommonInvokeRequest extends jspb.Message { + getMethod(): string; + setMethod(value: string): CommonInvokeRequest; + + hasData(): boolean; + clearData(): void; + getData(): google_protobuf_any_pb.Any | undefined; + setData(value?: google_protobuf_any_pb.Any): CommonInvokeRequest; + getContentType(): string; + setContentType(value: string): CommonInvokeRequest; + + hasHttpExtension(): boolean; + clearHttpExtension(): void; + getHttpExtension(): HTTPExtension | undefined; + setHttpExtension(value?: HTTPExtension): CommonInvokeRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): CommonInvokeRequest.AsObject; + static toObject(includeInstance: boolean, msg: CommonInvokeRequest): CommonInvokeRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: CommonInvokeRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): CommonInvokeRequest; + static deserializeBinaryFromReader(message: CommonInvokeRequest, reader: jspb.BinaryReader): CommonInvokeRequest; +} + +export namespace CommonInvokeRequest { + export type AsObject = { + method: string, + data?: google_protobuf_any_pb.Any.AsObject, + contentType: string, + httpExtension?: HTTPExtension.AsObject, + } +} + +export class HTTPExtension extends jspb.Message { + getVerb(): HTTPExtension.Verb; + setVerb(value: HTTPExtension.Verb): HTTPExtension; + getQuerystring(): string; + setQuerystring(value: string): HTTPExtension; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): HTTPExtension.AsObject; + static toObject(includeInstance: boolean, msg: HTTPExtension): HTTPExtension.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: HTTPExtension, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): HTTPExtension; + static deserializeBinaryFromReader(message: HTTPExtension, reader: jspb.BinaryReader): HTTPExtension; +} + +export namespace HTTPExtension { + export type AsObject = { + verb: HTTPExtension.Verb, + querystring: string, + } + + export enum Verb { + NONE = 0, + GET = 1, + HEAD = 2, + POST = 3, + PUT = 4, + DELETE = 5, + CONNECT = 6, + OPTIONS = 7, + TRACE = 8, + } + +} + +export class InvokeResponse extends jspb.Message { + + hasData(): boolean; + clearData(): void; + getData(): google_protobuf_any_pb.Any | undefined; + setData(value?: google_protobuf_any_pb.Any): InvokeResponse; + getContentType(): string; + setContentType(value: string): InvokeResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): InvokeResponse.AsObject; + static toObject(includeInstance: boolean, msg: InvokeResponse): InvokeResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: InvokeResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): InvokeResponse; + static deserializeBinaryFromReader(message: InvokeResponse, reader: jspb.BinaryReader): InvokeResponse; +} + +export namespace InvokeResponse { + export type AsObject = { + data?: google_protobuf_any_pb.Any.AsObject, + contentType: string, + } +} + +export class ConfigurationItem extends jspb.Message { + getKey(): string; + setKey(value: string): ConfigurationItem; + getContent(): string; + setContent(value: string): ConfigurationItem; + getGroup(): string; + setGroup(value: string): ConfigurationItem; + getLabel(): string; + setLabel(value: string): ConfigurationItem; + + getTagsMap(): jspb.Map; + clearTagsMap(): void; + + getMetadataMap(): jspb.Map; + clearMetadataMap(): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ConfigurationItem.AsObject; + static toObject(includeInstance: boolean, msg: ConfigurationItem): ConfigurationItem.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: ConfigurationItem, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ConfigurationItem; + static deserializeBinaryFromReader(message: ConfigurationItem, reader: jspb.BinaryReader): ConfigurationItem; +} + +export namespace ConfigurationItem { + export type AsObject = { + key: string, + content: string, + group: string, + label: string, + + tagsMap: Array<[string, string]>, + + metadataMap: Array<[string, string]>, + } +} + +export class GetConfigurationRequest extends jspb.Message { + getStoreName(): string; + setStoreName(value: string): GetConfigurationRequest; + getAppId(): string; + setAppId(value: string): GetConfigurationRequest; + getGroup(): string; + setGroup(value: string): GetConfigurationRequest; + getLabel(): string; + setLabel(value: string): GetConfigurationRequest; + clearKeysList(): void; + getKeysList(): Array; + setKeysList(value: Array): GetConfigurationRequest; + addKeys(value: string, index?: number): string; + + getMetadataMap(): jspb.Map; + clearMetadataMap(): void; + getSubscribeUpdate(): boolean; + setSubscribeUpdate(value: boolean): GetConfigurationRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetConfigurationRequest.AsObject; + static toObject(includeInstance: boolean, msg: GetConfigurationRequest): GetConfigurationRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetConfigurationRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetConfigurationRequest; + static deserializeBinaryFromReader(message: GetConfigurationRequest, reader: jspb.BinaryReader): GetConfigurationRequest; +} + +export namespace GetConfigurationRequest { + export type AsObject = { + storeName: string, + appId: string, + group: string, + label: string, + keysList: Array, + + metadataMap: Array<[string, string]>, + subscribeUpdate: boolean, + } +} + +export class GetConfigurationResponse extends jspb.Message { + clearItemsList(): void; + getItemsList(): Array; + setItemsList(value: Array): GetConfigurationResponse; + addItems(value?: ConfigurationItem, index?: number): ConfigurationItem; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetConfigurationResponse.AsObject; + static toObject(includeInstance: boolean, msg: GetConfigurationResponse): GetConfigurationResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetConfigurationResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetConfigurationResponse; + static deserializeBinaryFromReader(message: GetConfigurationResponse, reader: jspb.BinaryReader): GetConfigurationResponse; +} + +export namespace GetConfigurationResponse { + export type AsObject = { + itemsList: Array, + } +} + +export class SubscribeConfigurationRequest extends jspb.Message { + getStoreName(): string; + setStoreName(value: string): SubscribeConfigurationRequest; + getAppId(): string; + setAppId(value: string): SubscribeConfigurationRequest; + getGroup(): string; + setGroup(value: string): SubscribeConfigurationRequest; + getLabel(): string; + setLabel(value: string): SubscribeConfigurationRequest; + clearKeysList(): void; + getKeysList(): Array; + setKeysList(value: Array): SubscribeConfigurationRequest; + addKeys(value: string, index?: number): string; + + getMetadataMap(): jspb.Map; + clearMetadataMap(): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): SubscribeConfigurationRequest.AsObject; + static toObject(includeInstance: boolean, msg: SubscribeConfigurationRequest): SubscribeConfigurationRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: SubscribeConfigurationRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): SubscribeConfigurationRequest; + static deserializeBinaryFromReader(message: SubscribeConfigurationRequest, reader: jspb.BinaryReader): SubscribeConfigurationRequest; +} + +export namespace SubscribeConfigurationRequest { + export type AsObject = { + storeName: string, + appId: string, + group: string, + label: string, + keysList: Array, + + metadataMap: Array<[string, string]>, + } +} + +export class SubscribeConfigurationResponse extends jspb.Message { + getStoreName(): string; + setStoreName(value: string): SubscribeConfigurationResponse; + getAppId(): string; + setAppId(value: string): SubscribeConfigurationResponse; + clearItemsList(): void; + getItemsList(): Array; + setItemsList(value: Array): SubscribeConfigurationResponse; + addItems(value?: ConfigurationItem, index?: number): ConfigurationItem; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): SubscribeConfigurationResponse.AsObject; + static toObject(includeInstance: boolean, msg: SubscribeConfigurationResponse): SubscribeConfigurationResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: SubscribeConfigurationResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): SubscribeConfigurationResponse; + static deserializeBinaryFromReader(message: SubscribeConfigurationResponse, reader: jspb.BinaryReader): SubscribeConfigurationResponse; +} + +export namespace SubscribeConfigurationResponse { + export type AsObject = { + storeName: string, + appId: string, + itemsList: Array, + } +} + +export class SaveConfigurationRequest extends jspb.Message { + getStoreName(): string; + setStoreName(value: string): SaveConfigurationRequest; + getAppId(): string; + setAppId(value: string): SaveConfigurationRequest; + clearItemsList(): void; + getItemsList(): Array; + setItemsList(value: Array): SaveConfigurationRequest; + addItems(value?: ConfigurationItem, index?: number): ConfigurationItem; + + getMetadataMap(): jspb.Map; + clearMetadataMap(): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): SaveConfigurationRequest.AsObject; + static toObject(includeInstance: boolean, msg: SaveConfigurationRequest): SaveConfigurationRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: SaveConfigurationRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): SaveConfigurationRequest; + static deserializeBinaryFromReader(message: SaveConfigurationRequest, reader: jspb.BinaryReader): SaveConfigurationRequest; +} + +export namespace SaveConfigurationRequest { + export type AsObject = { + storeName: string, + appId: string, + itemsList: Array, + + metadataMap: Array<[string, string]>, + } +} + +export class DeleteConfigurationRequest extends jspb.Message { + getStoreName(): string; + setStoreName(value: string): DeleteConfigurationRequest; + getAppId(): string; + setAppId(value: string): DeleteConfigurationRequest; + getGroup(): string; + setGroup(value: string): DeleteConfigurationRequest; + getLabel(): string; + setLabel(value: string): DeleteConfigurationRequest; + clearKeysList(): void; + getKeysList(): Array; + setKeysList(value: Array): DeleteConfigurationRequest; + addKeys(value: string, index?: number): string; + + getMetadataMap(): jspb.Map; + clearMetadataMap(): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): DeleteConfigurationRequest.AsObject; + static toObject(includeInstance: boolean, msg: DeleteConfigurationRequest): DeleteConfigurationRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: DeleteConfigurationRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): DeleteConfigurationRequest; + static deserializeBinaryFromReader(message: DeleteConfigurationRequest, reader: jspb.BinaryReader): DeleteConfigurationRequest; +} + +export namespace DeleteConfigurationRequest { + export type AsObject = { + storeName: string, + appId: string, + group: string, + label: string, + keysList: Array, + + metadataMap: Array<[string, string]>, + } +} + +export class GetStateRequest extends jspb.Message { + getStoreName(): string; + setStoreName(value: string): GetStateRequest; + getKey(): string; + setKey(value: string): GetStateRequest; + getConsistency(): StateOptions.StateConsistency; + setConsistency(value: StateOptions.StateConsistency): GetStateRequest; + + getMetadataMap(): jspb.Map; + clearMetadataMap(): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetStateRequest.AsObject; + static toObject(includeInstance: boolean, msg: GetStateRequest): GetStateRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetStateRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetStateRequest; + static deserializeBinaryFromReader(message: GetStateRequest, reader: jspb.BinaryReader): GetStateRequest; +} + +export namespace GetStateRequest { + export type AsObject = { + storeName: string, + key: string, + consistency: StateOptions.StateConsistency, + + metadataMap: Array<[string, string]>, + } +} + +export class GetBulkStateRequest extends jspb.Message { + getStoreName(): string; + setStoreName(value: string): GetBulkStateRequest; + clearKeysList(): void; + getKeysList(): Array; + setKeysList(value: Array): GetBulkStateRequest; + addKeys(value: string, index?: number): string; + getParallelism(): number; + setParallelism(value: number): GetBulkStateRequest; + + getMetadataMap(): jspb.Map; + clearMetadataMap(): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetBulkStateRequest.AsObject; + static toObject(includeInstance: boolean, msg: GetBulkStateRequest): GetBulkStateRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetBulkStateRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetBulkStateRequest; + static deserializeBinaryFromReader(message: GetBulkStateRequest, reader: jspb.BinaryReader): GetBulkStateRequest; +} + +export namespace GetBulkStateRequest { + export type AsObject = { + storeName: string, + keysList: Array, + parallelism: number, + + metadataMap: Array<[string, string]>, + } +} + +export class GetBulkStateResponse extends jspb.Message { + clearItemsList(): void; + getItemsList(): Array; + setItemsList(value: Array): GetBulkStateResponse; + addItems(value?: BulkStateItem, index?: number): BulkStateItem; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetBulkStateResponse.AsObject; + static toObject(includeInstance: boolean, msg: GetBulkStateResponse): GetBulkStateResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetBulkStateResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetBulkStateResponse; + static deserializeBinaryFromReader(message: GetBulkStateResponse, reader: jspb.BinaryReader): GetBulkStateResponse; +} + +export namespace GetBulkStateResponse { + export type AsObject = { + itemsList: Array, + } +} + +export class BulkStateItem extends jspb.Message { + getKey(): string; + setKey(value: string): BulkStateItem; + getData(): Uint8Array | string; + getData_asU8(): Uint8Array; + getData_asB64(): string; + setData(value: Uint8Array | string): BulkStateItem; + getEtag(): string; + setEtag(value: string): BulkStateItem; + getError(): string; + setError(value: string): BulkStateItem; + + getMetadataMap(): jspb.Map; + clearMetadataMap(): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): BulkStateItem.AsObject; + static toObject(includeInstance: boolean, msg: BulkStateItem): BulkStateItem.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: BulkStateItem, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): BulkStateItem; + static deserializeBinaryFromReader(message: BulkStateItem, reader: jspb.BinaryReader): BulkStateItem; +} + +export namespace BulkStateItem { + export type AsObject = { + key: string, + data: Uint8Array | string, + etag: string, + error: string, + + metadataMap: Array<[string, string]>, + } +} + +export class GetStateResponse extends jspb.Message { + getData(): Uint8Array | string; + getData_asU8(): Uint8Array; + getData_asB64(): string; + setData(value: Uint8Array | string): GetStateResponse; + getEtag(): string; + setEtag(value: string): GetStateResponse; + + getMetadataMap(): jspb.Map; + clearMetadataMap(): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetStateResponse.AsObject; + static toObject(includeInstance: boolean, msg: GetStateResponse): GetStateResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetStateResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetStateResponse; + static deserializeBinaryFromReader(message: GetStateResponse, reader: jspb.BinaryReader): GetStateResponse; +} + +export namespace GetStateResponse { + export type AsObject = { + data: Uint8Array | string, + etag: string, + + metadataMap: Array<[string, string]>, + } +} + +export class DeleteStateRequest extends jspb.Message { + getStoreName(): string; + setStoreName(value: string): DeleteStateRequest; + getKey(): string; + setKey(value: string): DeleteStateRequest; + + hasEtag(): boolean; + clearEtag(): void; + getEtag(): Etag | undefined; + setEtag(value?: Etag): DeleteStateRequest; + + hasOptions(): boolean; + clearOptions(): void; + getOptions(): StateOptions | undefined; + setOptions(value?: StateOptions): DeleteStateRequest; + + getMetadataMap(): jspb.Map; + clearMetadataMap(): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): DeleteStateRequest.AsObject; + static toObject(includeInstance: boolean, msg: DeleteStateRequest): DeleteStateRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: DeleteStateRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): DeleteStateRequest; + static deserializeBinaryFromReader(message: DeleteStateRequest, reader: jspb.BinaryReader): DeleteStateRequest; +} + +export namespace DeleteStateRequest { + export type AsObject = { + storeName: string, + key: string, + etag?: Etag.AsObject, + options?: StateOptions.AsObject, + + metadataMap: Array<[string, string]>, + } +} + +export class DeleteBulkStateRequest extends jspb.Message { + getStoreName(): string; + setStoreName(value: string): DeleteBulkStateRequest; + clearStatesList(): void; + getStatesList(): Array; + setStatesList(value: Array): DeleteBulkStateRequest; + addStates(value?: StateItem, index?: number): StateItem; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): DeleteBulkStateRequest.AsObject; + static toObject(includeInstance: boolean, msg: DeleteBulkStateRequest): DeleteBulkStateRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: DeleteBulkStateRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): DeleteBulkStateRequest; + static deserializeBinaryFromReader(message: DeleteBulkStateRequest, reader: jspb.BinaryReader): DeleteBulkStateRequest; +} + +export namespace DeleteBulkStateRequest { + export type AsObject = { + storeName: string, + statesList: Array, + } +} + +export class SaveStateRequest extends jspb.Message { + getStoreName(): string; + setStoreName(value: string): SaveStateRequest; + clearStatesList(): void; + getStatesList(): Array; + setStatesList(value: Array): SaveStateRequest; + addStates(value?: StateItem, index?: number): StateItem; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): SaveStateRequest.AsObject; + static toObject(includeInstance: boolean, msg: SaveStateRequest): SaveStateRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: SaveStateRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): SaveStateRequest; + static deserializeBinaryFromReader(message: SaveStateRequest, reader: jspb.BinaryReader): SaveStateRequest; +} + +export namespace SaveStateRequest { + export type AsObject = { + storeName: string, + statesList: Array, + } +} + +export class StateItem extends jspb.Message { + getKey(): string; + setKey(value: string): StateItem; + getValue(): Uint8Array | string; + getValue_asU8(): Uint8Array; + getValue_asB64(): string; + setValue(value: Uint8Array | string): StateItem; + + hasEtag(): boolean; + clearEtag(): void; + getEtag(): Etag | undefined; + setEtag(value?: Etag): StateItem; + + getMetadataMap(): jspb.Map; + clearMetadataMap(): void; + + hasOptions(): boolean; + clearOptions(): void; + getOptions(): StateOptions | undefined; + setOptions(value?: StateOptions): StateItem; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): StateItem.AsObject; + static toObject(includeInstance: boolean, msg: StateItem): StateItem.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: StateItem, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): StateItem; + static deserializeBinaryFromReader(message: StateItem, reader: jspb.BinaryReader): StateItem; +} + +export namespace StateItem { + export type AsObject = { + key: string, + value: Uint8Array | string, + etag?: Etag.AsObject, + + metadataMap: Array<[string, string]>, + options?: StateOptions.AsObject, + } +} + +export class Etag extends jspb.Message { + getValue(): string; + setValue(value: string): Etag; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): Etag.AsObject; + static toObject(includeInstance: boolean, msg: Etag): Etag.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: Etag, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): Etag; + static deserializeBinaryFromReader(message: Etag, reader: jspb.BinaryReader): Etag; +} + +export namespace Etag { + export type AsObject = { + value: string, + } +} + +export class StateOptions extends jspb.Message { + getConcurrency(): StateOptions.StateConcurrency; + setConcurrency(value: StateOptions.StateConcurrency): StateOptions; + getConsistency(): StateOptions.StateConsistency; + setConsistency(value: StateOptions.StateConsistency): StateOptions; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): StateOptions.AsObject; + static toObject(includeInstance: boolean, msg: StateOptions): StateOptions.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: StateOptions, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): StateOptions; + static deserializeBinaryFromReader(message: StateOptions, reader: jspb.BinaryReader): StateOptions; +} + +export namespace StateOptions { + export type AsObject = { + concurrency: StateOptions.StateConcurrency, + consistency: StateOptions.StateConsistency, + } + + export enum StateConcurrency { + CONCURRENCY_UNSPECIFIED = 0, + CONCURRENCY_FIRST_WRITE = 1, + CONCURRENCY_LAST_WRITE = 2, + } + + export enum StateConsistency { + CONSISTENCY_UNSPECIFIED = 0, + CONSISTENCY_EVENTUAL = 1, + CONSISTENCY_STRONG = 2, + } + +} + +export class TransactionalStateOperation extends jspb.Message { + getOperationtype(): string; + setOperationtype(value: string): TransactionalStateOperation; + + hasRequest(): boolean; + clearRequest(): void; + getRequest(): StateItem | undefined; + setRequest(value?: StateItem): TransactionalStateOperation; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): TransactionalStateOperation.AsObject; + static toObject(includeInstance: boolean, msg: TransactionalStateOperation): TransactionalStateOperation.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: TransactionalStateOperation, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): TransactionalStateOperation; + static deserializeBinaryFromReader(message: TransactionalStateOperation, reader: jspb.BinaryReader): TransactionalStateOperation; +} + +export namespace TransactionalStateOperation { + export type AsObject = { + operationtype: string, + request?: StateItem.AsObject, + } +} + +export class ExecuteStateTransactionRequest extends jspb.Message { + getStorename(): string; + setStorename(value: string): ExecuteStateTransactionRequest; + clearOperationsList(): void; + getOperationsList(): Array; + setOperationsList(value: Array): ExecuteStateTransactionRequest; + addOperations(value?: TransactionalStateOperation, index?: number): TransactionalStateOperation; + + getMetadataMap(): jspb.Map; + clearMetadataMap(): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ExecuteStateTransactionRequest.AsObject; + static toObject(includeInstance: boolean, msg: ExecuteStateTransactionRequest): ExecuteStateTransactionRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: ExecuteStateTransactionRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ExecuteStateTransactionRequest; + static deserializeBinaryFromReader(message: ExecuteStateTransactionRequest, reader: jspb.BinaryReader): ExecuteStateTransactionRequest; +} + +export namespace ExecuteStateTransactionRequest { + export type AsObject = { + storename: string, + operationsList: Array, + + metadataMap: Array<[string, string]>, + } +} + +export class PublishEventRequest extends jspb.Message { + getPubsubName(): string; + setPubsubName(value: string): PublishEventRequest; + getTopic(): string; + setTopic(value: string): PublishEventRequest; + getData(): Uint8Array | string; + getData_asU8(): Uint8Array; + getData_asB64(): string; + setData(value: Uint8Array | string): PublishEventRequest; + getDataContentType(): string; + setDataContentType(value: string): PublishEventRequest; + + getMetadataMap(): jspb.Map; + clearMetadataMap(): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): PublishEventRequest.AsObject; + static toObject(includeInstance: boolean, msg: PublishEventRequest): PublishEventRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: PublishEventRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): PublishEventRequest; + static deserializeBinaryFromReader(message: PublishEventRequest, reader: jspb.BinaryReader): PublishEventRequest; +} + +export namespace PublishEventRequest { + export type AsObject = { + pubsubName: string, + topic: string, + data: Uint8Array | string, + dataContentType: string, + + metadataMap: Array<[string, string]>, + } +} + +export class InvokeBindingRequest extends jspb.Message { + getName(): string; + setName(value: string): InvokeBindingRequest; + getData(): Uint8Array | string; + getData_asU8(): Uint8Array; + getData_asB64(): string; + setData(value: Uint8Array | string): InvokeBindingRequest; + + getMetadataMap(): jspb.Map; + clearMetadataMap(): void; + getOperation(): string; + setOperation(value: string): InvokeBindingRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): InvokeBindingRequest.AsObject; + static toObject(includeInstance: boolean, msg: InvokeBindingRequest): InvokeBindingRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: InvokeBindingRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): InvokeBindingRequest; + static deserializeBinaryFromReader(message: InvokeBindingRequest, reader: jspb.BinaryReader): InvokeBindingRequest; +} + +export namespace InvokeBindingRequest { + export type AsObject = { + name: string, + data: Uint8Array | string, + + metadataMap: Array<[string, string]>, + operation: string, + } +} + +export class InvokeBindingResponse extends jspb.Message { + getData(): Uint8Array | string; + getData_asU8(): Uint8Array; + getData_asB64(): string; + setData(value: Uint8Array | string): InvokeBindingResponse; + + getMetadataMap(): jspb.Map; + clearMetadataMap(): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): InvokeBindingResponse.AsObject; + static toObject(includeInstance: boolean, msg: InvokeBindingResponse): InvokeBindingResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: InvokeBindingResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): InvokeBindingResponse; + static deserializeBinaryFromReader(message: InvokeBindingResponse, reader: jspb.BinaryReader): InvokeBindingResponse; +} + +export namespace InvokeBindingResponse { + export type AsObject = { + data: Uint8Array | string, + + metadataMap: Array<[string, string]>, + } +} diff --git a/sdk/js-sdk/proto/runtime_pb.js b/sdk/js-sdk/proto/runtime_pb.js new file mode 100644 index 0000000000..db7edb7018 --- /dev/null +++ b/sdk/js-sdk/proto/runtime_pb.js @@ -0,0 +1,10020 @@ +// source: runtime.proto +/** + * @fileoverview + * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = Function('return this')(); + +var google_protobuf_empty_pb = require('google-protobuf/google/protobuf/empty_pb.js'); +goog.object.extend(proto, google_protobuf_empty_pb); +var google_protobuf_any_pb = require('google-protobuf/google/protobuf/any_pb.js'); +goog.object.extend(proto, google_protobuf_any_pb); +goog.exportSymbol('proto.spec.proto.runtime.v1.BulkStateItem', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.CommonInvokeRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.ConfigurationItem', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.DelFileRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.DeleteBulkStateRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.DeleteConfigurationRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.DeleteStateRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.Etag', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.FileRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.GetBulkStateRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.GetBulkStateResponse', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.GetConfigurationRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.GetConfigurationResponse', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.GetFileRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.GetFileResponse', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.GetNextIdRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.GetNextIdResponse', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.GetStateRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.GetStateResponse', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.HTTPExtension', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.HTTPExtension.Verb', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.InvokeBindingRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.InvokeBindingResponse', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.InvokeResponse', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.InvokeServiceRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.ListFileRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.ListFileResp', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.PublishEventRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.PutFileRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.SaveConfigurationRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.SaveStateRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.SayHelloRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.SayHelloResponse', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.SequencerOptions', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.SequencerOptions.AutoIncrement', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.StateItem', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.StateOptions', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.StateOptions.StateConcurrency', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.StateOptions.StateConsistency', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.SubscribeConfigurationRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.SubscribeConfigurationResponse', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.TransactionalStateOperation', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.TryLockRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.TryLockResponse', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.UnlockRequest', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.UnlockResponse', null, global); +goog.exportSymbol('proto.spec.proto.runtime.v1.UnlockResponse.Status', null, global); +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.GetFileRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.GetFileRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.GetFileRequest.displayName = 'proto.spec.proto.runtime.v1.GetFileRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.GetFileResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.GetFileResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.GetFileResponse.displayName = 'proto.spec.proto.runtime.v1.GetFileResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.PutFileRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.PutFileRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.PutFileRequest.displayName = 'proto.spec.proto.runtime.v1.PutFileRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.FileRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.FileRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.FileRequest.displayName = 'proto.spec.proto.runtime.v1.FileRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.ListFileRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.ListFileRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.ListFileRequest.displayName = 'proto.spec.proto.runtime.v1.ListFileRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.ListFileResp = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.spec.proto.runtime.v1.ListFileResp.repeatedFields_, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.ListFileResp, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.ListFileResp.displayName = 'proto.spec.proto.runtime.v1.ListFileResp'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.DelFileRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.DelFileRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.DelFileRequest.displayName = 'proto.spec.proto.runtime.v1.DelFileRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.GetNextIdRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.GetNextIdRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.GetNextIdRequest.displayName = 'proto.spec.proto.runtime.v1.GetNextIdRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.SequencerOptions = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.SequencerOptions, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.SequencerOptions.displayName = 'proto.spec.proto.runtime.v1.SequencerOptions'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.GetNextIdResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.GetNextIdResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.GetNextIdResponse.displayName = 'proto.spec.proto.runtime.v1.GetNextIdResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.TryLockRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.TryLockRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.TryLockRequest.displayName = 'proto.spec.proto.runtime.v1.TryLockRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.TryLockResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.TryLockResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.TryLockResponse.displayName = 'proto.spec.proto.runtime.v1.TryLockResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.UnlockRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.UnlockRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.UnlockRequest.displayName = 'proto.spec.proto.runtime.v1.UnlockRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.UnlockResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.UnlockResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.UnlockResponse.displayName = 'proto.spec.proto.runtime.v1.UnlockResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.SayHelloRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.SayHelloRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.SayHelloRequest.displayName = 'proto.spec.proto.runtime.v1.SayHelloRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.SayHelloResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.SayHelloResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.SayHelloResponse.displayName = 'proto.spec.proto.runtime.v1.SayHelloResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.InvokeServiceRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.InvokeServiceRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.InvokeServiceRequest.displayName = 'proto.spec.proto.runtime.v1.InvokeServiceRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.CommonInvokeRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.CommonInvokeRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.CommonInvokeRequest.displayName = 'proto.spec.proto.runtime.v1.CommonInvokeRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.HTTPExtension = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.HTTPExtension, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.HTTPExtension.displayName = 'proto.spec.proto.runtime.v1.HTTPExtension'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.InvokeResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.InvokeResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.InvokeResponse.displayName = 'proto.spec.proto.runtime.v1.InvokeResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.ConfigurationItem = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.ConfigurationItem, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.ConfigurationItem.displayName = 'proto.spec.proto.runtime.v1.ConfigurationItem'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.spec.proto.runtime.v1.GetConfigurationRequest.repeatedFields_, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.GetConfigurationRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.GetConfigurationRequest.displayName = 'proto.spec.proto.runtime.v1.GetConfigurationRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.GetConfigurationResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.spec.proto.runtime.v1.GetConfigurationResponse.repeatedFields_, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.GetConfigurationResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.GetConfigurationResponse.displayName = 'proto.spec.proto.runtime.v1.GetConfigurationResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.repeatedFields_, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.SubscribeConfigurationRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.displayName = 'proto.spec.proto.runtime.v1.SubscribeConfigurationRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.spec.proto.runtime.v1.SubscribeConfigurationResponse.repeatedFields_, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.SubscribeConfigurationResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.SubscribeConfigurationResponse.displayName = 'proto.spec.proto.runtime.v1.SubscribeConfigurationResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.SaveConfigurationRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.spec.proto.runtime.v1.SaveConfigurationRequest.repeatedFields_, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.SaveConfigurationRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.SaveConfigurationRequest.displayName = 'proto.spec.proto.runtime.v1.SaveConfigurationRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.spec.proto.runtime.v1.DeleteConfigurationRequest.repeatedFields_, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.DeleteConfigurationRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.DeleteConfigurationRequest.displayName = 'proto.spec.proto.runtime.v1.DeleteConfigurationRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.GetStateRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.GetStateRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.GetStateRequest.displayName = 'proto.spec.proto.runtime.v1.GetStateRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.GetBulkStateRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.spec.proto.runtime.v1.GetBulkStateRequest.repeatedFields_, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.GetBulkStateRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.GetBulkStateRequest.displayName = 'proto.spec.proto.runtime.v1.GetBulkStateRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.GetBulkStateResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.spec.proto.runtime.v1.GetBulkStateResponse.repeatedFields_, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.GetBulkStateResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.GetBulkStateResponse.displayName = 'proto.spec.proto.runtime.v1.GetBulkStateResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.BulkStateItem = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.BulkStateItem, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.BulkStateItem.displayName = 'proto.spec.proto.runtime.v1.BulkStateItem'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.GetStateResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.GetStateResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.GetStateResponse.displayName = 'proto.spec.proto.runtime.v1.GetStateResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.DeleteStateRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.DeleteStateRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.DeleteStateRequest.displayName = 'proto.spec.proto.runtime.v1.DeleteStateRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.DeleteBulkStateRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.spec.proto.runtime.v1.DeleteBulkStateRequest.repeatedFields_, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.DeleteBulkStateRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.DeleteBulkStateRequest.displayName = 'proto.spec.proto.runtime.v1.DeleteBulkStateRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.SaveStateRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.spec.proto.runtime.v1.SaveStateRequest.repeatedFields_, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.SaveStateRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.SaveStateRequest.displayName = 'proto.spec.proto.runtime.v1.SaveStateRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.StateItem = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.StateItem, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.StateItem.displayName = 'proto.spec.proto.runtime.v1.StateItem'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.Etag = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.Etag, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.Etag.displayName = 'proto.spec.proto.runtime.v1.Etag'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.StateOptions = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.StateOptions, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.StateOptions.displayName = 'proto.spec.proto.runtime.v1.StateOptions'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.TransactionalStateOperation = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.TransactionalStateOperation, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.TransactionalStateOperation.displayName = 'proto.spec.proto.runtime.v1.TransactionalStateOperation'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest.repeatedFields_, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest.displayName = 'proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.PublishEventRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.PublishEventRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.PublishEventRequest.displayName = 'proto.spec.proto.runtime.v1.PublishEventRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.InvokeBindingRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.InvokeBindingRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.InvokeBindingRequest.displayName = 'proto.spec.proto.runtime.v1.InvokeBindingRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spec.proto.runtime.v1.InvokeBindingResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spec.proto.runtime.v1.InvokeBindingResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spec.proto.runtime.v1.InvokeBindingResponse.displayName = 'proto.spec.proto.runtime.v1.InvokeBindingResponse'; +} + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.GetFileRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.GetFileRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.GetFileRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.GetFileRequest.toObject = function(includeInstance, msg) { + var f, obj = { + storeName: jspb.Message.getFieldWithDefault(msg, 1, ""), + name: jspb.Message.getFieldWithDefault(msg, 2, ""), + metadataMap: (f = msg.getMetadataMap()) ? f.toObject(includeInstance, undefined) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.GetFileRequest} + */ +proto.spec.proto.runtime.v1.GetFileRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.GetFileRequest; + return proto.spec.proto.runtime.v1.GetFileRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.GetFileRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.GetFileRequest} + */ +proto.spec.proto.runtime.v1.GetFileRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStoreName(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setName(value); + break; + case 3: + var value = msg.getMetadataMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.GetFileRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.GetFileRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.GetFileRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.GetFileRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStoreName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getName(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getMetadataMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(3, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } +}; + + +/** + * optional string store_name = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.GetFileRequest.prototype.getStoreName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.GetFileRequest} returns this + */ +proto.spec.proto.runtime.v1.GetFileRequest.prototype.setStoreName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string name = 2; + * @return {string} + */ +proto.spec.proto.runtime.v1.GetFileRequest.prototype.getName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.GetFileRequest} returns this + */ +proto.spec.proto.runtime.v1.GetFileRequest.prototype.setName = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * map metadata = 3; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.spec.proto.runtime.v1.GetFileRequest.prototype.getMetadataMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 3, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.spec.proto.runtime.v1.GetFileRequest} returns this + */ +proto.spec.proto.runtime.v1.GetFileRequest.prototype.clearMetadataMap = function() { + this.getMetadataMap().clear(); + return this;}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.GetFileResponse.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.GetFileResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.GetFileResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.GetFileResponse.toObject = function(includeInstance, msg) { + var f, obj = { + data: msg.getData_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.GetFileResponse} + */ +proto.spec.proto.runtime.v1.GetFileResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.GetFileResponse; + return proto.spec.proto.runtime.v1.GetFileResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.GetFileResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.GetFileResponse} + */ +proto.spec.proto.runtime.v1.GetFileResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setData(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.GetFileResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.GetFileResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.GetFileResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.GetFileResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getData_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } +}; + + +/** + * optional bytes data = 1; + * @return {!(string|Uint8Array)} + */ +proto.spec.proto.runtime.v1.GetFileResponse.prototype.getData = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes data = 1; + * This is a type-conversion wrapper around `getData()` + * @return {string} + */ +proto.spec.proto.runtime.v1.GetFileResponse.prototype.getData_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getData())); +}; + + +/** + * optional bytes data = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getData()` + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.GetFileResponse.prototype.getData_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getData())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.spec.proto.runtime.v1.GetFileResponse} returns this + */ +proto.spec.proto.runtime.v1.GetFileResponse.prototype.setData = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.PutFileRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.PutFileRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.PutFileRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.PutFileRequest.toObject = function(includeInstance, msg) { + var f, obj = { + storeName: jspb.Message.getFieldWithDefault(msg, 1, ""), + name: jspb.Message.getFieldWithDefault(msg, 2, ""), + data: msg.getData_asB64(), + metadataMap: (f = msg.getMetadataMap()) ? f.toObject(includeInstance, undefined) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.PutFileRequest} + */ +proto.spec.proto.runtime.v1.PutFileRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.PutFileRequest; + return proto.spec.proto.runtime.v1.PutFileRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.PutFileRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.PutFileRequest} + */ +proto.spec.proto.runtime.v1.PutFileRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStoreName(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setName(value); + break; + case 3: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setData(value); + break; + case 4: + var value = msg.getMetadataMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.PutFileRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.PutFileRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.PutFileRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.PutFileRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStoreName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getName(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getData_asU8(); + if (f.length > 0) { + writer.writeBytes( + 3, + f + ); + } + f = message.getMetadataMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(4, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } +}; + + +/** + * optional string store_name = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.PutFileRequest.prototype.getStoreName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.PutFileRequest} returns this + */ +proto.spec.proto.runtime.v1.PutFileRequest.prototype.setStoreName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string name = 2; + * @return {string} + */ +proto.spec.proto.runtime.v1.PutFileRequest.prototype.getName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.PutFileRequest} returns this + */ +proto.spec.proto.runtime.v1.PutFileRequest.prototype.setName = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional bytes data = 3; + * @return {!(string|Uint8Array)} + */ +proto.spec.proto.runtime.v1.PutFileRequest.prototype.getData = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * optional bytes data = 3; + * This is a type-conversion wrapper around `getData()` + * @return {string} + */ +proto.spec.proto.runtime.v1.PutFileRequest.prototype.getData_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getData())); +}; + + +/** + * optional bytes data = 3; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getData()` + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.PutFileRequest.prototype.getData_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getData())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.spec.proto.runtime.v1.PutFileRequest} returns this + */ +proto.spec.proto.runtime.v1.PutFileRequest.prototype.setData = function(value) { + return jspb.Message.setProto3BytesField(this, 3, value); +}; + + +/** + * map metadata = 4; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.spec.proto.runtime.v1.PutFileRequest.prototype.getMetadataMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 4, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.spec.proto.runtime.v1.PutFileRequest} returns this + */ +proto.spec.proto.runtime.v1.PutFileRequest.prototype.clearMetadataMap = function() { + this.getMetadataMap().clear(); + return this;}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.FileRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.FileRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.FileRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.FileRequest.toObject = function(includeInstance, msg) { + var f, obj = { + storeName: jspb.Message.getFieldWithDefault(msg, 1, ""), + name: jspb.Message.getFieldWithDefault(msg, 2, ""), + metadataMap: (f = msg.getMetadataMap()) ? f.toObject(includeInstance, undefined) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.FileRequest} + */ +proto.spec.proto.runtime.v1.FileRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.FileRequest; + return proto.spec.proto.runtime.v1.FileRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.FileRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.FileRequest} + */ +proto.spec.proto.runtime.v1.FileRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStoreName(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setName(value); + break; + case 3: + var value = msg.getMetadataMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.FileRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.FileRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.FileRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.FileRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStoreName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getName(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getMetadataMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(3, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } +}; + + +/** + * optional string store_name = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.FileRequest.prototype.getStoreName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.FileRequest} returns this + */ +proto.spec.proto.runtime.v1.FileRequest.prototype.setStoreName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string name = 2; + * @return {string} + */ +proto.spec.proto.runtime.v1.FileRequest.prototype.getName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.FileRequest} returns this + */ +proto.spec.proto.runtime.v1.FileRequest.prototype.setName = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * map metadata = 3; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.spec.proto.runtime.v1.FileRequest.prototype.getMetadataMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 3, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.spec.proto.runtime.v1.FileRequest} returns this + */ +proto.spec.proto.runtime.v1.FileRequest.prototype.clearMetadataMap = function() { + this.getMetadataMap().clear(); + return this;}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.ListFileRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.ListFileRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.ListFileRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.ListFileRequest.toObject = function(includeInstance, msg) { + var f, obj = { + request: (f = msg.getRequest()) && proto.spec.proto.runtime.v1.FileRequest.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.ListFileRequest} + */ +proto.spec.proto.runtime.v1.ListFileRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.ListFileRequest; + return proto.spec.proto.runtime.v1.ListFileRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.ListFileRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.ListFileRequest} + */ +proto.spec.proto.runtime.v1.ListFileRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.spec.proto.runtime.v1.FileRequest; + reader.readMessage(value,proto.spec.proto.runtime.v1.FileRequest.deserializeBinaryFromReader); + msg.setRequest(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.ListFileRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.ListFileRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.ListFileRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.ListFileRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getRequest(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.spec.proto.runtime.v1.FileRequest.serializeBinaryToWriter + ); + } +}; + + +/** + * optional FileRequest request = 1; + * @return {?proto.spec.proto.runtime.v1.FileRequest} + */ +proto.spec.proto.runtime.v1.ListFileRequest.prototype.getRequest = function() { + return /** @type{?proto.spec.proto.runtime.v1.FileRequest} */ ( + jspb.Message.getWrapperField(this, proto.spec.proto.runtime.v1.FileRequest, 1)); +}; + + +/** + * @param {?proto.spec.proto.runtime.v1.FileRequest|undefined} value + * @return {!proto.spec.proto.runtime.v1.ListFileRequest} returns this +*/ +proto.spec.proto.runtime.v1.ListFileRequest.prototype.setRequest = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.spec.proto.runtime.v1.ListFileRequest} returns this + */ +proto.spec.proto.runtime.v1.ListFileRequest.prototype.clearRequest = function() { + return this.setRequest(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.spec.proto.runtime.v1.ListFileRequest.prototype.hasRequest = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.spec.proto.runtime.v1.ListFileResp.repeatedFields_ = [1]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.ListFileResp.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.ListFileResp.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.ListFileResp} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.ListFileResp.toObject = function(includeInstance, msg) { + var f, obj = { + fileNameList: (f = jspb.Message.getRepeatedField(msg, 1)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.ListFileResp} + */ +proto.spec.proto.runtime.v1.ListFileResp.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.ListFileResp; + return proto.spec.proto.runtime.v1.ListFileResp.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.ListFileResp} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.ListFileResp} + */ +proto.spec.proto.runtime.v1.ListFileResp.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.addFileName(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.ListFileResp.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.ListFileResp.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.ListFileResp} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.ListFileResp.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getFileNameList(); + if (f.length > 0) { + writer.writeRepeatedString( + 1, + f + ); + } +}; + + +/** + * repeated string file_name = 1; + * @return {!Array} + */ +proto.spec.proto.runtime.v1.ListFileResp.prototype.getFileNameList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); +}; + + +/** + * @param {!Array} value + * @return {!proto.spec.proto.runtime.v1.ListFileResp} returns this + */ +proto.spec.proto.runtime.v1.ListFileResp.prototype.setFileNameList = function(value) { + return jspb.Message.setField(this, 1, value || []); +}; + + +/** + * @param {string} value + * @param {number=} opt_index + * @return {!proto.spec.proto.runtime.v1.ListFileResp} returns this + */ +proto.spec.proto.runtime.v1.ListFileResp.prototype.addFileName = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 1, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.spec.proto.runtime.v1.ListFileResp} returns this + */ +proto.spec.proto.runtime.v1.ListFileResp.prototype.clearFileNameList = function() { + return this.setFileNameList([]); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.DelFileRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.DelFileRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.DelFileRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.DelFileRequest.toObject = function(includeInstance, msg) { + var f, obj = { + request: (f = msg.getRequest()) && proto.spec.proto.runtime.v1.FileRequest.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.DelFileRequest} + */ +proto.spec.proto.runtime.v1.DelFileRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.DelFileRequest; + return proto.spec.proto.runtime.v1.DelFileRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.DelFileRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.DelFileRequest} + */ +proto.spec.proto.runtime.v1.DelFileRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.spec.proto.runtime.v1.FileRequest; + reader.readMessage(value,proto.spec.proto.runtime.v1.FileRequest.deserializeBinaryFromReader); + msg.setRequest(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.DelFileRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.DelFileRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.DelFileRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.DelFileRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getRequest(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.spec.proto.runtime.v1.FileRequest.serializeBinaryToWriter + ); + } +}; + + +/** + * optional FileRequest request = 1; + * @return {?proto.spec.proto.runtime.v1.FileRequest} + */ +proto.spec.proto.runtime.v1.DelFileRequest.prototype.getRequest = function() { + return /** @type{?proto.spec.proto.runtime.v1.FileRequest} */ ( + jspb.Message.getWrapperField(this, proto.spec.proto.runtime.v1.FileRequest, 1)); +}; + + +/** + * @param {?proto.spec.proto.runtime.v1.FileRequest|undefined} value + * @return {!proto.spec.proto.runtime.v1.DelFileRequest} returns this +*/ +proto.spec.proto.runtime.v1.DelFileRequest.prototype.setRequest = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.spec.proto.runtime.v1.DelFileRequest} returns this + */ +proto.spec.proto.runtime.v1.DelFileRequest.prototype.clearRequest = function() { + return this.setRequest(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.spec.proto.runtime.v1.DelFileRequest.prototype.hasRequest = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.GetNextIdRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.GetNextIdRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.GetNextIdRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.GetNextIdRequest.toObject = function(includeInstance, msg) { + var f, obj = { + storeName: jspb.Message.getFieldWithDefault(msg, 1, ""), + key: jspb.Message.getFieldWithDefault(msg, 2, ""), + options: (f = msg.getOptions()) && proto.spec.proto.runtime.v1.SequencerOptions.toObject(includeInstance, f), + metadataMap: (f = msg.getMetadataMap()) ? f.toObject(includeInstance, undefined) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.GetNextIdRequest} + */ +proto.spec.proto.runtime.v1.GetNextIdRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.GetNextIdRequest; + return proto.spec.proto.runtime.v1.GetNextIdRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.GetNextIdRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.GetNextIdRequest} + */ +proto.spec.proto.runtime.v1.GetNextIdRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStoreName(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setKey(value); + break; + case 3: + var value = new proto.spec.proto.runtime.v1.SequencerOptions; + reader.readMessage(value,proto.spec.proto.runtime.v1.SequencerOptions.deserializeBinaryFromReader); + msg.setOptions(value); + break; + case 4: + var value = msg.getMetadataMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.GetNextIdRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.GetNextIdRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.GetNextIdRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.GetNextIdRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStoreName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getKey(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getOptions(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.spec.proto.runtime.v1.SequencerOptions.serializeBinaryToWriter + ); + } + f = message.getMetadataMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(4, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } +}; + + +/** + * optional string store_name = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.GetNextIdRequest.prototype.getStoreName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.GetNextIdRequest} returns this + */ +proto.spec.proto.runtime.v1.GetNextIdRequest.prototype.setStoreName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string key = 2; + * @return {string} + */ +proto.spec.proto.runtime.v1.GetNextIdRequest.prototype.getKey = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.GetNextIdRequest} returns this + */ +proto.spec.proto.runtime.v1.GetNextIdRequest.prototype.setKey = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional SequencerOptions options = 3; + * @return {?proto.spec.proto.runtime.v1.SequencerOptions} + */ +proto.spec.proto.runtime.v1.GetNextIdRequest.prototype.getOptions = function() { + return /** @type{?proto.spec.proto.runtime.v1.SequencerOptions} */ ( + jspb.Message.getWrapperField(this, proto.spec.proto.runtime.v1.SequencerOptions, 3)); +}; + + +/** + * @param {?proto.spec.proto.runtime.v1.SequencerOptions|undefined} value + * @return {!proto.spec.proto.runtime.v1.GetNextIdRequest} returns this +*/ +proto.spec.proto.runtime.v1.GetNextIdRequest.prototype.setOptions = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.spec.proto.runtime.v1.GetNextIdRequest} returns this + */ +proto.spec.proto.runtime.v1.GetNextIdRequest.prototype.clearOptions = function() { + return this.setOptions(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.spec.proto.runtime.v1.GetNextIdRequest.prototype.hasOptions = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * map metadata = 4; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.spec.proto.runtime.v1.GetNextIdRequest.prototype.getMetadataMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 4, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.spec.proto.runtime.v1.GetNextIdRequest} returns this + */ +proto.spec.proto.runtime.v1.GetNextIdRequest.prototype.clearMetadataMap = function() { + this.getMetadataMap().clear(); + return this;}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.SequencerOptions.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.SequencerOptions.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.SequencerOptions} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.SequencerOptions.toObject = function(includeInstance, msg) { + var f, obj = { + increment: jspb.Message.getFieldWithDefault(msg, 1, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.SequencerOptions} + */ +proto.spec.proto.runtime.v1.SequencerOptions.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.SequencerOptions; + return proto.spec.proto.runtime.v1.SequencerOptions.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.SequencerOptions} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.SequencerOptions} + */ +proto.spec.proto.runtime.v1.SequencerOptions.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!proto.spec.proto.runtime.v1.SequencerOptions.AutoIncrement} */ (reader.readEnum()); + msg.setIncrement(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.SequencerOptions.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.SequencerOptions.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.SequencerOptions} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.SequencerOptions.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getIncrement(); + if (f !== 0.0) { + writer.writeEnum( + 1, + f + ); + } +}; + + +/** + * @enum {number} + */ +proto.spec.proto.runtime.v1.SequencerOptions.AutoIncrement = { + WEAK: 0, + STRONG: 1 +}; + +/** + * optional AutoIncrement increment = 1; + * @return {!proto.spec.proto.runtime.v1.SequencerOptions.AutoIncrement} + */ +proto.spec.proto.runtime.v1.SequencerOptions.prototype.getIncrement = function() { + return /** @type {!proto.spec.proto.runtime.v1.SequencerOptions.AutoIncrement} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {!proto.spec.proto.runtime.v1.SequencerOptions.AutoIncrement} value + * @return {!proto.spec.proto.runtime.v1.SequencerOptions} returns this + */ +proto.spec.proto.runtime.v1.SequencerOptions.prototype.setIncrement = function(value) { + return jspb.Message.setProto3EnumField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.GetNextIdResponse.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.GetNextIdResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.GetNextIdResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.GetNextIdResponse.toObject = function(includeInstance, msg) { + var f, obj = { + nextId: jspb.Message.getFieldWithDefault(msg, 1, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.GetNextIdResponse} + */ +proto.spec.proto.runtime.v1.GetNextIdResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.GetNextIdResponse; + return proto.spec.proto.runtime.v1.GetNextIdResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.GetNextIdResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.GetNextIdResponse} + */ +proto.spec.proto.runtime.v1.GetNextIdResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt64()); + msg.setNextId(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.GetNextIdResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.GetNextIdResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.GetNextIdResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.GetNextIdResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getNextId(); + if (f !== 0) { + writer.writeInt64( + 1, + f + ); + } +}; + + +/** + * optional int64 next_id = 1; + * @return {number} + */ +proto.spec.proto.runtime.v1.GetNextIdResponse.prototype.getNextId = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.spec.proto.runtime.v1.GetNextIdResponse} returns this + */ +proto.spec.proto.runtime.v1.GetNextIdResponse.prototype.setNextId = function(value) { + return jspb.Message.setProto3IntField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.TryLockRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.TryLockRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.TryLockRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.TryLockRequest.toObject = function(includeInstance, msg) { + var f, obj = { + storeName: jspb.Message.getFieldWithDefault(msg, 1, ""), + resourceId: jspb.Message.getFieldWithDefault(msg, 2, ""), + lockOwner: jspb.Message.getFieldWithDefault(msg, 3, ""), + expire: jspb.Message.getFieldWithDefault(msg, 4, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.TryLockRequest} + */ +proto.spec.proto.runtime.v1.TryLockRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.TryLockRequest; + return proto.spec.proto.runtime.v1.TryLockRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.TryLockRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.TryLockRequest} + */ +proto.spec.proto.runtime.v1.TryLockRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStoreName(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setResourceId(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setLockOwner(value); + break; + case 4: + var value = /** @type {number} */ (reader.readInt32()); + msg.setExpire(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.TryLockRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.TryLockRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.TryLockRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.TryLockRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStoreName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getResourceId(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getLockOwner(); + if (f.length > 0) { + writer.writeString( + 3, + f + ); + } + f = message.getExpire(); + if (f !== 0) { + writer.writeInt32( + 4, + f + ); + } +}; + + +/** + * optional string store_name = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.TryLockRequest.prototype.getStoreName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.TryLockRequest} returns this + */ +proto.spec.proto.runtime.v1.TryLockRequest.prototype.setStoreName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string resource_id = 2; + * @return {string} + */ +proto.spec.proto.runtime.v1.TryLockRequest.prototype.getResourceId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.TryLockRequest} returns this + */ +proto.spec.proto.runtime.v1.TryLockRequest.prototype.setResourceId = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional string lock_owner = 3; + * @return {string} + */ +proto.spec.proto.runtime.v1.TryLockRequest.prototype.getLockOwner = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.TryLockRequest} returns this + */ +proto.spec.proto.runtime.v1.TryLockRequest.prototype.setLockOwner = function(value) { + return jspb.Message.setProto3StringField(this, 3, value); +}; + + +/** + * optional int32 expire = 4; + * @return {number} + */ +proto.spec.proto.runtime.v1.TryLockRequest.prototype.getExpire = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.spec.proto.runtime.v1.TryLockRequest} returns this + */ +proto.spec.proto.runtime.v1.TryLockRequest.prototype.setExpire = function(value) { + return jspb.Message.setProto3IntField(this, 4, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.TryLockResponse.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.TryLockResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.TryLockResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.TryLockResponse.toObject = function(includeInstance, msg) { + var f, obj = { + success: jspb.Message.getBooleanFieldWithDefault(msg, 1, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.TryLockResponse} + */ +proto.spec.proto.runtime.v1.TryLockResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.TryLockResponse; + return proto.spec.proto.runtime.v1.TryLockResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.TryLockResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.TryLockResponse} + */ +proto.spec.proto.runtime.v1.TryLockResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setSuccess(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.TryLockResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.TryLockResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.TryLockResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.TryLockResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getSuccess(); + if (f) { + writer.writeBool( + 1, + f + ); + } +}; + + +/** + * optional bool success = 1; + * @return {boolean} + */ +proto.spec.proto.runtime.v1.TryLockResponse.prototype.getSuccess = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 1, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.spec.proto.runtime.v1.TryLockResponse} returns this + */ +proto.spec.proto.runtime.v1.TryLockResponse.prototype.setSuccess = function(value) { + return jspb.Message.setProto3BooleanField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.UnlockRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.UnlockRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.UnlockRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.UnlockRequest.toObject = function(includeInstance, msg) { + var f, obj = { + storeName: jspb.Message.getFieldWithDefault(msg, 1, ""), + resourceId: jspb.Message.getFieldWithDefault(msg, 2, ""), + lockOwner: jspb.Message.getFieldWithDefault(msg, 3, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.UnlockRequest} + */ +proto.spec.proto.runtime.v1.UnlockRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.UnlockRequest; + return proto.spec.proto.runtime.v1.UnlockRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.UnlockRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.UnlockRequest} + */ +proto.spec.proto.runtime.v1.UnlockRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStoreName(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setResourceId(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setLockOwner(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.UnlockRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.UnlockRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.UnlockRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.UnlockRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStoreName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getResourceId(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getLockOwner(); + if (f.length > 0) { + writer.writeString( + 3, + f + ); + } +}; + + +/** + * optional string store_name = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.UnlockRequest.prototype.getStoreName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.UnlockRequest} returns this + */ +proto.spec.proto.runtime.v1.UnlockRequest.prototype.setStoreName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string resource_id = 2; + * @return {string} + */ +proto.spec.proto.runtime.v1.UnlockRequest.prototype.getResourceId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.UnlockRequest} returns this + */ +proto.spec.proto.runtime.v1.UnlockRequest.prototype.setResourceId = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional string lock_owner = 3; + * @return {string} + */ +proto.spec.proto.runtime.v1.UnlockRequest.prototype.getLockOwner = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.UnlockRequest} returns this + */ +proto.spec.proto.runtime.v1.UnlockRequest.prototype.setLockOwner = function(value) { + return jspb.Message.setProto3StringField(this, 3, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.UnlockResponse.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.UnlockResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.UnlockResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.UnlockResponse.toObject = function(includeInstance, msg) { + var f, obj = { + status: jspb.Message.getFieldWithDefault(msg, 1, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.UnlockResponse} + */ +proto.spec.proto.runtime.v1.UnlockResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.UnlockResponse; + return proto.spec.proto.runtime.v1.UnlockResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.UnlockResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.UnlockResponse} + */ +proto.spec.proto.runtime.v1.UnlockResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!proto.spec.proto.runtime.v1.UnlockResponse.Status} */ (reader.readEnum()); + msg.setStatus(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.UnlockResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.UnlockResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.UnlockResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.UnlockResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStatus(); + if (f !== 0.0) { + writer.writeEnum( + 1, + f + ); + } +}; + + +/** + * @enum {number} + */ +proto.spec.proto.runtime.v1.UnlockResponse.Status = { + SUCCESS: 0, + LOCK_UNEXIST: 1, + LOCK_BELONG_TO_OTHERS: 2, + INTERNAL_ERROR: 3 +}; + +/** + * optional Status status = 1; + * @return {!proto.spec.proto.runtime.v1.UnlockResponse.Status} + */ +proto.spec.proto.runtime.v1.UnlockResponse.prototype.getStatus = function() { + return /** @type {!proto.spec.proto.runtime.v1.UnlockResponse.Status} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {!proto.spec.proto.runtime.v1.UnlockResponse.Status} value + * @return {!proto.spec.proto.runtime.v1.UnlockResponse} returns this + */ +proto.spec.proto.runtime.v1.UnlockResponse.prototype.setStatus = function(value) { + return jspb.Message.setProto3EnumField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.SayHelloRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.SayHelloRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.SayHelloRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.SayHelloRequest.toObject = function(includeInstance, msg) { + var f, obj = { + serviceName: jspb.Message.getFieldWithDefault(msg, 1, ""), + name: jspb.Message.getFieldWithDefault(msg, 2, ""), + data: (f = msg.getData()) && google_protobuf_any_pb.Any.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.SayHelloRequest} + */ +proto.spec.proto.runtime.v1.SayHelloRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.SayHelloRequest; + return proto.spec.proto.runtime.v1.SayHelloRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.SayHelloRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.SayHelloRequest} + */ +proto.spec.proto.runtime.v1.SayHelloRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setServiceName(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setName(value); + break; + case 3: + var value = new google_protobuf_any_pb.Any; + reader.readMessage(value,google_protobuf_any_pb.Any.deserializeBinaryFromReader); + msg.setData(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.SayHelloRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.SayHelloRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.SayHelloRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.SayHelloRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getServiceName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getName(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getData(); + if (f != null) { + writer.writeMessage( + 3, + f, + google_protobuf_any_pb.Any.serializeBinaryToWriter + ); + } +}; + + +/** + * optional string service_name = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.SayHelloRequest.prototype.getServiceName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.SayHelloRequest} returns this + */ +proto.spec.proto.runtime.v1.SayHelloRequest.prototype.setServiceName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string name = 2; + * @return {string} + */ +proto.spec.proto.runtime.v1.SayHelloRequest.prototype.getName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.SayHelloRequest} returns this + */ +proto.spec.proto.runtime.v1.SayHelloRequest.prototype.setName = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional google.protobuf.Any data = 3; + * @return {?proto.google.protobuf.Any} + */ +proto.spec.proto.runtime.v1.SayHelloRequest.prototype.getData = function() { + return /** @type{?proto.google.protobuf.Any} */ ( + jspb.Message.getWrapperField(this, google_protobuf_any_pb.Any, 3)); +}; + + +/** + * @param {?proto.google.protobuf.Any|undefined} value + * @return {!proto.spec.proto.runtime.v1.SayHelloRequest} returns this +*/ +proto.spec.proto.runtime.v1.SayHelloRequest.prototype.setData = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.spec.proto.runtime.v1.SayHelloRequest} returns this + */ +proto.spec.proto.runtime.v1.SayHelloRequest.prototype.clearData = function() { + return this.setData(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.spec.proto.runtime.v1.SayHelloRequest.prototype.hasData = function() { + return jspb.Message.getField(this, 3) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.SayHelloResponse.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.SayHelloResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.SayHelloResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.SayHelloResponse.toObject = function(includeInstance, msg) { + var f, obj = { + hello: jspb.Message.getFieldWithDefault(msg, 1, ""), + data: (f = msg.getData()) && google_protobuf_any_pb.Any.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.SayHelloResponse} + */ +proto.spec.proto.runtime.v1.SayHelloResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.SayHelloResponse; + return proto.spec.proto.runtime.v1.SayHelloResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.SayHelloResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.SayHelloResponse} + */ +proto.spec.proto.runtime.v1.SayHelloResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setHello(value); + break; + case 2: + var value = new google_protobuf_any_pb.Any; + reader.readMessage(value,google_protobuf_any_pb.Any.deserializeBinaryFromReader); + msg.setData(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.SayHelloResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.SayHelloResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.SayHelloResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.SayHelloResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getHello(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getData(); + if (f != null) { + writer.writeMessage( + 2, + f, + google_protobuf_any_pb.Any.serializeBinaryToWriter + ); + } +}; + + +/** + * optional string hello = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.SayHelloResponse.prototype.getHello = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.SayHelloResponse} returns this + */ +proto.spec.proto.runtime.v1.SayHelloResponse.prototype.setHello = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional google.protobuf.Any data = 2; + * @return {?proto.google.protobuf.Any} + */ +proto.spec.proto.runtime.v1.SayHelloResponse.prototype.getData = function() { + return /** @type{?proto.google.protobuf.Any} */ ( + jspb.Message.getWrapperField(this, google_protobuf_any_pb.Any, 2)); +}; + + +/** + * @param {?proto.google.protobuf.Any|undefined} value + * @return {!proto.spec.proto.runtime.v1.SayHelloResponse} returns this +*/ +proto.spec.proto.runtime.v1.SayHelloResponse.prototype.setData = function(value) { + return jspb.Message.setWrapperField(this, 2, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.spec.proto.runtime.v1.SayHelloResponse} returns this + */ +proto.spec.proto.runtime.v1.SayHelloResponse.prototype.clearData = function() { + return this.setData(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.spec.proto.runtime.v1.SayHelloResponse.prototype.hasData = function() { + return jspb.Message.getField(this, 2) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.InvokeServiceRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.InvokeServiceRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.InvokeServiceRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.InvokeServiceRequest.toObject = function(includeInstance, msg) { + var f, obj = { + id: jspb.Message.getFieldWithDefault(msg, 1, ""), + message: (f = msg.getMessage()) && proto.spec.proto.runtime.v1.CommonInvokeRequest.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.InvokeServiceRequest} + */ +proto.spec.proto.runtime.v1.InvokeServiceRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.InvokeServiceRequest; + return proto.spec.proto.runtime.v1.InvokeServiceRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.InvokeServiceRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.InvokeServiceRequest} + */ +proto.spec.proto.runtime.v1.InvokeServiceRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setId(value); + break; + case 3: + var value = new proto.spec.proto.runtime.v1.CommonInvokeRequest; + reader.readMessage(value,proto.spec.proto.runtime.v1.CommonInvokeRequest.deserializeBinaryFromReader); + msg.setMessage(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.InvokeServiceRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.InvokeServiceRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.InvokeServiceRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.InvokeServiceRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getId(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getMessage(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.spec.proto.runtime.v1.CommonInvokeRequest.serializeBinaryToWriter + ); + } +}; + + +/** + * optional string id = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.InvokeServiceRequest.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.InvokeServiceRequest} returns this + */ +proto.spec.proto.runtime.v1.InvokeServiceRequest.prototype.setId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional CommonInvokeRequest message = 3; + * @return {?proto.spec.proto.runtime.v1.CommonInvokeRequest} + */ +proto.spec.proto.runtime.v1.InvokeServiceRequest.prototype.getMessage = function() { + return /** @type{?proto.spec.proto.runtime.v1.CommonInvokeRequest} */ ( + jspb.Message.getWrapperField(this, proto.spec.proto.runtime.v1.CommonInvokeRequest, 3)); +}; + + +/** + * @param {?proto.spec.proto.runtime.v1.CommonInvokeRequest|undefined} value + * @return {!proto.spec.proto.runtime.v1.InvokeServiceRequest} returns this +*/ +proto.spec.proto.runtime.v1.InvokeServiceRequest.prototype.setMessage = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.spec.proto.runtime.v1.InvokeServiceRequest} returns this + */ +proto.spec.proto.runtime.v1.InvokeServiceRequest.prototype.clearMessage = function() { + return this.setMessage(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.spec.proto.runtime.v1.InvokeServiceRequest.prototype.hasMessage = function() { + return jspb.Message.getField(this, 3) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.CommonInvokeRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.CommonInvokeRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.CommonInvokeRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.CommonInvokeRequest.toObject = function(includeInstance, msg) { + var f, obj = { + method: jspb.Message.getFieldWithDefault(msg, 1, ""), + data: (f = msg.getData()) && google_protobuf_any_pb.Any.toObject(includeInstance, f), + contentType: jspb.Message.getFieldWithDefault(msg, 3, ""), + httpExtension: (f = msg.getHttpExtension()) && proto.spec.proto.runtime.v1.HTTPExtension.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.CommonInvokeRequest} + */ +proto.spec.proto.runtime.v1.CommonInvokeRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.CommonInvokeRequest; + return proto.spec.proto.runtime.v1.CommonInvokeRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.CommonInvokeRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.CommonInvokeRequest} + */ +proto.spec.proto.runtime.v1.CommonInvokeRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setMethod(value); + break; + case 2: + var value = new google_protobuf_any_pb.Any; + reader.readMessage(value,google_protobuf_any_pb.Any.deserializeBinaryFromReader); + msg.setData(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setContentType(value); + break; + case 4: + var value = new proto.spec.proto.runtime.v1.HTTPExtension; + reader.readMessage(value,proto.spec.proto.runtime.v1.HTTPExtension.deserializeBinaryFromReader); + msg.setHttpExtension(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.CommonInvokeRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.CommonInvokeRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.CommonInvokeRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.CommonInvokeRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getMethod(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getData(); + if (f != null) { + writer.writeMessage( + 2, + f, + google_protobuf_any_pb.Any.serializeBinaryToWriter + ); + } + f = message.getContentType(); + if (f.length > 0) { + writer.writeString( + 3, + f + ); + } + f = message.getHttpExtension(); + if (f != null) { + writer.writeMessage( + 4, + f, + proto.spec.proto.runtime.v1.HTTPExtension.serializeBinaryToWriter + ); + } +}; + + +/** + * optional string method = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.CommonInvokeRequest.prototype.getMethod = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.CommonInvokeRequest} returns this + */ +proto.spec.proto.runtime.v1.CommonInvokeRequest.prototype.setMethod = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional google.protobuf.Any data = 2; + * @return {?proto.google.protobuf.Any} + */ +proto.spec.proto.runtime.v1.CommonInvokeRequest.prototype.getData = function() { + return /** @type{?proto.google.protobuf.Any} */ ( + jspb.Message.getWrapperField(this, google_protobuf_any_pb.Any, 2)); +}; + + +/** + * @param {?proto.google.protobuf.Any|undefined} value + * @return {!proto.spec.proto.runtime.v1.CommonInvokeRequest} returns this +*/ +proto.spec.proto.runtime.v1.CommonInvokeRequest.prototype.setData = function(value) { + return jspb.Message.setWrapperField(this, 2, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.spec.proto.runtime.v1.CommonInvokeRequest} returns this + */ +proto.spec.proto.runtime.v1.CommonInvokeRequest.prototype.clearData = function() { + return this.setData(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.spec.proto.runtime.v1.CommonInvokeRequest.prototype.hasData = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional string content_type = 3; + * @return {string} + */ +proto.spec.proto.runtime.v1.CommonInvokeRequest.prototype.getContentType = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.CommonInvokeRequest} returns this + */ +proto.spec.proto.runtime.v1.CommonInvokeRequest.prototype.setContentType = function(value) { + return jspb.Message.setProto3StringField(this, 3, value); +}; + + +/** + * optional HTTPExtension http_extension = 4; + * @return {?proto.spec.proto.runtime.v1.HTTPExtension} + */ +proto.spec.proto.runtime.v1.CommonInvokeRequest.prototype.getHttpExtension = function() { + return /** @type{?proto.spec.proto.runtime.v1.HTTPExtension} */ ( + jspb.Message.getWrapperField(this, proto.spec.proto.runtime.v1.HTTPExtension, 4)); +}; + + +/** + * @param {?proto.spec.proto.runtime.v1.HTTPExtension|undefined} value + * @return {!proto.spec.proto.runtime.v1.CommonInvokeRequest} returns this +*/ +proto.spec.proto.runtime.v1.CommonInvokeRequest.prototype.setHttpExtension = function(value) { + return jspb.Message.setWrapperField(this, 4, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.spec.proto.runtime.v1.CommonInvokeRequest} returns this + */ +proto.spec.proto.runtime.v1.CommonInvokeRequest.prototype.clearHttpExtension = function() { + return this.setHttpExtension(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.spec.proto.runtime.v1.CommonInvokeRequest.prototype.hasHttpExtension = function() { + return jspb.Message.getField(this, 4) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.HTTPExtension.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.HTTPExtension.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.HTTPExtension} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.HTTPExtension.toObject = function(includeInstance, msg) { + var f, obj = { + verb: jspb.Message.getFieldWithDefault(msg, 1, 0), + querystring: jspb.Message.getFieldWithDefault(msg, 2, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.HTTPExtension} + */ +proto.spec.proto.runtime.v1.HTTPExtension.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.HTTPExtension; + return proto.spec.proto.runtime.v1.HTTPExtension.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.HTTPExtension} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.HTTPExtension} + */ +proto.spec.proto.runtime.v1.HTTPExtension.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!proto.spec.proto.runtime.v1.HTTPExtension.Verb} */ (reader.readEnum()); + msg.setVerb(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setQuerystring(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.HTTPExtension.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.HTTPExtension.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.HTTPExtension} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.HTTPExtension.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getVerb(); + if (f !== 0.0) { + writer.writeEnum( + 1, + f + ); + } + f = message.getQuerystring(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } +}; + + +/** + * @enum {number} + */ +proto.spec.proto.runtime.v1.HTTPExtension.Verb = { + NONE: 0, + GET: 1, + HEAD: 2, + POST: 3, + PUT: 4, + DELETE: 5, + CONNECT: 6, + OPTIONS: 7, + TRACE: 8 +}; + +/** + * optional Verb verb = 1; + * @return {!proto.spec.proto.runtime.v1.HTTPExtension.Verb} + */ +proto.spec.proto.runtime.v1.HTTPExtension.prototype.getVerb = function() { + return /** @type {!proto.spec.proto.runtime.v1.HTTPExtension.Verb} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {!proto.spec.proto.runtime.v1.HTTPExtension.Verb} value + * @return {!proto.spec.proto.runtime.v1.HTTPExtension} returns this + */ +proto.spec.proto.runtime.v1.HTTPExtension.prototype.setVerb = function(value) { + return jspb.Message.setProto3EnumField(this, 1, value); +}; + + +/** + * optional string querystring = 2; + * @return {string} + */ +proto.spec.proto.runtime.v1.HTTPExtension.prototype.getQuerystring = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.HTTPExtension} returns this + */ +proto.spec.proto.runtime.v1.HTTPExtension.prototype.setQuerystring = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.InvokeResponse.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.InvokeResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.InvokeResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.InvokeResponse.toObject = function(includeInstance, msg) { + var f, obj = { + data: (f = msg.getData()) && google_protobuf_any_pb.Any.toObject(includeInstance, f), + contentType: jspb.Message.getFieldWithDefault(msg, 2, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.InvokeResponse} + */ +proto.spec.proto.runtime.v1.InvokeResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.InvokeResponse; + return proto.spec.proto.runtime.v1.InvokeResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.InvokeResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.InvokeResponse} + */ +proto.spec.proto.runtime.v1.InvokeResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new google_protobuf_any_pb.Any; + reader.readMessage(value,google_protobuf_any_pb.Any.deserializeBinaryFromReader); + msg.setData(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setContentType(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.InvokeResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.InvokeResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.InvokeResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.InvokeResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getData(); + if (f != null) { + writer.writeMessage( + 1, + f, + google_protobuf_any_pb.Any.serializeBinaryToWriter + ); + } + f = message.getContentType(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } +}; + + +/** + * optional google.protobuf.Any data = 1; + * @return {?proto.google.protobuf.Any} + */ +proto.spec.proto.runtime.v1.InvokeResponse.prototype.getData = function() { + return /** @type{?proto.google.protobuf.Any} */ ( + jspb.Message.getWrapperField(this, google_protobuf_any_pb.Any, 1)); +}; + + +/** + * @param {?proto.google.protobuf.Any|undefined} value + * @return {!proto.spec.proto.runtime.v1.InvokeResponse} returns this +*/ +proto.spec.proto.runtime.v1.InvokeResponse.prototype.setData = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.spec.proto.runtime.v1.InvokeResponse} returns this + */ +proto.spec.proto.runtime.v1.InvokeResponse.prototype.clearData = function() { + return this.setData(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.spec.proto.runtime.v1.InvokeResponse.prototype.hasData = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional string content_type = 2; + * @return {string} + */ +proto.spec.proto.runtime.v1.InvokeResponse.prototype.getContentType = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.InvokeResponse} returns this + */ +proto.spec.proto.runtime.v1.InvokeResponse.prototype.setContentType = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.ConfigurationItem.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.ConfigurationItem.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.ConfigurationItem} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.ConfigurationItem.toObject = function(includeInstance, msg) { + var f, obj = { + key: jspb.Message.getFieldWithDefault(msg, 1, ""), + content: jspb.Message.getFieldWithDefault(msg, 2, ""), + group: jspb.Message.getFieldWithDefault(msg, 3, ""), + label: jspb.Message.getFieldWithDefault(msg, 4, ""), + tagsMap: (f = msg.getTagsMap()) ? f.toObject(includeInstance, undefined) : [], + metadataMap: (f = msg.getMetadataMap()) ? f.toObject(includeInstance, undefined) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.ConfigurationItem} + */ +proto.spec.proto.runtime.v1.ConfigurationItem.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.ConfigurationItem; + return proto.spec.proto.runtime.v1.ConfigurationItem.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.ConfigurationItem} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.ConfigurationItem} + */ +proto.spec.proto.runtime.v1.ConfigurationItem.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setKey(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setContent(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setGroup(value); + break; + case 4: + var value = /** @type {string} */ (reader.readString()); + msg.setLabel(value); + break; + case 5: + var value = msg.getTagsMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + case 6: + var value = msg.getMetadataMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.ConfigurationItem.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.ConfigurationItem.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.ConfigurationItem} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.ConfigurationItem.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getKey(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getContent(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getGroup(); + if (f.length > 0) { + writer.writeString( + 3, + f + ); + } + f = message.getLabel(); + if (f.length > 0) { + writer.writeString( + 4, + f + ); + } + f = message.getTagsMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(5, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } + f = message.getMetadataMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(6, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } +}; + + +/** + * optional string key = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.ConfigurationItem.prototype.getKey = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.ConfigurationItem} returns this + */ +proto.spec.proto.runtime.v1.ConfigurationItem.prototype.setKey = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string content = 2; + * @return {string} + */ +proto.spec.proto.runtime.v1.ConfigurationItem.prototype.getContent = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.ConfigurationItem} returns this + */ +proto.spec.proto.runtime.v1.ConfigurationItem.prototype.setContent = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional string group = 3; + * @return {string} + */ +proto.spec.proto.runtime.v1.ConfigurationItem.prototype.getGroup = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.ConfigurationItem} returns this + */ +proto.spec.proto.runtime.v1.ConfigurationItem.prototype.setGroup = function(value) { + return jspb.Message.setProto3StringField(this, 3, value); +}; + + +/** + * optional string label = 4; + * @return {string} + */ +proto.spec.proto.runtime.v1.ConfigurationItem.prototype.getLabel = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.ConfigurationItem} returns this + */ +proto.spec.proto.runtime.v1.ConfigurationItem.prototype.setLabel = function(value) { + return jspb.Message.setProto3StringField(this, 4, value); +}; + + +/** + * map tags = 5; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.spec.proto.runtime.v1.ConfigurationItem.prototype.getTagsMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 5, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.spec.proto.runtime.v1.ConfigurationItem} returns this + */ +proto.spec.proto.runtime.v1.ConfigurationItem.prototype.clearTagsMap = function() { + this.getTagsMap().clear(); + return this;}; + + +/** + * map metadata = 6; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.spec.proto.runtime.v1.ConfigurationItem.prototype.getMetadataMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 6, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.spec.proto.runtime.v1.ConfigurationItem} returns this + */ +proto.spec.proto.runtime.v1.ConfigurationItem.prototype.clearMetadataMap = function() { + this.getMetadataMap().clear(); + return this;}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.repeatedFields_ = [5]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.GetConfigurationRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.GetConfigurationRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.toObject = function(includeInstance, msg) { + var f, obj = { + storeName: jspb.Message.getFieldWithDefault(msg, 1, ""), + appId: jspb.Message.getFieldWithDefault(msg, 2, ""), + group: jspb.Message.getFieldWithDefault(msg, 3, ""), + label: jspb.Message.getFieldWithDefault(msg, 4, ""), + keysList: (f = jspb.Message.getRepeatedField(msg, 5)) == null ? undefined : f, + metadataMap: (f = msg.getMetadataMap()) ? f.toObject(includeInstance, undefined) : [], + subscribeUpdate: jspb.Message.getBooleanFieldWithDefault(msg, 7, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.GetConfigurationRequest} + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.GetConfigurationRequest; + return proto.spec.proto.runtime.v1.GetConfigurationRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.GetConfigurationRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.GetConfigurationRequest} + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStoreName(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setAppId(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setGroup(value); + break; + case 4: + var value = /** @type {string} */ (reader.readString()); + msg.setLabel(value); + break; + case 5: + var value = /** @type {string} */ (reader.readString()); + msg.addKeys(value); + break; + case 6: + var value = msg.getMetadataMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + case 7: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setSubscribeUpdate(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.GetConfigurationRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.GetConfigurationRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStoreName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getAppId(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getGroup(); + if (f.length > 0) { + writer.writeString( + 3, + f + ); + } + f = message.getLabel(); + if (f.length > 0) { + writer.writeString( + 4, + f + ); + } + f = message.getKeysList(); + if (f.length > 0) { + writer.writeRepeatedString( + 5, + f + ); + } + f = message.getMetadataMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(6, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } + f = message.getSubscribeUpdate(); + if (f) { + writer.writeBool( + 7, + f + ); + } +}; + + +/** + * optional string store_name = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.prototype.getStoreName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.GetConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.prototype.setStoreName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string app_id = 2; + * @return {string} + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.prototype.getAppId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.GetConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.prototype.setAppId = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional string group = 3; + * @return {string} + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.prototype.getGroup = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.GetConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.prototype.setGroup = function(value) { + return jspb.Message.setProto3StringField(this, 3, value); +}; + + +/** + * optional string label = 4; + * @return {string} + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.prototype.getLabel = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.GetConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.prototype.setLabel = function(value) { + return jspb.Message.setProto3StringField(this, 4, value); +}; + + +/** + * repeated string keys = 5; + * @return {!Array} + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.prototype.getKeysList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 5)); +}; + + +/** + * @param {!Array} value + * @return {!proto.spec.proto.runtime.v1.GetConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.prototype.setKeysList = function(value) { + return jspb.Message.setField(this, 5, value || []); +}; + + +/** + * @param {string} value + * @param {number=} opt_index + * @return {!proto.spec.proto.runtime.v1.GetConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.prototype.addKeys = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 5, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.spec.proto.runtime.v1.GetConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.prototype.clearKeysList = function() { + return this.setKeysList([]); +}; + + +/** + * map metadata = 6; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.prototype.getMetadataMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 6, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.spec.proto.runtime.v1.GetConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.prototype.clearMetadataMap = function() { + this.getMetadataMap().clear(); + return this;}; + + +/** + * optional bool subscribe_update = 7; + * @return {boolean} + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.prototype.getSubscribeUpdate = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 7, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.spec.proto.runtime.v1.GetConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.GetConfigurationRequest.prototype.setSubscribeUpdate = function(value) { + return jspb.Message.setProto3BooleanField(this, 7, value); +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.spec.proto.runtime.v1.GetConfigurationResponse.repeatedFields_ = [1]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.GetConfigurationResponse.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.GetConfigurationResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.GetConfigurationResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.GetConfigurationResponse.toObject = function(includeInstance, msg) { + var f, obj = { + itemsList: jspb.Message.toObjectList(msg.getItemsList(), + proto.spec.proto.runtime.v1.ConfigurationItem.toObject, includeInstance) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.GetConfigurationResponse} + */ +proto.spec.proto.runtime.v1.GetConfigurationResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.GetConfigurationResponse; + return proto.spec.proto.runtime.v1.GetConfigurationResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.GetConfigurationResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.GetConfigurationResponse} + */ +proto.spec.proto.runtime.v1.GetConfigurationResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.spec.proto.runtime.v1.ConfigurationItem; + reader.readMessage(value,proto.spec.proto.runtime.v1.ConfigurationItem.deserializeBinaryFromReader); + msg.addItems(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.GetConfigurationResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.GetConfigurationResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.GetConfigurationResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.GetConfigurationResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getItemsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 1, + f, + proto.spec.proto.runtime.v1.ConfigurationItem.serializeBinaryToWriter + ); + } +}; + + +/** + * repeated ConfigurationItem items = 1; + * @return {!Array} + */ +proto.spec.proto.runtime.v1.GetConfigurationResponse.prototype.getItemsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.spec.proto.runtime.v1.ConfigurationItem, 1)); +}; + + +/** + * @param {!Array} value + * @return {!proto.spec.proto.runtime.v1.GetConfigurationResponse} returns this +*/ +proto.spec.proto.runtime.v1.GetConfigurationResponse.prototype.setItemsList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); +}; + + +/** + * @param {!proto.spec.proto.runtime.v1.ConfigurationItem=} opt_value + * @param {number=} opt_index + * @return {!proto.spec.proto.runtime.v1.ConfigurationItem} + */ +proto.spec.proto.runtime.v1.GetConfigurationResponse.prototype.addItems = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.spec.proto.runtime.v1.ConfigurationItem, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.spec.proto.runtime.v1.GetConfigurationResponse} returns this + */ +proto.spec.proto.runtime.v1.GetConfigurationResponse.prototype.clearItemsList = function() { + return this.setItemsList([]); +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.repeatedFields_ = [5]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.SubscribeConfigurationRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.toObject = function(includeInstance, msg) { + var f, obj = { + storeName: jspb.Message.getFieldWithDefault(msg, 1, ""), + appId: jspb.Message.getFieldWithDefault(msg, 2, ""), + group: jspb.Message.getFieldWithDefault(msg, 3, ""), + label: jspb.Message.getFieldWithDefault(msg, 4, ""), + keysList: (f = jspb.Message.getRepeatedField(msg, 5)) == null ? undefined : f, + metadataMap: (f = msg.getMetadataMap()) ? f.toObject(includeInstance, undefined) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.SubscribeConfigurationRequest} + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.SubscribeConfigurationRequest; + return proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.SubscribeConfigurationRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.SubscribeConfigurationRequest} + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStoreName(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setAppId(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setGroup(value); + break; + case 4: + var value = /** @type {string} */ (reader.readString()); + msg.setLabel(value); + break; + case 5: + var value = /** @type {string} */ (reader.readString()); + msg.addKeys(value); + break; + case 6: + var value = msg.getMetadataMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.SubscribeConfigurationRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStoreName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getAppId(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getGroup(); + if (f.length > 0) { + writer.writeString( + 3, + f + ); + } + f = message.getLabel(); + if (f.length > 0) { + writer.writeString( + 4, + f + ); + } + f = message.getKeysList(); + if (f.length > 0) { + writer.writeRepeatedString( + 5, + f + ); + } + f = message.getMetadataMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(6, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } +}; + + +/** + * optional string store_name = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.prototype.getStoreName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.SubscribeConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.prototype.setStoreName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string app_id = 2; + * @return {string} + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.prototype.getAppId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.SubscribeConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.prototype.setAppId = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional string group = 3; + * @return {string} + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.prototype.getGroup = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.SubscribeConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.prototype.setGroup = function(value) { + return jspb.Message.setProto3StringField(this, 3, value); +}; + + +/** + * optional string label = 4; + * @return {string} + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.prototype.getLabel = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.SubscribeConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.prototype.setLabel = function(value) { + return jspb.Message.setProto3StringField(this, 4, value); +}; + + +/** + * repeated string keys = 5; + * @return {!Array} + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.prototype.getKeysList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 5)); +}; + + +/** + * @param {!Array} value + * @return {!proto.spec.proto.runtime.v1.SubscribeConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.prototype.setKeysList = function(value) { + return jspb.Message.setField(this, 5, value || []); +}; + + +/** + * @param {string} value + * @param {number=} opt_index + * @return {!proto.spec.proto.runtime.v1.SubscribeConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.prototype.addKeys = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 5, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.spec.proto.runtime.v1.SubscribeConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.prototype.clearKeysList = function() { + return this.setKeysList([]); +}; + + +/** + * map metadata = 6; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.prototype.getMetadataMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 6, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.spec.proto.runtime.v1.SubscribeConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationRequest.prototype.clearMetadataMap = function() { + this.getMetadataMap().clear(); + return this;}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationResponse.repeatedFields_ = [3]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationResponse.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.SubscribeConfigurationResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.SubscribeConfigurationResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationResponse.toObject = function(includeInstance, msg) { + var f, obj = { + storeName: jspb.Message.getFieldWithDefault(msg, 1, ""), + appId: jspb.Message.getFieldWithDefault(msg, 2, ""), + itemsList: jspb.Message.toObjectList(msg.getItemsList(), + proto.spec.proto.runtime.v1.ConfigurationItem.toObject, includeInstance) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.SubscribeConfigurationResponse} + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.SubscribeConfigurationResponse; + return proto.spec.proto.runtime.v1.SubscribeConfigurationResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.SubscribeConfigurationResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.SubscribeConfigurationResponse} + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStoreName(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setAppId(value); + break; + case 3: + var value = new proto.spec.proto.runtime.v1.ConfigurationItem; + reader.readMessage(value,proto.spec.proto.runtime.v1.ConfigurationItem.deserializeBinaryFromReader); + msg.addItems(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.SubscribeConfigurationResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.SubscribeConfigurationResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStoreName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getAppId(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getItemsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 3, + f, + proto.spec.proto.runtime.v1.ConfigurationItem.serializeBinaryToWriter + ); + } +}; + + +/** + * optional string store_name = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationResponse.prototype.getStoreName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.SubscribeConfigurationResponse} returns this + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationResponse.prototype.setStoreName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string app_id = 2; + * @return {string} + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationResponse.prototype.getAppId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.SubscribeConfigurationResponse} returns this + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationResponse.prototype.setAppId = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * repeated ConfigurationItem items = 3; + * @return {!Array} + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationResponse.prototype.getItemsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.spec.proto.runtime.v1.ConfigurationItem, 3)); +}; + + +/** + * @param {!Array} value + * @return {!proto.spec.proto.runtime.v1.SubscribeConfigurationResponse} returns this +*/ +proto.spec.proto.runtime.v1.SubscribeConfigurationResponse.prototype.setItemsList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 3, value); +}; + + +/** + * @param {!proto.spec.proto.runtime.v1.ConfigurationItem=} opt_value + * @param {number=} opt_index + * @return {!proto.spec.proto.runtime.v1.ConfigurationItem} + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationResponse.prototype.addItems = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 3, opt_value, proto.spec.proto.runtime.v1.ConfigurationItem, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.spec.proto.runtime.v1.SubscribeConfigurationResponse} returns this + */ +proto.spec.proto.runtime.v1.SubscribeConfigurationResponse.prototype.clearItemsList = function() { + return this.setItemsList([]); +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.spec.proto.runtime.v1.SaveConfigurationRequest.repeatedFields_ = [3]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.SaveConfigurationRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.SaveConfigurationRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.SaveConfigurationRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.SaveConfigurationRequest.toObject = function(includeInstance, msg) { + var f, obj = { + storeName: jspb.Message.getFieldWithDefault(msg, 1, ""), + appId: jspb.Message.getFieldWithDefault(msg, 2, ""), + itemsList: jspb.Message.toObjectList(msg.getItemsList(), + proto.spec.proto.runtime.v1.ConfigurationItem.toObject, includeInstance), + metadataMap: (f = msg.getMetadataMap()) ? f.toObject(includeInstance, undefined) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.SaveConfigurationRequest} + */ +proto.spec.proto.runtime.v1.SaveConfigurationRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.SaveConfigurationRequest; + return proto.spec.proto.runtime.v1.SaveConfigurationRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.SaveConfigurationRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.SaveConfigurationRequest} + */ +proto.spec.proto.runtime.v1.SaveConfigurationRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStoreName(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setAppId(value); + break; + case 3: + var value = new proto.spec.proto.runtime.v1.ConfigurationItem; + reader.readMessage(value,proto.spec.proto.runtime.v1.ConfigurationItem.deserializeBinaryFromReader); + msg.addItems(value); + break; + case 4: + var value = msg.getMetadataMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.SaveConfigurationRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.SaveConfigurationRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.SaveConfigurationRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.SaveConfigurationRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStoreName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getAppId(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getItemsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 3, + f, + proto.spec.proto.runtime.v1.ConfigurationItem.serializeBinaryToWriter + ); + } + f = message.getMetadataMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(4, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } +}; + + +/** + * optional string store_name = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.SaveConfigurationRequest.prototype.getStoreName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.SaveConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.SaveConfigurationRequest.prototype.setStoreName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string app_id = 2; + * @return {string} + */ +proto.spec.proto.runtime.v1.SaveConfigurationRequest.prototype.getAppId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.SaveConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.SaveConfigurationRequest.prototype.setAppId = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * repeated ConfigurationItem items = 3; + * @return {!Array} + */ +proto.spec.proto.runtime.v1.SaveConfigurationRequest.prototype.getItemsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.spec.proto.runtime.v1.ConfigurationItem, 3)); +}; + + +/** + * @param {!Array} value + * @return {!proto.spec.proto.runtime.v1.SaveConfigurationRequest} returns this +*/ +proto.spec.proto.runtime.v1.SaveConfigurationRequest.prototype.setItemsList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 3, value); +}; + + +/** + * @param {!proto.spec.proto.runtime.v1.ConfigurationItem=} opt_value + * @param {number=} opt_index + * @return {!proto.spec.proto.runtime.v1.ConfigurationItem} + */ +proto.spec.proto.runtime.v1.SaveConfigurationRequest.prototype.addItems = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 3, opt_value, proto.spec.proto.runtime.v1.ConfigurationItem, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.spec.proto.runtime.v1.SaveConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.SaveConfigurationRequest.prototype.clearItemsList = function() { + return this.setItemsList([]); +}; + + +/** + * map metadata = 4; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.spec.proto.runtime.v1.SaveConfigurationRequest.prototype.getMetadataMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 4, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.spec.proto.runtime.v1.SaveConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.SaveConfigurationRequest.prototype.clearMetadataMap = function() { + this.getMetadataMap().clear(); + return this;}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest.repeatedFields_ = [5]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.DeleteConfigurationRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.DeleteConfigurationRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest.toObject = function(includeInstance, msg) { + var f, obj = { + storeName: jspb.Message.getFieldWithDefault(msg, 1, ""), + appId: jspb.Message.getFieldWithDefault(msg, 2, ""), + group: jspb.Message.getFieldWithDefault(msg, 3, ""), + label: jspb.Message.getFieldWithDefault(msg, 4, ""), + keysList: (f = jspb.Message.getRepeatedField(msg, 5)) == null ? undefined : f, + metadataMap: (f = msg.getMetadataMap()) ? f.toObject(includeInstance, undefined) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.DeleteConfigurationRequest} + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.DeleteConfigurationRequest; + return proto.spec.proto.runtime.v1.DeleteConfigurationRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.DeleteConfigurationRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.DeleteConfigurationRequest} + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStoreName(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setAppId(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setGroup(value); + break; + case 4: + var value = /** @type {string} */ (reader.readString()); + msg.setLabel(value); + break; + case 5: + var value = /** @type {string} */ (reader.readString()); + msg.addKeys(value); + break; + case 6: + var value = msg.getMetadataMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.DeleteConfigurationRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.DeleteConfigurationRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStoreName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getAppId(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getGroup(); + if (f.length > 0) { + writer.writeString( + 3, + f + ); + } + f = message.getLabel(); + if (f.length > 0) { + writer.writeString( + 4, + f + ); + } + f = message.getKeysList(); + if (f.length > 0) { + writer.writeRepeatedString( + 5, + f + ); + } + f = message.getMetadataMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(6, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } +}; + + +/** + * optional string store_name = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest.prototype.getStoreName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.DeleteConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest.prototype.setStoreName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string app_id = 2; + * @return {string} + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest.prototype.getAppId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.DeleteConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest.prototype.setAppId = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional string group = 3; + * @return {string} + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest.prototype.getGroup = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.DeleteConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest.prototype.setGroup = function(value) { + return jspb.Message.setProto3StringField(this, 3, value); +}; + + +/** + * optional string label = 4; + * @return {string} + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest.prototype.getLabel = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.DeleteConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest.prototype.setLabel = function(value) { + return jspb.Message.setProto3StringField(this, 4, value); +}; + + +/** + * repeated string keys = 5; + * @return {!Array} + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest.prototype.getKeysList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 5)); +}; + + +/** + * @param {!Array} value + * @return {!proto.spec.proto.runtime.v1.DeleteConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest.prototype.setKeysList = function(value) { + return jspb.Message.setField(this, 5, value || []); +}; + + +/** + * @param {string} value + * @param {number=} opt_index + * @return {!proto.spec.proto.runtime.v1.DeleteConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest.prototype.addKeys = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 5, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.spec.proto.runtime.v1.DeleteConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest.prototype.clearKeysList = function() { + return this.setKeysList([]); +}; + + +/** + * map metadata = 6; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest.prototype.getMetadataMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 6, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.spec.proto.runtime.v1.DeleteConfigurationRequest} returns this + */ +proto.spec.proto.runtime.v1.DeleteConfigurationRequest.prototype.clearMetadataMap = function() { + this.getMetadataMap().clear(); + return this;}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.GetStateRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.GetStateRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.GetStateRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.GetStateRequest.toObject = function(includeInstance, msg) { + var f, obj = { + storeName: jspb.Message.getFieldWithDefault(msg, 1, ""), + key: jspb.Message.getFieldWithDefault(msg, 2, ""), + consistency: jspb.Message.getFieldWithDefault(msg, 3, 0), + metadataMap: (f = msg.getMetadataMap()) ? f.toObject(includeInstance, undefined) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.GetStateRequest} + */ +proto.spec.proto.runtime.v1.GetStateRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.GetStateRequest; + return proto.spec.proto.runtime.v1.GetStateRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.GetStateRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.GetStateRequest} + */ +proto.spec.proto.runtime.v1.GetStateRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStoreName(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setKey(value); + break; + case 3: + var value = /** @type {!proto.spec.proto.runtime.v1.StateOptions.StateConsistency} */ (reader.readEnum()); + msg.setConsistency(value); + break; + case 4: + var value = msg.getMetadataMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.GetStateRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.GetStateRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.GetStateRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.GetStateRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStoreName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getKey(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getConsistency(); + if (f !== 0.0) { + writer.writeEnum( + 3, + f + ); + } + f = message.getMetadataMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(4, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } +}; + + +/** + * optional string store_name = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.GetStateRequest.prototype.getStoreName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.GetStateRequest} returns this + */ +proto.spec.proto.runtime.v1.GetStateRequest.prototype.setStoreName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string key = 2; + * @return {string} + */ +proto.spec.proto.runtime.v1.GetStateRequest.prototype.getKey = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.GetStateRequest} returns this + */ +proto.spec.proto.runtime.v1.GetStateRequest.prototype.setKey = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional StateOptions.StateConsistency consistency = 3; + * @return {!proto.spec.proto.runtime.v1.StateOptions.StateConsistency} + */ +proto.spec.proto.runtime.v1.GetStateRequest.prototype.getConsistency = function() { + return /** @type {!proto.spec.proto.runtime.v1.StateOptions.StateConsistency} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); +}; + + +/** + * @param {!proto.spec.proto.runtime.v1.StateOptions.StateConsistency} value + * @return {!proto.spec.proto.runtime.v1.GetStateRequest} returns this + */ +proto.spec.proto.runtime.v1.GetStateRequest.prototype.setConsistency = function(value) { + return jspb.Message.setProto3EnumField(this, 3, value); +}; + + +/** + * map metadata = 4; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.spec.proto.runtime.v1.GetStateRequest.prototype.getMetadataMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 4, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.spec.proto.runtime.v1.GetStateRequest} returns this + */ +proto.spec.proto.runtime.v1.GetStateRequest.prototype.clearMetadataMap = function() { + this.getMetadataMap().clear(); + return this;}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.spec.proto.runtime.v1.GetBulkStateRequest.repeatedFields_ = [2]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.GetBulkStateRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.GetBulkStateRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.GetBulkStateRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.GetBulkStateRequest.toObject = function(includeInstance, msg) { + var f, obj = { + storeName: jspb.Message.getFieldWithDefault(msg, 1, ""), + keysList: (f = jspb.Message.getRepeatedField(msg, 2)) == null ? undefined : f, + parallelism: jspb.Message.getFieldWithDefault(msg, 3, 0), + metadataMap: (f = msg.getMetadataMap()) ? f.toObject(includeInstance, undefined) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.GetBulkStateRequest} + */ +proto.spec.proto.runtime.v1.GetBulkStateRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.GetBulkStateRequest; + return proto.spec.proto.runtime.v1.GetBulkStateRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.GetBulkStateRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.GetBulkStateRequest} + */ +proto.spec.proto.runtime.v1.GetBulkStateRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStoreName(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.addKeys(value); + break; + case 3: + var value = /** @type {number} */ (reader.readInt32()); + msg.setParallelism(value); + break; + case 4: + var value = msg.getMetadataMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.GetBulkStateRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.GetBulkStateRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.GetBulkStateRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.GetBulkStateRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStoreName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getKeysList(); + if (f.length > 0) { + writer.writeRepeatedString( + 2, + f + ); + } + f = message.getParallelism(); + if (f !== 0) { + writer.writeInt32( + 3, + f + ); + } + f = message.getMetadataMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(4, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } +}; + + +/** + * optional string store_name = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.GetBulkStateRequest.prototype.getStoreName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.GetBulkStateRequest} returns this + */ +proto.spec.proto.runtime.v1.GetBulkStateRequest.prototype.setStoreName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * repeated string keys = 2; + * @return {!Array} + */ +proto.spec.proto.runtime.v1.GetBulkStateRequest.prototype.getKeysList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); +}; + + +/** + * @param {!Array} value + * @return {!proto.spec.proto.runtime.v1.GetBulkStateRequest} returns this + */ +proto.spec.proto.runtime.v1.GetBulkStateRequest.prototype.setKeysList = function(value) { + return jspb.Message.setField(this, 2, value || []); +}; + + +/** + * @param {string} value + * @param {number=} opt_index + * @return {!proto.spec.proto.runtime.v1.GetBulkStateRequest} returns this + */ +proto.spec.proto.runtime.v1.GetBulkStateRequest.prototype.addKeys = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 2, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.spec.proto.runtime.v1.GetBulkStateRequest} returns this + */ +proto.spec.proto.runtime.v1.GetBulkStateRequest.prototype.clearKeysList = function() { + return this.setKeysList([]); +}; + + +/** + * optional int32 parallelism = 3; + * @return {number} + */ +proto.spec.proto.runtime.v1.GetBulkStateRequest.prototype.getParallelism = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.spec.proto.runtime.v1.GetBulkStateRequest} returns this + */ +proto.spec.proto.runtime.v1.GetBulkStateRequest.prototype.setParallelism = function(value) { + return jspb.Message.setProto3IntField(this, 3, value); +}; + + +/** + * map metadata = 4; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.spec.proto.runtime.v1.GetBulkStateRequest.prototype.getMetadataMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 4, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.spec.proto.runtime.v1.GetBulkStateRequest} returns this + */ +proto.spec.proto.runtime.v1.GetBulkStateRequest.prototype.clearMetadataMap = function() { + this.getMetadataMap().clear(); + return this;}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.spec.proto.runtime.v1.GetBulkStateResponse.repeatedFields_ = [1]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.GetBulkStateResponse.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.GetBulkStateResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.GetBulkStateResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.GetBulkStateResponse.toObject = function(includeInstance, msg) { + var f, obj = { + itemsList: jspb.Message.toObjectList(msg.getItemsList(), + proto.spec.proto.runtime.v1.BulkStateItem.toObject, includeInstance) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.GetBulkStateResponse} + */ +proto.spec.proto.runtime.v1.GetBulkStateResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.GetBulkStateResponse; + return proto.spec.proto.runtime.v1.GetBulkStateResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.GetBulkStateResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.GetBulkStateResponse} + */ +proto.spec.proto.runtime.v1.GetBulkStateResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.spec.proto.runtime.v1.BulkStateItem; + reader.readMessage(value,proto.spec.proto.runtime.v1.BulkStateItem.deserializeBinaryFromReader); + msg.addItems(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.GetBulkStateResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.GetBulkStateResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.GetBulkStateResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.GetBulkStateResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getItemsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 1, + f, + proto.spec.proto.runtime.v1.BulkStateItem.serializeBinaryToWriter + ); + } +}; + + +/** + * repeated BulkStateItem items = 1; + * @return {!Array} + */ +proto.spec.proto.runtime.v1.GetBulkStateResponse.prototype.getItemsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.spec.proto.runtime.v1.BulkStateItem, 1)); +}; + + +/** + * @param {!Array} value + * @return {!proto.spec.proto.runtime.v1.GetBulkStateResponse} returns this +*/ +proto.spec.proto.runtime.v1.GetBulkStateResponse.prototype.setItemsList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); +}; + + +/** + * @param {!proto.spec.proto.runtime.v1.BulkStateItem=} opt_value + * @param {number=} opt_index + * @return {!proto.spec.proto.runtime.v1.BulkStateItem} + */ +proto.spec.proto.runtime.v1.GetBulkStateResponse.prototype.addItems = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.spec.proto.runtime.v1.BulkStateItem, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.spec.proto.runtime.v1.GetBulkStateResponse} returns this + */ +proto.spec.proto.runtime.v1.GetBulkStateResponse.prototype.clearItemsList = function() { + return this.setItemsList([]); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.BulkStateItem.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.BulkStateItem.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.BulkStateItem} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.BulkStateItem.toObject = function(includeInstance, msg) { + var f, obj = { + key: jspb.Message.getFieldWithDefault(msg, 1, ""), + data: msg.getData_asB64(), + etag: jspb.Message.getFieldWithDefault(msg, 3, ""), + error: jspb.Message.getFieldWithDefault(msg, 4, ""), + metadataMap: (f = msg.getMetadataMap()) ? f.toObject(includeInstance, undefined) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.BulkStateItem} + */ +proto.spec.proto.runtime.v1.BulkStateItem.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.BulkStateItem; + return proto.spec.proto.runtime.v1.BulkStateItem.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.BulkStateItem} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.BulkStateItem} + */ +proto.spec.proto.runtime.v1.BulkStateItem.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setKey(value); + break; + case 2: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setData(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setEtag(value); + break; + case 4: + var value = /** @type {string} */ (reader.readString()); + msg.setError(value); + break; + case 5: + var value = msg.getMetadataMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.BulkStateItem.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.BulkStateItem.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.BulkStateItem} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.BulkStateItem.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getKey(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getData_asU8(); + if (f.length > 0) { + writer.writeBytes( + 2, + f + ); + } + f = message.getEtag(); + if (f.length > 0) { + writer.writeString( + 3, + f + ); + } + f = message.getError(); + if (f.length > 0) { + writer.writeString( + 4, + f + ); + } + f = message.getMetadataMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(5, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } +}; + + +/** + * optional string key = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.BulkStateItem.prototype.getKey = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.BulkStateItem} returns this + */ +proto.spec.proto.runtime.v1.BulkStateItem.prototype.setKey = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional bytes data = 2; + * @return {!(string|Uint8Array)} + */ +proto.spec.proto.runtime.v1.BulkStateItem.prototype.getData = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * optional bytes data = 2; + * This is a type-conversion wrapper around `getData()` + * @return {string} + */ +proto.spec.proto.runtime.v1.BulkStateItem.prototype.getData_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getData())); +}; + + +/** + * optional bytes data = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getData()` + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.BulkStateItem.prototype.getData_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getData())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.spec.proto.runtime.v1.BulkStateItem} returns this + */ +proto.spec.proto.runtime.v1.BulkStateItem.prototype.setData = function(value) { + return jspb.Message.setProto3BytesField(this, 2, value); +}; + + +/** + * optional string etag = 3; + * @return {string} + */ +proto.spec.proto.runtime.v1.BulkStateItem.prototype.getEtag = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.BulkStateItem} returns this + */ +proto.spec.proto.runtime.v1.BulkStateItem.prototype.setEtag = function(value) { + return jspb.Message.setProto3StringField(this, 3, value); +}; + + +/** + * optional string error = 4; + * @return {string} + */ +proto.spec.proto.runtime.v1.BulkStateItem.prototype.getError = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.BulkStateItem} returns this + */ +proto.spec.proto.runtime.v1.BulkStateItem.prototype.setError = function(value) { + return jspb.Message.setProto3StringField(this, 4, value); +}; + + +/** + * map metadata = 5; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.spec.proto.runtime.v1.BulkStateItem.prototype.getMetadataMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 5, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.spec.proto.runtime.v1.BulkStateItem} returns this + */ +proto.spec.proto.runtime.v1.BulkStateItem.prototype.clearMetadataMap = function() { + this.getMetadataMap().clear(); + return this;}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.GetStateResponse.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.GetStateResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.GetStateResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.GetStateResponse.toObject = function(includeInstance, msg) { + var f, obj = { + data: msg.getData_asB64(), + etag: jspb.Message.getFieldWithDefault(msg, 2, ""), + metadataMap: (f = msg.getMetadataMap()) ? f.toObject(includeInstance, undefined) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.GetStateResponse} + */ +proto.spec.proto.runtime.v1.GetStateResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.GetStateResponse; + return proto.spec.proto.runtime.v1.GetStateResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.GetStateResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.GetStateResponse} + */ +proto.spec.proto.runtime.v1.GetStateResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setData(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setEtag(value); + break; + case 3: + var value = msg.getMetadataMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.GetStateResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.GetStateResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.GetStateResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.GetStateResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getData_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } + f = message.getEtag(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getMetadataMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(3, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } +}; + + +/** + * optional bytes data = 1; + * @return {!(string|Uint8Array)} + */ +proto.spec.proto.runtime.v1.GetStateResponse.prototype.getData = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes data = 1; + * This is a type-conversion wrapper around `getData()` + * @return {string} + */ +proto.spec.proto.runtime.v1.GetStateResponse.prototype.getData_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getData())); +}; + + +/** + * optional bytes data = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getData()` + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.GetStateResponse.prototype.getData_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getData())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.spec.proto.runtime.v1.GetStateResponse} returns this + */ +proto.spec.proto.runtime.v1.GetStateResponse.prototype.setData = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + +/** + * optional string etag = 2; + * @return {string} + */ +proto.spec.proto.runtime.v1.GetStateResponse.prototype.getEtag = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.GetStateResponse} returns this + */ +proto.spec.proto.runtime.v1.GetStateResponse.prototype.setEtag = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * map metadata = 3; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.spec.proto.runtime.v1.GetStateResponse.prototype.getMetadataMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 3, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.spec.proto.runtime.v1.GetStateResponse} returns this + */ +proto.spec.proto.runtime.v1.GetStateResponse.prototype.clearMetadataMap = function() { + this.getMetadataMap().clear(); + return this;}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.DeleteStateRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.DeleteStateRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.DeleteStateRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.DeleteStateRequest.toObject = function(includeInstance, msg) { + var f, obj = { + storeName: jspb.Message.getFieldWithDefault(msg, 1, ""), + key: jspb.Message.getFieldWithDefault(msg, 2, ""), + etag: (f = msg.getEtag()) && proto.spec.proto.runtime.v1.Etag.toObject(includeInstance, f), + options: (f = msg.getOptions()) && proto.spec.proto.runtime.v1.StateOptions.toObject(includeInstance, f), + metadataMap: (f = msg.getMetadataMap()) ? f.toObject(includeInstance, undefined) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.DeleteStateRequest} + */ +proto.spec.proto.runtime.v1.DeleteStateRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.DeleteStateRequest; + return proto.spec.proto.runtime.v1.DeleteStateRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.DeleteStateRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.DeleteStateRequest} + */ +proto.spec.proto.runtime.v1.DeleteStateRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStoreName(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setKey(value); + break; + case 3: + var value = new proto.spec.proto.runtime.v1.Etag; + reader.readMessage(value,proto.spec.proto.runtime.v1.Etag.deserializeBinaryFromReader); + msg.setEtag(value); + break; + case 4: + var value = new proto.spec.proto.runtime.v1.StateOptions; + reader.readMessage(value,proto.spec.proto.runtime.v1.StateOptions.deserializeBinaryFromReader); + msg.setOptions(value); + break; + case 5: + var value = msg.getMetadataMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.DeleteStateRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.DeleteStateRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.DeleteStateRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.DeleteStateRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStoreName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getKey(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getEtag(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.spec.proto.runtime.v1.Etag.serializeBinaryToWriter + ); + } + f = message.getOptions(); + if (f != null) { + writer.writeMessage( + 4, + f, + proto.spec.proto.runtime.v1.StateOptions.serializeBinaryToWriter + ); + } + f = message.getMetadataMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(5, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } +}; + + +/** + * optional string store_name = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.DeleteStateRequest.prototype.getStoreName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.DeleteStateRequest} returns this + */ +proto.spec.proto.runtime.v1.DeleteStateRequest.prototype.setStoreName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string key = 2; + * @return {string} + */ +proto.spec.proto.runtime.v1.DeleteStateRequest.prototype.getKey = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.DeleteStateRequest} returns this + */ +proto.spec.proto.runtime.v1.DeleteStateRequest.prototype.setKey = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional Etag etag = 3; + * @return {?proto.spec.proto.runtime.v1.Etag} + */ +proto.spec.proto.runtime.v1.DeleteStateRequest.prototype.getEtag = function() { + return /** @type{?proto.spec.proto.runtime.v1.Etag} */ ( + jspb.Message.getWrapperField(this, proto.spec.proto.runtime.v1.Etag, 3)); +}; + + +/** + * @param {?proto.spec.proto.runtime.v1.Etag|undefined} value + * @return {!proto.spec.proto.runtime.v1.DeleteStateRequest} returns this +*/ +proto.spec.proto.runtime.v1.DeleteStateRequest.prototype.setEtag = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.spec.proto.runtime.v1.DeleteStateRequest} returns this + */ +proto.spec.proto.runtime.v1.DeleteStateRequest.prototype.clearEtag = function() { + return this.setEtag(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.spec.proto.runtime.v1.DeleteStateRequest.prototype.hasEtag = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional StateOptions options = 4; + * @return {?proto.spec.proto.runtime.v1.StateOptions} + */ +proto.spec.proto.runtime.v1.DeleteStateRequest.prototype.getOptions = function() { + return /** @type{?proto.spec.proto.runtime.v1.StateOptions} */ ( + jspb.Message.getWrapperField(this, proto.spec.proto.runtime.v1.StateOptions, 4)); +}; + + +/** + * @param {?proto.spec.proto.runtime.v1.StateOptions|undefined} value + * @return {!proto.spec.proto.runtime.v1.DeleteStateRequest} returns this +*/ +proto.spec.proto.runtime.v1.DeleteStateRequest.prototype.setOptions = function(value) { + return jspb.Message.setWrapperField(this, 4, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.spec.proto.runtime.v1.DeleteStateRequest} returns this + */ +proto.spec.proto.runtime.v1.DeleteStateRequest.prototype.clearOptions = function() { + return this.setOptions(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.spec.proto.runtime.v1.DeleteStateRequest.prototype.hasOptions = function() { + return jspb.Message.getField(this, 4) != null; +}; + + +/** + * map metadata = 5; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.spec.proto.runtime.v1.DeleteStateRequest.prototype.getMetadataMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 5, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.spec.proto.runtime.v1.DeleteStateRequest} returns this + */ +proto.spec.proto.runtime.v1.DeleteStateRequest.prototype.clearMetadataMap = function() { + this.getMetadataMap().clear(); + return this;}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.spec.proto.runtime.v1.DeleteBulkStateRequest.repeatedFields_ = [2]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.DeleteBulkStateRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.DeleteBulkStateRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.DeleteBulkStateRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.DeleteBulkStateRequest.toObject = function(includeInstance, msg) { + var f, obj = { + storeName: jspb.Message.getFieldWithDefault(msg, 1, ""), + statesList: jspb.Message.toObjectList(msg.getStatesList(), + proto.spec.proto.runtime.v1.StateItem.toObject, includeInstance) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.DeleteBulkStateRequest} + */ +proto.spec.proto.runtime.v1.DeleteBulkStateRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.DeleteBulkStateRequest; + return proto.spec.proto.runtime.v1.DeleteBulkStateRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.DeleteBulkStateRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.DeleteBulkStateRequest} + */ +proto.spec.proto.runtime.v1.DeleteBulkStateRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStoreName(value); + break; + case 2: + var value = new proto.spec.proto.runtime.v1.StateItem; + reader.readMessage(value,proto.spec.proto.runtime.v1.StateItem.deserializeBinaryFromReader); + msg.addStates(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.DeleteBulkStateRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.DeleteBulkStateRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.DeleteBulkStateRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.DeleteBulkStateRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStoreName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getStatesList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 2, + f, + proto.spec.proto.runtime.v1.StateItem.serializeBinaryToWriter + ); + } +}; + + +/** + * optional string store_name = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.DeleteBulkStateRequest.prototype.getStoreName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.DeleteBulkStateRequest} returns this + */ +proto.spec.proto.runtime.v1.DeleteBulkStateRequest.prototype.setStoreName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * repeated StateItem states = 2; + * @return {!Array} + */ +proto.spec.proto.runtime.v1.DeleteBulkStateRequest.prototype.getStatesList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.spec.proto.runtime.v1.StateItem, 2)); +}; + + +/** + * @param {!Array} value + * @return {!proto.spec.proto.runtime.v1.DeleteBulkStateRequest} returns this +*/ +proto.spec.proto.runtime.v1.DeleteBulkStateRequest.prototype.setStatesList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 2, value); +}; + + +/** + * @param {!proto.spec.proto.runtime.v1.StateItem=} opt_value + * @param {number=} opt_index + * @return {!proto.spec.proto.runtime.v1.StateItem} + */ +proto.spec.proto.runtime.v1.DeleteBulkStateRequest.prototype.addStates = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 2, opt_value, proto.spec.proto.runtime.v1.StateItem, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.spec.proto.runtime.v1.DeleteBulkStateRequest} returns this + */ +proto.spec.proto.runtime.v1.DeleteBulkStateRequest.prototype.clearStatesList = function() { + return this.setStatesList([]); +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.spec.proto.runtime.v1.SaveStateRequest.repeatedFields_ = [2]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.SaveStateRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.SaveStateRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.SaveStateRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.SaveStateRequest.toObject = function(includeInstance, msg) { + var f, obj = { + storeName: jspb.Message.getFieldWithDefault(msg, 1, ""), + statesList: jspb.Message.toObjectList(msg.getStatesList(), + proto.spec.proto.runtime.v1.StateItem.toObject, includeInstance) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.SaveStateRequest} + */ +proto.spec.proto.runtime.v1.SaveStateRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.SaveStateRequest; + return proto.spec.proto.runtime.v1.SaveStateRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.SaveStateRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.SaveStateRequest} + */ +proto.spec.proto.runtime.v1.SaveStateRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStoreName(value); + break; + case 2: + var value = new proto.spec.proto.runtime.v1.StateItem; + reader.readMessage(value,proto.spec.proto.runtime.v1.StateItem.deserializeBinaryFromReader); + msg.addStates(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.SaveStateRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.SaveStateRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.SaveStateRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.SaveStateRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStoreName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getStatesList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 2, + f, + proto.spec.proto.runtime.v1.StateItem.serializeBinaryToWriter + ); + } +}; + + +/** + * optional string store_name = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.SaveStateRequest.prototype.getStoreName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.SaveStateRequest} returns this + */ +proto.spec.proto.runtime.v1.SaveStateRequest.prototype.setStoreName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * repeated StateItem states = 2; + * @return {!Array} + */ +proto.spec.proto.runtime.v1.SaveStateRequest.prototype.getStatesList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.spec.proto.runtime.v1.StateItem, 2)); +}; + + +/** + * @param {!Array} value + * @return {!proto.spec.proto.runtime.v1.SaveStateRequest} returns this +*/ +proto.spec.proto.runtime.v1.SaveStateRequest.prototype.setStatesList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 2, value); +}; + + +/** + * @param {!proto.spec.proto.runtime.v1.StateItem=} opt_value + * @param {number=} opt_index + * @return {!proto.spec.proto.runtime.v1.StateItem} + */ +proto.spec.proto.runtime.v1.SaveStateRequest.prototype.addStates = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 2, opt_value, proto.spec.proto.runtime.v1.StateItem, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.spec.proto.runtime.v1.SaveStateRequest} returns this + */ +proto.spec.proto.runtime.v1.SaveStateRequest.prototype.clearStatesList = function() { + return this.setStatesList([]); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.StateItem.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.StateItem.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.StateItem} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.StateItem.toObject = function(includeInstance, msg) { + var f, obj = { + key: jspb.Message.getFieldWithDefault(msg, 1, ""), + value: msg.getValue_asB64(), + etag: (f = msg.getEtag()) && proto.spec.proto.runtime.v1.Etag.toObject(includeInstance, f), + metadataMap: (f = msg.getMetadataMap()) ? f.toObject(includeInstance, undefined) : [], + options: (f = msg.getOptions()) && proto.spec.proto.runtime.v1.StateOptions.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.StateItem} + */ +proto.spec.proto.runtime.v1.StateItem.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.StateItem; + return proto.spec.proto.runtime.v1.StateItem.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.StateItem} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.StateItem} + */ +proto.spec.proto.runtime.v1.StateItem.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setKey(value); + break; + case 2: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setValue(value); + break; + case 3: + var value = new proto.spec.proto.runtime.v1.Etag; + reader.readMessage(value,proto.spec.proto.runtime.v1.Etag.deserializeBinaryFromReader); + msg.setEtag(value); + break; + case 4: + var value = msg.getMetadataMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + case 5: + var value = new proto.spec.proto.runtime.v1.StateOptions; + reader.readMessage(value,proto.spec.proto.runtime.v1.StateOptions.deserializeBinaryFromReader); + msg.setOptions(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.StateItem.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.StateItem.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.StateItem} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.StateItem.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getKey(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getValue_asU8(); + if (f.length > 0) { + writer.writeBytes( + 2, + f + ); + } + f = message.getEtag(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.spec.proto.runtime.v1.Etag.serializeBinaryToWriter + ); + } + f = message.getMetadataMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(4, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } + f = message.getOptions(); + if (f != null) { + writer.writeMessage( + 5, + f, + proto.spec.proto.runtime.v1.StateOptions.serializeBinaryToWriter + ); + } +}; + + +/** + * optional string key = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.StateItem.prototype.getKey = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.StateItem} returns this + */ +proto.spec.proto.runtime.v1.StateItem.prototype.setKey = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional bytes value = 2; + * @return {!(string|Uint8Array)} + */ +proto.spec.proto.runtime.v1.StateItem.prototype.getValue = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * optional bytes value = 2; + * This is a type-conversion wrapper around `getValue()` + * @return {string} + */ +proto.spec.proto.runtime.v1.StateItem.prototype.getValue_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getValue())); +}; + + +/** + * optional bytes value = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getValue()` + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.StateItem.prototype.getValue_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getValue())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.spec.proto.runtime.v1.StateItem} returns this + */ +proto.spec.proto.runtime.v1.StateItem.prototype.setValue = function(value) { + return jspb.Message.setProto3BytesField(this, 2, value); +}; + + +/** + * optional Etag etag = 3; + * @return {?proto.spec.proto.runtime.v1.Etag} + */ +proto.spec.proto.runtime.v1.StateItem.prototype.getEtag = function() { + return /** @type{?proto.spec.proto.runtime.v1.Etag} */ ( + jspb.Message.getWrapperField(this, proto.spec.proto.runtime.v1.Etag, 3)); +}; + + +/** + * @param {?proto.spec.proto.runtime.v1.Etag|undefined} value + * @return {!proto.spec.proto.runtime.v1.StateItem} returns this +*/ +proto.spec.proto.runtime.v1.StateItem.prototype.setEtag = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.spec.proto.runtime.v1.StateItem} returns this + */ +proto.spec.proto.runtime.v1.StateItem.prototype.clearEtag = function() { + return this.setEtag(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.spec.proto.runtime.v1.StateItem.prototype.hasEtag = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * map metadata = 4; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.spec.proto.runtime.v1.StateItem.prototype.getMetadataMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 4, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.spec.proto.runtime.v1.StateItem} returns this + */ +proto.spec.proto.runtime.v1.StateItem.prototype.clearMetadataMap = function() { + this.getMetadataMap().clear(); + return this;}; + + +/** + * optional StateOptions options = 5; + * @return {?proto.spec.proto.runtime.v1.StateOptions} + */ +proto.spec.proto.runtime.v1.StateItem.prototype.getOptions = function() { + return /** @type{?proto.spec.proto.runtime.v1.StateOptions} */ ( + jspb.Message.getWrapperField(this, proto.spec.proto.runtime.v1.StateOptions, 5)); +}; + + +/** + * @param {?proto.spec.proto.runtime.v1.StateOptions|undefined} value + * @return {!proto.spec.proto.runtime.v1.StateItem} returns this +*/ +proto.spec.proto.runtime.v1.StateItem.prototype.setOptions = function(value) { + return jspb.Message.setWrapperField(this, 5, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.spec.proto.runtime.v1.StateItem} returns this + */ +proto.spec.proto.runtime.v1.StateItem.prototype.clearOptions = function() { + return this.setOptions(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.spec.proto.runtime.v1.StateItem.prototype.hasOptions = function() { + return jspb.Message.getField(this, 5) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.Etag.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.Etag.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.Etag} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.Etag.toObject = function(includeInstance, msg) { + var f, obj = { + value: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.Etag} + */ +proto.spec.proto.runtime.v1.Etag.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.Etag; + return proto.spec.proto.runtime.v1.Etag.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.Etag} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.Etag} + */ +proto.spec.proto.runtime.v1.Etag.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setValue(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.Etag.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.Etag.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.Etag} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.Etag.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getValue(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string value = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.Etag.prototype.getValue = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.Etag} returns this + */ +proto.spec.proto.runtime.v1.Etag.prototype.setValue = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.StateOptions.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.StateOptions.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.StateOptions} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.StateOptions.toObject = function(includeInstance, msg) { + var f, obj = { + concurrency: jspb.Message.getFieldWithDefault(msg, 1, 0), + consistency: jspb.Message.getFieldWithDefault(msg, 2, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.StateOptions} + */ +proto.spec.proto.runtime.v1.StateOptions.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.StateOptions; + return proto.spec.proto.runtime.v1.StateOptions.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.StateOptions} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.StateOptions} + */ +proto.spec.proto.runtime.v1.StateOptions.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!proto.spec.proto.runtime.v1.StateOptions.StateConcurrency} */ (reader.readEnum()); + msg.setConcurrency(value); + break; + case 2: + var value = /** @type {!proto.spec.proto.runtime.v1.StateOptions.StateConsistency} */ (reader.readEnum()); + msg.setConsistency(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.StateOptions.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.StateOptions.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.StateOptions} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.StateOptions.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getConcurrency(); + if (f !== 0.0) { + writer.writeEnum( + 1, + f + ); + } + f = message.getConsistency(); + if (f !== 0.0) { + writer.writeEnum( + 2, + f + ); + } +}; + + +/** + * @enum {number} + */ +proto.spec.proto.runtime.v1.StateOptions.StateConcurrency = { + CONCURRENCY_UNSPECIFIED: 0, + CONCURRENCY_FIRST_WRITE: 1, + CONCURRENCY_LAST_WRITE: 2 +}; + +/** + * @enum {number} + */ +proto.spec.proto.runtime.v1.StateOptions.StateConsistency = { + CONSISTENCY_UNSPECIFIED: 0, + CONSISTENCY_EVENTUAL: 1, + CONSISTENCY_STRONG: 2 +}; + +/** + * optional StateConcurrency concurrency = 1; + * @return {!proto.spec.proto.runtime.v1.StateOptions.StateConcurrency} + */ +proto.spec.proto.runtime.v1.StateOptions.prototype.getConcurrency = function() { + return /** @type {!proto.spec.proto.runtime.v1.StateOptions.StateConcurrency} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {!proto.spec.proto.runtime.v1.StateOptions.StateConcurrency} value + * @return {!proto.spec.proto.runtime.v1.StateOptions} returns this + */ +proto.spec.proto.runtime.v1.StateOptions.prototype.setConcurrency = function(value) { + return jspb.Message.setProto3EnumField(this, 1, value); +}; + + +/** + * optional StateConsistency consistency = 2; + * @return {!proto.spec.proto.runtime.v1.StateOptions.StateConsistency} + */ +proto.spec.proto.runtime.v1.StateOptions.prototype.getConsistency = function() { + return /** @type {!proto.spec.proto.runtime.v1.StateOptions.StateConsistency} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {!proto.spec.proto.runtime.v1.StateOptions.StateConsistency} value + * @return {!proto.spec.proto.runtime.v1.StateOptions} returns this + */ +proto.spec.proto.runtime.v1.StateOptions.prototype.setConsistency = function(value) { + return jspb.Message.setProto3EnumField(this, 2, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.TransactionalStateOperation.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.TransactionalStateOperation.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.TransactionalStateOperation} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.TransactionalStateOperation.toObject = function(includeInstance, msg) { + var f, obj = { + operationtype: jspb.Message.getFieldWithDefault(msg, 1, ""), + request: (f = msg.getRequest()) && proto.spec.proto.runtime.v1.StateItem.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.TransactionalStateOperation} + */ +proto.spec.proto.runtime.v1.TransactionalStateOperation.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.TransactionalStateOperation; + return proto.spec.proto.runtime.v1.TransactionalStateOperation.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.TransactionalStateOperation} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.TransactionalStateOperation} + */ +proto.spec.proto.runtime.v1.TransactionalStateOperation.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setOperationtype(value); + break; + case 2: + var value = new proto.spec.proto.runtime.v1.StateItem; + reader.readMessage(value,proto.spec.proto.runtime.v1.StateItem.deserializeBinaryFromReader); + msg.setRequest(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.TransactionalStateOperation.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.TransactionalStateOperation.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.TransactionalStateOperation} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.TransactionalStateOperation.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getOperationtype(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getRequest(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.spec.proto.runtime.v1.StateItem.serializeBinaryToWriter + ); + } +}; + + +/** + * optional string operationType = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.TransactionalStateOperation.prototype.getOperationtype = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.TransactionalStateOperation} returns this + */ +proto.spec.proto.runtime.v1.TransactionalStateOperation.prototype.setOperationtype = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional StateItem request = 2; + * @return {?proto.spec.proto.runtime.v1.StateItem} + */ +proto.spec.proto.runtime.v1.TransactionalStateOperation.prototype.getRequest = function() { + return /** @type{?proto.spec.proto.runtime.v1.StateItem} */ ( + jspb.Message.getWrapperField(this, proto.spec.proto.runtime.v1.StateItem, 2)); +}; + + +/** + * @param {?proto.spec.proto.runtime.v1.StateItem|undefined} value + * @return {!proto.spec.proto.runtime.v1.TransactionalStateOperation} returns this +*/ +proto.spec.proto.runtime.v1.TransactionalStateOperation.prototype.setRequest = function(value) { + return jspb.Message.setWrapperField(this, 2, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.spec.proto.runtime.v1.TransactionalStateOperation} returns this + */ +proto.spec.proto.runtime.v1.TransactionalStateOperation.prototype.clearRequest = function() { + return this.setRequest(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.spec.proto.runtime.v1.TransactionalStateOperation.prototype.hasRequest = function() { + return jspb.Message.getField(this, 2) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest.repeatedFields_ = [2]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest.toObject = function(includeInstance, msg) { + var f, obj = { + storename: jspb.Message.getFieldWithDefault(msg, 1, ""), + operationsList: jspb.Message.toObjectList(msg.getOperationsList(), + proto.spec.proto.runtime.v1.TransactionalStateOperation.toObject, includeInstance), + metadataMap: (f = msg.getMetadataMap()) ? f.toObject(includeInstance, undefined) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest} + */ +proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest; + return proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest} + */ +proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStorename(value); + break; + case 2: + var value = new proto.spec.proto.runtime.v1.TransactionalStateOperation; + reader.readMessage(value,proto.spec.proto.runtime.v1.TransactionalStateOperation.deserializeBinaryFromReader); + msg.addOperations(value); + break; + case 3: + var value = msg.getMetadataMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStorename(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getOperationsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 2, + f, + proto.spec.proto.runtime.v1.TransactionalStateOperation.serializeBinaryToWriter + ); + } + f = message.getMetadataMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(3, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } +}; + + +/** + * optional string storeName = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest.prototype.getStorename = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest} returns this + */ +proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest.prototype.setStorename = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * repeated TransactionalStateOperation operations = 2; + * @return {!Array} + */ +proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest.prototype.getOperationsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.spec.proto.runtime.v1.TransactionalStateOperation, 2)); +}; + + +/** + * @param {!Array} value + * @return {!proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest} returns this +*/ +proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest.prototype.setOperationsList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 2, value); +}; + + +/** + * @param {!proto.spec.proto.runtime.v1.TransactionalStateOperation=} opt_value + * @param {number=} opt_index + * @return {!proto.spec.proto.runtime.v1.TransactionalStateOperation} + */ +proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest.prototype.addOperations = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 2, opt_value, proto.spec.proto.runtime.v1.TransactionalStateOperation, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest} returns this + */ +proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest.prototype.clearOperationsList = function() { + return this.setOperationsList([]); +}; + + +/** + * map metadata = 3; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest.prototype.getMetadataMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 3, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest} returns this + */ +proto.spec.proto.runtime.v1.ExecuteStateTransactionRequest.prototype.clearMetadataMap = function() { + this.getMetadataMap().clear(); + return this;}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.PublishEventRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.PublishEventRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.PublishEventRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.PublishEventRequest.toObject = function(includeInstance, msg) { + var f, obj = { + pubsubName: jspb.Message.getFieldWithDefault(msg, 1, ""), + topic: jspb.Message.getFieldWithDefault(msg, 2, ""), + data: msg.getData_asB64(), + dataContentType: jspb.Message.getFieldWithDefault(msg, 4, ""), + metadataMap: (f = msg.getMetadataMap()) ? f.toObject(includeInstance, undefined) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.PublishEventRequest} + */ +proto.spec.proto.runtime.v1.PublishEventRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.PublishEventRequest; + return proto.spec.proto.runtime.v1.PublishEventRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.PublishEventRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.PublishEventRequest} + */ +proto.spec.proto.runtime.v1.PublishEventRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setPubsubName(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setTopic(value); + break; + case 3: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setData(value); + break; + case 4: + var value = /** @type {string} */ (reader.readString()); + msg.setDataContentType(value); + break; + case 5: + var value = msg.getMetadataMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.PublishEventRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.PublishEventRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.PublishEventRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.PublishEventRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getPubsubName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getTopic(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getData_asU8(); + if (f.length > 0) { + writer.writeBytes( + 3, + f + ); + } + f = message.getDataContentType(); + if (f.length > 0) { + writer.writeString( + 4, + f + ); + } + f = message.getMetadataMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(5, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } +}; + + +/** + * optional string pubsub_name = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.PublishEventRequest.prototype.getPubsubName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.PublishEventRequest} returns this + */ +proto.spec.proto.runtime.v1.PublishEventRequest.prototype.setPubsubName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string topic = 2; + * @return {string} + */ +proto.spec.proto.runtime.v1.PublishEventRequest.prototype.getTopic = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.PublishEventRequest} returns this + */ +proto.spec.proto.runtime.v1.PublishEventRequest.prototype.setTopic = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional bytes data = 3; + * @return {!(string|Uint8Array)} + */ +proto.spec.proto.runtime.v1.PublishEventRequest.prototype.getData = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * optional bytes data = 3; + * This is a type-conversion wrapper around `getData()` + * @return {string} + */ +proto.spec.proto.runtime.v1.PublishEventRequest.prototype.getData_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getData())); +}; + + +/** + * optional bytes data = 3; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getData()` + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.PublishEventRequest.prototype.getData_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getData())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.spec.proto.runtime.v1.PublishEventRequest} returns this + */ +proto.spec.proto.runtime.v1.PublishEventRequest.prototype.setData = function(value) { + return jspb.Message.setProto3BytesField(this, 3, value); +}; + + +/** + * optional string data_content_type = 4; + * @return {string} + */ +proto.spec.proto.runtime.v1.PublishEventRequest.prototype.getDataContentType = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.PublishEventRequest} returns this + */ +proto.spec.proto.runtime.v1.PublishEventRequest.prototype.setDataContentType = function(value) { + return jspb.Message.setProto3StringField(this, 4, value); +}; + + +/** + * map metadata = 5; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.spec.proto.runtime.v1.PublishEventRequest.prototype.getMetadataMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 5, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.spec.proto.runtime.v1.PublishEventRequest} returns this + */ +proto.spec.proto.runtime.v1.PublishEventRequest.prototype.clearMetadataMap = function() { + this.getMetadataMap().clear(); + return this;}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.InvokeBindingRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.InvokeBindingRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.InvokeBindingRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.InvokeBindingRequest.toObject = function(includeInstance, msg) { + var f, obj = { + name: jspb.Message.getFieldWithDefault(msg, 1, ""), + data: msg.getData_asB64(), + metadataMap: (f = msg.getMetadataMap()) ? f.toObject(includeInstance, undefined) : [], + operation: jspb.Message.getFieldWithDefault(msg, 4, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.InvokeBindingRequest} + */ +proto.spec.proto.runtime.v1.InvokeBindingRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.InvokeBindingRequest; + return proto.spec.proto.runtime.v1.InvokeBindingRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.InvokeBindingRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.InvokeBindingRequest} + */ +proto.spec.proto.runtime.v1.InvokeBindingRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setName(value); + break; + case 2: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setData(value); + break; + case 3: + var value = msg.getMetadataMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + case 4: + var value = /** @type {string} */ (reader.readString()); + msg.setOperation(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.InvokeBindingRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.InvokeBindingRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.InvokeBindingRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.InvokeBindingRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getData_asU8(); + if (f.length > 0) { + writer.writeBytes( + 2, + f + ); + } + f = message.getMetadataMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(3, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } + f = message.getOperation(); + if (f.length > 0) { + writer.writeString( + 4, + f + ); + } +}; + + +/** + * optional string name = 1; + * @return {string} + */ +proto.spec.proto.runtime.v1.InvokeBindingRequest.prototype.getName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.InvokeBindingRequest} returns this + */ +proto.spec.proto.runtime.v1.InvokeBindingRequest.prototype.setName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional bytes data = 2; + * @return {!(string|Uint8Array)} + */ +proto.spec.proto.runtime.v1.InvokeBindingRequest.prototype.getData = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * optional bytes data = 2; + * This is a type-conversion wrapper around `getData()` + * @return {string} + */ +proto.spec.proto.runtime.v1.InvokeBindingRequest.prototype.getData_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getData())); +}; + + +/** + * optional bytes data = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getData()` + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.InvokeBindingRequest.prototype.getData_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getData())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.spec.proto.runtime.v1.InvokeBindingRequest} returns this + */ +proto.spec.proto.runtime.v1.InvokeBindingRequest.prototype.setData = function(value) { + return jspb.Message.setProto3BytesField(this, 2, value); +}; + + +/** + * map metadata = 3; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.spec.proto.runtime.v1.InvokeBindingRequest.prototype.getMetadataMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 3, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.spec.proto.runtime.v1.InvokeBindingRequest} returns this + */ +proto.spec.proto.runtime.v1.InvokeBindingRequest.prototype.clearMetadataMap = function() { + this.getMetadataMap().clear(); + return this;}; + + +/** + * optional string operation = 4; + * @return {string} + */ +proto.spec.proto.runtime.v1.InvokeBindingRequest.prototype.getOperation = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** + * @param {string} value + * @return {!proto.spec.proto.runtime.v1.InvokeBindingRequest} returns this + */ +proto.spec.proto.runtime.v1.InvokeBindingRequest.prototype.setOperation = function(value) { + return jspb.Message.setProto3StringField(this, 4, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.spec.proto.runtime.v1.InvokeBindingResponse.prototype.toObject = function(opt_includeInstance) { + return proto.spec.proto.runtime.v1.InvokeBindingResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spec.proto.runtime.v1.InvokeBindingResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.InvokeBindingResponse.toObject = function(includeInstance, msg) { + var f, obj = { + data: msg.getData_asB64(), + metadataMap: (f = msg.getMetadataMap()) ? f.toObject(includeInstance, undefined) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spec.proto.runtime.v1.InvokeBindingResponse} + */ +proto.spec.proto.runtime.v1.InvokeBindingResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spec.proto.runtime.v1.InvokeBindingResponse; + return proto.spec.proto.runtime.v1.InvokeBindingResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spec.proto.runtime.v1.InvokeBindingResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spec.proto.runtime.v1.InvokeBindingResponse} + */ +proto.spec.proto.runtime.v1.InvokeBindingResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setData(value); + break; + case 2: + var value = msg.getMetadataMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.InvokeBindingResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spec.proto.runtime.v1.InvokeBindingResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spec.proto.runtime.v1.InvokeBindingResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spec.proto.runtime.v1.InvokeBindingResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getData_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } + f = message.getMetadataMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(2, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } +}; + + +/** + * optional bytes data = 1; + * @return {!(string|Uint8Array)} + */ +proto.spec.proto.runtime.v1.InvokeBindingResponse.prototype.getData = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes data = 1; + * This is a type-conversion wrapper around `getData()` + * @return {string} + */ +proto.spec.proto.runtime.v1.InvokeBindingResponse.prototype.getData_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getData())); +}; + + +/** + * optional bytes data = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getData()` + * @return {!Uint8Array} + */ +proto.spec.proto.runtime.v1.InvokeBindingResponse.prototype.getData_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getData())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.spec.proto.runtime.v1.InvokeBindingResponse} returns this + */ +proto.spec.proto.runtime.v1.InvokeBindingResponse.prototype.setData = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + +/** + * map metadata = 2; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.spec.proto.runtime.v1.InvokeBindingResponse.prototype.getMetadataMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 2, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.spec.proto.runtime.v1.InvokeBindingResponse} returns this + */ +proto.spec.proto.runtime.v1.InvokeBindingResponse.prototype.clearMetadataMap = function() { + this.getMetadataMap().clear(); + return this;}; + + +goog.object.extend(exports, proto.spec.proto.runtime.v1); diff --git a/sdk/js-sdk/scripts/build-grpc.sh b/sdk/js-sdk/scripts/build-grpc.sh new file mode 100755 index 0000000000..878d8f1c5e --- /dev/null +++ b/sdk/js-sdk/scripts/build-grpc.sh @@ -0,0 +1,60 @@ +#!/bin/bash +OS=$(echo `uname`|tr '[:upper:]' '[:lower:]') +ARCH=$(uname -m) + +# Proto buf generation +PATH_ROOT=$(pwd) +PATH_PROTO_ROOT="${PATH_ROOT}/../../spec/proto/runtime/v1" +PATH_PROTO_OUTPUT="${PATH_ROOT}/proto" + +prerequisiteCheckProtobuf() { + if ! type "protoc" > /dev/null; then + echo "protoc is not installed, trying to install" + sudo apt update + sudo apt install -y protobuf-compiler + protoc --version + + prerequisiteCheckProtobuf + else + echo "protoc ($(protoc --version)) installed" + fi +} + +generateGrpc() { + PATH_PROTO=$1 + PATH_FILE=$2 + + echo "[protoc] Generating RPC for $PATH_PROTO/$PATH_FILE" + + # Tools to be installed by npm (see package.json) + # npm install grpc-tools --save-dev + # npm install grpc_tools_node_protoc_ts --save-dev + PROTOC_GEN_TS_PATH="${PATH_ROOT}/node_modules/.bin/protoc-gen-ts" + PROTOC_GEN_GRPC_PATH="${PATH_ROOT}/node_modules/.bin/grpc_tools_node_protoc_plugin" + + # commonjs + protoc \ + --proto_path="${PATH_PROTO}" \ + --plugin="protoc-gen-ts=${PROTOC_GEN_TS_PATH}" \ + --plugin=protoc-gen-grpc=${PROTOC_GEN_GRPC_PATH} \ + --js_out="import_style=commonjs,binary:$PATH_PROTO_OUTPUT" \ + --ts_out="grpc_js:$PATH_PROTO_OUTPUT" \ + --grpc_out="grpc_js:$PATH_PROTO_OUTPUT" \ + "$PATH_PROTO/$PATH_FILE" +} + +echo "Checking Dependencies" +prerequisiteCheckProtobuf + +echo "" +echo "Removing old Proto Files: ${PATH_PROTO_OUTPUT}" +rm -rf $PATH_PROTO_OUTPUT +mkdir -p $PATH_PROTO_OUTPUT + +echo "" +echo "Compiling gRPC files" +generateGrpc $PATH_PROTO_ROOT "runtime.proto" +generateGrpc $PATH_PROTO_ROOT "appcallback.proto" + +echo "" +echo "DONE" diff --git a/sdk/js-sdk/src/API.ts b/sdk/js-sdk/src/API.ts new file mode 100644 index 0000000000..8d34a380c4 --- /dev/null +++ b/sdk/js-sdk/src/API.ts @@ -0,0 +1,8 @@ +import { RuntimeClient } from '../proto/runtime_grpc_pb'; + +export default class API { + readonly runtime: RuntimeClient; + constructor(runtime: RuntimeClient) { + this.runtime = runtime; + } +} diff --git a/sdk/js-sdk/src/Client.ts b/sdk/js-sdk/src/Client.ts new file mode 100644 index 0000000000..0d71ae217b --- /dev/null +++ b/sdk/js-sdk/src/Client.ts @@ -0,0 +1,31 @@ +import { ChannelCredentials } from '@grpc/grpc-js'; +import { RuntimeClient } from '../proto/runtime_grpc_pb'; +import State from './State'; +import Hello from './Hello'; + +export default class Client { + readonly port: string; + readonly runtime: RuntimeClient; + readonly hello: Hello; + // readonly pubsub: IClientPubSub; + readonly state: State; + // readonly binding: IClientBinding; + // readonly invoker: IClientInvoker; + // readonly secret: IClientSecret; + // readonly actor: IClientActor; + + constructor(port: string = process.env.runtime_GRPC_PORT || '34904') { + this.port = port; + const clientCredentials = ChannelCredentials.createInsecure(); + + console.log(`[Layotto-JS] Start connection to port:${this.port}`); + this.runtime = new RuntimeClient(`127.0.0.1:${this.port}`, clientCredentials); + this.hello = new Hello(this.runtime); + this.state = new State(this.runtime); + // this.pubsub = new GRPCClientPubSub(client); + // this.binding = new GRPCClientBinding(client); + // this.invoker = new GRPCClientInvoker(client); + // this.secret = new GRPCClientSecret(client); + // this.actor = new GRPCClientActor(client); + } +} diff --git a/sdk/js-sdk/src/Hello.ts b/sdk/js-sdk/src/Hello.ts new file mode 100644 index 0000000000..b0c28e5f2b --- /dev/null +++ b/sdk/js-sdk/src/Hello.ts @@ -0,0 +1,21 @@ +import { + SayHelloRequest +} from '../proto/runtime_pb'; +import API from './API'; + +export default class Hello extends API { + async sayHello(serviceName = 'helloworld', name = ''): Promise { + const req = new SayHelloRequest(); + req.setServiceName(serviceName); + if (name) { + req.setName(name); + } + + return new Promise((resolve, reject) => { + this.runtime.sayHello(req, (err, res) => { + if (err) return reject(err); + resolve(res.getHello()); + }); + }); + } +} diff --git a/sdk/js-sdk/src/State.ts b/sdk/js-sdk/src/State.ts new file mode 100644 index 0000000000..192e1a0367 --- /dev/null +++ b/sdk/js-sdk/src/State.ts @@ -0,0 +1,123 @@ +import { + SaveStateRequest, + StateItem as StateItemPB, + Etag as ETagTB, + StateOptions as StateOptionsPB, + GetStateRequest, + GetBulkStateRequest, +} from '../proto/runtime_pb'; +import API from './API'; + +export type StateConcurrency = StateOptionsPB.StateConcurrency; +export type StateConsistency = StateOptionsPB.StateConsistency; + +type StateOptions = { + concurrency: StateConcurrency; + consistency: StateConsistency; +}; + +type Metadata = { + [key: string]: string; +}; + +type StateItem = { + key: string; + value: Uint8Array | string; + etag?: string; + metadata?: Metadata; + options?: StateOptions; +} + +type BulkResponseStateItem = { + key: string; + value: Uint8Array; + etag: string; +} + +export default class State extends API { + // Saves an array of state objects + async save(storeName: string, states: StateItem[] | StateItem): Promise { + const stateList: StateItemPB[] = []; + if (!Array.isArray(states)) { + states = [states]; + } + for (const item of states) { + const stateItem = new StateItemPB(); + stateItem.setKey(item.key); + if (typeof item.value === 'string') { + stateItem.setValue(Buffer.from(item.value, 'utf8')); + } else { + stateItem.setValue(item.value); + } + if (item.etag !== undefined) { + const etag = new ETagTB(); + etag.setValue(item.etag); + stateItem.setEtag(etag); + } + if (item.options !== undefined) { + const options = new StateOptionsPB(); + options.setConcurrency(item.options.concurrency); + } + stateList.push(stateItem); + } + + const req = new SaveStateRequest(); + req.setStoreName(storeName); + req.setStatesList(stateList); + + return new Promise((resolve, reject) => { + this.runtime.saveState(req, (err) => { + if (err) return reject(err); + resolve(); + }); + }); + } + + // Gets the state for a specific key + async get(storeName: string, key: string): Promise { + const req = new GetStateRequest(); + req.setStoreName(storeName); + req.setKey(key); + + return new Promise((resolve, reject) => { + this.runtime.getState(req, (err, res) => { + if (err) return reject(err); + resolve(res.getData_asU8()); + }); + }); + } + + // Gets a bulk of state items for a list of keys + async getBulk(storeName: string, keys: string[], parallelism = 10): Promise { + const req = new GetBulkStateRequest(); + req.setStoreName(storeName); + req.setKeysList(keys); + req.setParallelism(parallelism); + + return new Promise((resolve, reject) => { + this.runtime.getBulkState(req, (err, res) => { + if (err) return reject(err); + const states: BulkResponseStateItem[] = []; + const itemsList = res.getItemsList(); + for (const item of itemsList) { + states.push({ + key: item.getKey(), + value: item.getData_asU8(), + etag: item.getEtag(), + }); + } + resolve(states); + }); + }); + } + + // Deletes the state for a specific key + async delete() { + + } + + // Deletes a bulk of state items for a list of keys + async deleteBulk() {} + + // async transaction() {} +} diff --git a/sdk/js-sdk/src/index.ts b/sdk/js-sdk/src/index.ts new file mode 100644 index 0000000000..98de5d811d --- /dev/null +++ b/sdk/js-sdk/src/index.ts @@ -0,0 +1,5 @@ +import Client from './Client'; + +export { + Client +} diff --git a/sdk/js-sdk/test/unit/Client.test.ts b/sdk/js-sdk/test/unit/Client.test.ts new file mode 100644 index 0000000000..ce892da308 --- /dev/null +++ b/sdk/js-sdk/test/unit/Client.test.ts @@ -0,0 +1,17 @@ +import { strict as assert } from 'assert'; +import { Client } from '../../src'; + +describe('Client.test.ts', () => { + let client: Client; + beforeAll(async () => { + client = new Client(); + const hello = await client.hello.sayHello(); + assert.equal(hello, 'greeting, '); + }); + + it('should create a Client with default port', () => { + assert.equal(client.port, '34904'); + assert(client.runtime); + assert(client.state); + }); +}); diff --git a/sdk/js-sdk/test/unit/State.test.ts b/sdk/js-sdk/test/unit/State.test.ts new file mode 100644 index 0000000000..081d917e1c --- /dev/null +++ b/sdk/js-sdk/test/unit/State.test.ts @@ -0,0 +1,51 @@ +import { strict as assert } from 'assert'; +import { Client } from '../../src'; + +describe('State.test.ts', () => { + let client: Client; + const storeName = 'redis'; + + beforeAll(async () => { + client = new Client(); + }); + + it('should save one item and get key success', async () => { + const key = 'js-sdk-unit-' + Date.now(); + const value = `hello js-sdk, with 中文, 😄, at ${Date()}`; + await client.state.save(storeName, [ + { key, value }, + ]); + const resValue = await client.state.get(storeName, key); + assert.equal(Buffer.from(resValue).toString(), value); + + await client.state.save(storeName, { key, value }); + const resValue2 = await client.state.get(storeName, key); + assert.equal(Buffer.from(resValue2).toString(), value); + }); + + it('should save many items and get them success', async () => { + const items: { key: string, value: string }[] = []; + for (let i = 0; i < 20; i++) { + const key = `key${i}:js-sdk-unit-${Date.now()}`; + const value = `key${i}:hello js-sdk, with 中文, 😄, at ${Date()}`; + items.push({ key, value }); + } + await client.state.save(storeName, items); + + for (const { key, value } of items) { + const resValue = await client.state.get(storeName, key); + assert.equal(Buffer.from(resValue).toString(), value); + } + + const keys = items.map(i => i.key); + const states = await client.state.getBulk(storeName, keys); + assert.equal(states.length, items.length); + for (let i = 0; i < states.length; i++) { + const state = states[i]; + const item = items.find(i => i.key === state.key); + assert(item); + assert.equal(state.key, item.key); + assert.equal(Buffer.from(state.value).toString(), item.value); + } + }); +}); diff --git a/sdk/js-sdk/tsconfig.json b/sdk/js-sdk/tsconfig.json new file mode 100644 index 0000000000..75dee290f3 --- /dev/null +++ b/sdk/js-sdk/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "@eggjs/tsconfig", + "compilerOptions": { + "rootDir": "./src", + "outDir": "./dist", + "module": "CommonJS", + "moduleResolution": "Node" + }, + "include": [ "src" ], + "exclude": ["node_modules", "**/test/*"] +} From b1ab5ec3bb7f694179ffe2338ce17c90b507a0aa Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sun, 24 Oct 2021 14:11:52 +0800 Subject: [PATCH 02/13] feat(js-sdk): First impl for the State API See https://mosn.io/layotto/#/zh/building_blocks/state/reference --- .gitignore | 2 +- sdk/js-sdk/README.md | 3 +- sdk/js-sdk/demo/package.json | 3 + sdk/js-sdk/demo/state.js | 5 +- sdk/js-sdk/demo/state.mjs | 5 +- sdk/js-sdk/demo/state.ts | 12 +- sdk/js-sdk/package.json | 2 +- sdk/js-sdk/src/API.ts | 16 ++- sdk/js-sdk/src/Hello.ts | 6 +- sdk/js-sdk/src/State.ts | 184 +++++++++++++++++++---------- sdk/js-sdk/src/types/State.ts | 42 +++++++ sdk/js-sdk/test/unit/State.test.ts | 154 ++++++++++++++++++------ 12 files changed, 322 insertions(+), 112 deletions(-) create mode 100644 sdk/js-sdk/src/types/State.ts diff --git a/.gitignore b/.gitignore index e71b0c8753..45ed23a68f 100644 --- a/.gitignore +++ b/.gitignore @@ -14,5 +14,5 @@ logs/ /cover.out vendor/ demo/state/redis/client -sdk/js-sdk/node_modules +node_modules/ sdk/js-sdk/dist diff --git a/sdk/js-sdk/README.md b/sdk/js-sdk/README.md index e252191eab..3dcf87644e 100644 --- a/sdk/js-sdk/README.md +++ b/sdk/js-sdk/README.md @@ -19,7 +19,8 @@ await client.state.save(storeName, { key, value }); console.log('saveState success, key: %j, value: %j', key, value); const resValue = await client.state.get(storeName, key); -console.log('getState success, key: %j, value: %j, toString: %j', key, resValue, Buffer.from(resValue).toString('utf8')); +console.log('getState success, key: %j, value: %j, toString: %j', + key, resValue, Buffer.from(resValue).toString('utf8')); ``` ## Development diff --git a/sdk/js-sdk/demo/package.json b/sdk/js-sdk/demo/package.json index 09481ddaae..e34d7c63fd 100644 --- a/sdk/js-sdk/demo/package.json +++ b/sdk/js-sdk/demo/package.json @@ -8,5 +8,8 @@ "test:cjs": "node ./state.js", "test:esm": "node ./state.mjs", "test:ts": "ts-node ./state.ts" + }, + "dependencies": { + "layotto": "^0.0.1" } } diff --git a/sdk/js-sdk/demo/state.js b/sdk/js-sdk/demo/state.js index 5e0d5bbf7c..99a61a390c 100644 --- a/sdk/js-sdk/demo/state.js +++ b/sdk/js-sdk/demo/state.js @@ -14,8 +14,9 @@ async function main() { ]); console.log('saveState success, key: %j, value: %j', key, value); - const resValue = await client.state.get(storeName, key); - console.log('getState success, key: %j, value: %j, toString: %j', key, resValue, Buffer.from(resValue).toString('utf8')); + const state = await client.state.get(storeName, key); + console.log('getState success, key: %j, value: %j, toString: %j', + key, state.value, Buffer.from(state.value).toString('utf8')); } main(); diff --git a/sdk/js-sdk/demo/state.mjs b/sdk/js-sdk/demo/state.mjs index d812be561d..26c418e415 100644 --- a/sdk/js-sdk/demo/state.mjs +++ b/sdk/js-sdk/demo/state.mjs @@ -14,8 +14,9 @@ async function main() { ]); console.log('saveState success, key: %j, value: %j', key, value); - const resValue = await client.state.get(storeName, key); - console.log('getState success, key: %j, value: %j, toString: %j', key, resValue, Buffer.from(resValue).toString('utf8')); + const state = await client.state.get(storeName, key); + console.log('getState success, key: %j, value: %j, toString: %j', + key, state.value, Buffer.from(state.value).toString('utf8')); } main(); diff --git a/sdk/js-sdk/demo/state.ts b/sdk/js-sdk/demo/state.ts index 0aab508ccc..2fbbc2a5a3 100644 --- a/sdk/js-sdk/demo/state.ts +++ b/sdk/js-sdk/demo/state.ts @@ -11,14 +11,16 @@ async function main() { await client.state.save(storeName, [ { key, value }, - ]); + ], { traceid: 'mock-tracerid-123123' }); console.log('saveState success, key: %j, value: %j', key, value); - await client.state.save(storeName, { key, value }); - console.log('saveState success, key: %j, value: %j', key, value); + // await client.state.save(storeName, { key, value }); + // console.log('saveState success, key: %j, value: %j', key, value); - const resValue = await client.state.get(storeName, key); - console.log('getState success, key: %j, value: %j, toString: %j', key, resValue, Buffer.from(resValue).toString('utf8')); + const state = await client.state.get(storeName, key); + assert(state); + console.log('getState success, key: %j, value: %j, toString: %j', + key, state.value, Buffer.from(state.value).toString('utf8')); } main(); diff --git a/sdk/js-sdk/package.json b/sdk/js-sdk/package.json index 340d04b179..1c83e506d5 100644 --- a/sdk/js-sdk/package.json +++ b/sdk/js-sdk/package.json @@ -1,6 +1,6 @@ { "name": "layotto", - "version": "0.0.0", + "version": "0.0.1", "description": "Layotto Node.js SDK", "main": "dist/index.js", "files": [ diff --git a/sdk/js-sdk/src/API.ts b/sdk/js-sdk/src/API.ts index 8d34a380c4..8e7942d85b 100644 --- a/sdk/js-sdk/src/API.ts +++ b/sdk/js-sdk/src/API.ts @@ -1,8 +1,22 @@ +import { Metadata } from '@grpc/grpc-js'; import { RuntimeClient } from '../proto/runtime_grpc_pb'; -export default class API { +// gRPC meta data +export type RequestMetadata = { + [key: string]: string; +}; + +export class API { readonly runtime: RuntimeClient; constructor(runtime: RuntimeClient) { this.runtime = runtime; } + + createMetadata(meta?: RequestMetadata) { + const metadata = new Metadata(); + for (const key in meta) { + metadata.add(key, meta[key]); + } + return metadata; + } } diff --git a/sdk/js-sdk/src/Hello.ts b/sdk/js-sdk/src/Hello.ts index b0c28e5f2b..4316f69572 100644 --- a/sdk/js-sdk/src/Hello.ts +++ b/sdk/js-sdk/src/Hello.ts @@ -1,10 +1,10 @@ import { SayHelloRequest } from '../proto/runtime_pb'; -import API from './API'; +import { API, RequestMetadata } from './API'; export default class Hello extends API { - async sayHello(serviceName = 'helloworld', name = ''): Promise { + async sayHello(serviceName = 'helloworld', name = '', meta?: RequestMetadata): Promise { const req = new SayHelloRequest(); req.setServiceName(serviceName); if (name) { @@ -12,7 +12,7 @@ export default class Hello extends API { } return new Promise((resolve, reject) => { - this.runtime.sayHello(req, (err, res) => { + this.runtime.sayHello(req, this.createMetadata(meta), (err, res) => { if (err) return reject(err); resolve(res.getHello()); }); diff --git a/sdk/js-sdk/src/State.ts b/sdk/js-sdk/src/State.ts index 192e1a0367..41c7e4e1c9 100644 --- a/sdk/js-sdk/src/State.ts +++ b/sdk/js-sdk/src/State.ts @@ -1,72 +1,37 @@ import { SaveStateRequest, StateItem as StateItemPB, - Etag as ETagTB, + Etag, StateOptions as StateOptionsPB, GetStateRequest, GetBulkStateRequest, + DeleteStateRequest, + DeleteBulkStateRequest, + ExecuteStateTransactionRequest, + TransactionalStateOperation, } from '../proto/runtime_pb'; -import API from './API'; - -export type StateConcurrency = StateOptionsPB.StateConcurrency; -export type StateConsistency = StateOptionsPB.StateConsistency; - -type StateOptions = { - concurrency: StateConcurrency; - consistency: StateConsistency; -}; - -type Metadata = { - [key: string]: string; -}; - -type StateItem = { - key: string; - value: Uint8Array | string; - etag?: string; - metadata?: Metadata; - options?: StateOptions; -} - -type BulkResponseStateItem = { - key: string; - value: Uint8Array; - etag: string; -} +import { API, RequestMetadata } from './API'; +import { + DeleteStateItem, + ResponseStateItem, + StateItem, + StateOperation, + StateOptions, +} from './types/State'; export default class State extends API { // Saves an array of state objects - async save(storeName: string, states: StateItem[] | StateItem): Promise { - const stateList: StateItemPB[] = []; + async save(storeName: string, states: StateItem[] | StateItem, meta?: RequestMetadata): Promise { if (!Array.isArray(states)) { states = [states]; } - for (const item of states) { - const stateItem = new StateItemPB(); - stateItem.setKey(item.key); - if (typeof item.value === 'string') { - stateItem.setValue(Buffer.from(item.value, 'utf8')); - } else { - stateItem.setValue(item.value); - } - if (item.etag !== undefined) { - const etag = new ETagTB(); - etag.setValue(item.etag); - stateItem.setEtag(etag); - } - if (item.options !== undefined) { - const options = new StateOptionsPB(); - options.setConcurrency(item.options.concurrency); - } - stateList.push(stateItem); - } - + const stateList = this.createStateItemPBList(states); const req = new SaveStateRequest(); req.setStoreName(storeName); req.setStatesList(stateList); return new Promise((resolve, reject) => { - this.runtime.saveState(req, (err) => { + this.runtime.saveState(req, this.createMetadata(meta), (err) => { if (err) return reject(err); resolve(); }); @@ -74,36 +39,47 @@ export default class State extends API { } // Gets the state for a specific key - async get(storeName: string, key: string): Promise { + async get(storeName: string, key: string, meta?: RequestMetadata): Promise { const req = new GetStateRequest(); req.setStoreName(storeName); req.setKey(key); return new Promise((resolve, reject) => { - this.runtime.getState(req, (err, res) => { + this.runtime.getState(req, this.createMetadata(meta), (err, res) => { if (err) return reject(err); - resolve(res.getData_asU8()); + if (this.isEmpty(res)) { + return resolve(null); + } + resolve({ + key, + value: res.getData_asU8(), + etag: res.getEtag(), + }); }); }); } // Gets a bulk of state items for a list of keys - async getBulk(storeName: string, keys: string[], parallelism = 10): Promise { + async getBulk(storeName: string, keys: string[], parallelism = 10, meta?: RequestMetadata): Promise { const req = new GetBulkStateRequest(); req.setStoreName(storeName); req.setKeysList(keys); req.setParallelism(parallelism); return new Promise((resolve, reject) => { - this.runtime.getBulkState(req, (err, res) => { + this.runtime.getBulkState(req, this.createMetadata(meta), (err, res) => { if (err) return reject(err); - const states: BulkResponseStateItem[] = []; + const states: ResponseStateItem[] = []; const itemsList = res.getItemsList(); for (const item of itemsList) { + if (this.isEmpty(item)) { + continue; + } states.push({ key: item.getKey(), value: item.getData_asU8(), etag: item.getEtag(), + // metadata: item.getMetadataMap(), }); } resolve(states); @@ -112,12 +88,100 @@ export default class State extends API { } // Deletes the state for a specific key - async delete() { + async delete(storeName: string, key: string, etag = '', options?: StateOptions, meta?: RequestMetadata): Promise { + const req = new DeleteStateRequest(); + req.setStoreName(storeName); + req.setKey(key); + if (etag) { + const etagInstance = new Etag(); + etagInstance.setValue(etag); + req.setEtag(etagInstance); + } + if (options) { + const optionsInstance = new StateOptionsPB(); + optionsInstance.setConcurrency(options.concurrency); + optionsInstance.setConsistency(options.consistency); + req.setOptions(optionsInstance); + } + return new Promise((resolve, reject) => { + this.runtime.deleteState(req, this.createMetadata(meta), (err) => { + if (err) return reject(err); + resolve(); + }); + }); } // Deletes a bulk of state items for a list of keys - async deleteBulk() {} + async deleteBulk(storeName: string, states: DeleteStateItem[], meta?: RequestMetadata): Promise { + const req = new DeleteBulkStateRequest(); + req.setStoreName(storeName); + const stateList = this.createStateItemPBList(states); + req.setStatesList(stateList); + + return new Promise((resolve, reject) => { + this.runtime.deleteBulkState(req, this.createMetadata(meta), (err) => { + if (err) return reject(err); + resolve(); + }); + }); + } + + // Executes transactions for a specified store + async executeTransaction(storeName: string, operations: StateOperation[], meta?: RequestMetadata): Promise { + const req = new ExecuteStateTransactionRequest(); + req.setStorename(storeName); + const operationsList: TransactionalStateOperation[] = []; + for (const operation of operations) { + const ops = new TransactionalStateOperation(); + ops.setOperationtype(operation.operationType); + const stateItem = this.createStateItemPB(operation.request); + ops.setRequest(stateItem); + operationsList.push(ops); + } + req.setOperationsList(operationsList); + + return new Promise((resolve, reject) => { + this.runtime.executeStateTransaction(req, this.createMetadata(meta), (err, _res) => { + if (err) return reject(err); + resolve(); + }); + }); + } - // async transaction() {} + private createStateItemPB(item: StateItem | DeleteStateItem): StateItemPB { + const stateItem = new StateItemPB(); + stateItem.setKey(item.key); + if ('value' in item) { + if (typeof item.value === 'string') { + stateItem.setValue(Buffer.from(item.value, 'utf8')); + } else { + stateItem.setValue(item.value); + } + } + if (item.etag !== undefined) { + const etag = new Etag(); + etag.setValue(item.etag); + stateItem.setEtag(etag); + } + if (item.options !== undefined) { + const options = new StateOptionsPB(); + options.setConcurrency(item.options.concurrency); + options.setConsistency(item.options.consistency); + stateItem.setOptions(options); + } + return stateItem; + } + + private createStateItemPBList(items: StateItem[] | DeleteStateItem[]): StateItemPB[] { + const list: StateItemPB[] = []; + for (const item of items) { + list.push(this.createStateItemPB(item)); + } + return list; + } + + private isEmpty(obj: { getEtag(): string }) { + return obj.getEtag() === ''; + } } diff --git a/sdk/js-sdk/src/types/State.ts b/sdk/js-sdk/src/types/State.ts new file mode 100644 index 0000000000..b7beb5ec4c --- /dev/null +++ b/sdk/js-sdk/src/types/State.ts @@ -0,0 +1,42 @@ +import { + StateOptions as StateOptionsPB, +} from '../../proto/runtime_pb'; + +export type StateConcurrency = StateOptionsPB.StateConcurrency; +export type StateConsistency = StateOptionsPB.StateConsistency; + +export type StateOptions = { + concurrency: StateConcurrency; + consistency: StateConsistency; +}; + +export type StateItem = { + key: string; + value: Uint8Array | string; + etag?: string; + options?: StateOptions; +} + +export type DeleteStateItem = { + key: string; + etag?: string; + options?: StateOptions; +}; + +export type ResponseStateItem = { + key: string; + value: Uint8Array; + etag: string; + // metadata; +} + +export enum StateOperationType { + Upsert = 'upsert', + Delete = 'delete', +} + +export type StateOperation = { + operationType: StateOperationType; + request: StateItem | DeleteStateItem; +}; + diff --git a/sdk/js-sdk/test/unit/State.test.ts b/sdk/js-sdk/test/unit/State.test.ts index 081d917e1c..6218058b1a 100644 --- a/sdk/js-sdk/test/unit/State.test.ts +++ b/sdk/js-sdk/test/unit/State.test.ts @@ -1,5 +1,6 @@ import { strict as assert } from 'assert'; import { Client } from '../../src'; +import { StateOperation, StateOperationType } from '../../src/types/State'; describe('State.test.ts', () => { let client: Client; @@ -9,43 +10,124 @@ describe('State.test.ts', () => { client = new Client(); }); - it('should save one item and get key success', async () => { - const key = 'js-sdk-unit-' + Date.now(); - const value = `hello js-sdk, with 中文, 😄, at ${Date()}`; - await client.state.save(storeName, [ - { key, value }, - ]); - const resValue = await client.state.get(storeName, key); - assert.equal(Buffer.from(resValue).toString(), value); - - await client.state.save(storeName, { key, value }); - const resValue2 = await client.state.get(storeName, key); - assert.equal(Buffer.from(resValue2).toString(), value); + describe('get(), getBulk()', () => { + it('should get not exists key', async () => { + const key = 'js-sdk-unit-notexists-' + Date.now(); + const state = await client.state.get(storeName, key); + assert.equal(state, null); + }); + + it('should get empty value', async () => { + const key = 'js-sdk-unit-empty-' + Date.now(); + await client.state.save(storeName, { key, value: '' }); + const state = await client.state.get(storeName, key); + assert(state); + assert.equal(state.value.length, 0); + assert.equal(state.key, key); + assert.equal(state.etag, '1'); + }); + + it('should save one item and get key success', async () => { + const key = 'js-sdk-unit-' + Date.now(); + const value = `hello js-sdk, with 中文, 😄, at ${Date()}`; + await client.state.save(storeName, { key, value }, { traceid: `mock-traceid-unittest-${Date.now()}` }); + const state = await client.state.get(storeName, key); + assert(state); + assert.equal(Buffer.from(state.value).toString(), value); + + await client.state.save(storeName, { key, value }); + const state2 = await client.state.get(storeName, key); + assert(state2); + assert.equal(Buffer.from(state2.value).toString(), value); + }); + + it('should save bulk items and get them success', async () => { + const items: { key: string, value: string }[] = []; + for (let i = 0; i < 20; i++) { + const key = `key${i}:js-sdk-unit-${Date.now()}`; + const value = `key${i}:hello js-sdk, with 中文, 😄, at ${Date()}`; + items.push({ key, value }); + } + await client.state.save(storeName, items); + + for (const { key, value } of items) { + const state = await client.state.get(storeName, key); + assert(state); + assert.equal(Buffer.from(state.value).toString(), value); + } + + const keys = items.map(i => i.key); + const states = await client.state.getBulk(storeName, keys); + assert.equal(states.length, items.length); + for (let i = 0; i < states.length; i++) { + const state = states[i]; + const item = items.find(i => i.key === state.key); + assert(item); + assert.equal(state.key, item.key); + assert.equal(Buffer.from(state.value).toString(), item.value); + } + + const states2 = await client.state.getBulk(storeName, keys, undefined, { foo: 'bar' }); + assert.equal(states2.length, items.length); + }); + }); + + describe('delete(), deleteBulk()', () => { + it('should delete one key success', async () => { + const key = 'js-sdk-unit-delete-' + Date.now(); + // delete not exists + await client.state.delete(storeName, key); + + const value = `hello js-sdk, with 中文, 😄, at ${Date()}`; + await client.state.save(storeName, { key, value }); + + // delete exists + await client.state.delete(storeName, key); + + const state = await client.state.get(storeName, key); + assert.equal(state, null); + }); + + it('should delete bulk keys success', async () => { + const items: { key: string, value: string }[] = []; + const keys: { key: string }[] = []; + for (let i = 0; i < 20; i++) { + const key = `key${i}:js-sdk-unit-delete-bulk-${Date.now()}`; + const value = `key${i}:hello js-sdk, with 中文, 😄, at ${Date()}`; + items.push({ key, value }); + keys.push({ key }); + } + // delete not exists + await client.state.deleteBulk(storeName, keys); + + await client.state.save(storeName, items); + + // delete exists + await client.state.deleteBulk(storeName, keys); + + const states = await client.state.getBulk(storeName, keys.map(i => i.key)); + assert.equal(states.length, 0); + }); }); - it('should save many items and get them success', async () => { - const items: { key: string, value: string }[] = []; - for (let i = 0; i < 20; i++) { - const key = `key${i}:js-sdk-unit-${Date.now()}`; - const value = `key${i}:hello js-sdk, with 中文, 😄, at ${Date()}`; - items.push({ key, value }); - } - await client.state.save(storeName, items); - - for (const { key, value } of items) { - const resValue = await client.state.get(storeName, key); - assert.equal(Buffer.from(resValue).toString(), value); - } - - const keys = items.map(i => i.key); - const states = await client.state.getBulk(storeName, keys); - assert.equal(states.length, items.length); - for (let i = 0; i < states.length; i++) { - const state = states[i]; - const item = items.find(i => i.key === state.key); - assert(item); - assert.equal(state.key, item.key); - assert.equal(Buffer.from(state.value).toString(), item.value); - } + describe('executeTransaction()', () => { + it('should upsert then delete success', async () => { + const operations: StateOperation[] = []; + const keys: { key: string }[] = []; + for (let i = 0; i < 20; i++) { + const key = `key${i}:js-sdk-unit-upsert-bulk-${Date.now()}`; + const value = `key${i}:hello js-sdk, with 中文, 😄, at ${Date()}`; + operations.push({ + operationType: StateOperationType.Upsert, + request: { key, value }, + }); + keys.push({ key }); + } + // not work now: mosn error + // 2021-10-24 14:06:52,590 [ERROR] [mosn.proxy.panic] [grpc] [unary] grpc unary handle panic: interface conversion: interface {} is *state.SetRequest, not state.SetRequest, method: /spec.proto.runtime.v1.Runtime/ExecuteStateTransaction, stack:goroutine 8213 [running]: + await client.state.executeTransaction(storeName, operations); + // const states = await client.state.getBulk(storeName, keys.map(i => i.key)); + // assert.equal(states.length, 20); + }); }); }); From 53862d530ee865cb1213375c513296ab7d541cc8 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sun, 24 Oct 2021 21:14:16 +0800 Subject: [PATCH 03/13] feat(js-sdk): Impl Lock API --- sdk/js-sdk/README.md | 6 ++++ sdk/js-sdk/demo/package.json | 1 + sdk/js-sdk/demo/rpc/http/server.js | 10 +++++++ sdk/js-sdk/package.json | 2 +- sdk/js-sdk/src/Client.ts | 13 ++++----- sdk/js-sdk/src/Invoker.ts | 41 +++++++++++++++++++++++++++ sdk/js-sdk/src/Lock.ts | 40 ++++++++++++++++++++++++++ sdk/js-sdk/src/types/Invoker.ts | 3 ++ sdk/js-sdk/src/types/Lock.ts | 3 ++ sdk/js-sdk/src/utils.ts | 5 ++++ sdk/js-sdk/test/unit/Invoker.test.ts | 26 +++++++++++++++++ sdk/js-sdk/test/unit/Lock.test.ts | 42 ++++++++++++++++++++++++++++ 12 files changed, 184 insertions(+), 8 deletions(-) create mode 100644 sdk/js-sdk/demo/rpc/http/server.js create mode 100644 sdk/js-sdk/src/Invoker.ts create mode 100644 sdk/js-sdk/src/Lock.ts create mode 100644 sdk/js-sdk/src/types/Invoker.ts create mode 100644 sdk/js-sdk/src/types/Lock.ts create mode 100644 sdk/js-sdk/src/utils.ts create mode 100644 sdk/js-sdk/test/unit/Invoker.test.ts create mode 100644 sdk/js-sdk/test/unit/Lock.test.ts diff --git a/sdk/js-sdk/README.md b/sdk/js-sdk/README.md index 3dcf87644e..bbc51d6406 100644 --- a/sdk/js-sdk/README.md +++ b/sdk/js-sdk/README.md @@ -55,3 +55,9 @@ go build ```bash npm run test:unit ``` + +Enable trace debug log for grpc-js: + +```bash +GRPC_TRACE=compression GRPC_VERBOSITY=debug GRPC_TRACE=all npm run test test/unit/Invoker.test.ts +``` diff --git a/sdk/js-sdk/demo/package.json b/sdk/js-sdk/demo/package.json index e34d7c63fd..ab460ed026 100644 --- a/sdk/js-sdk/demo/package.json +++ b/sdk/js-sdk/demo/package.json @@ -10,6 +10,7 @@ "test:ts": "ts-node ./state.ts" }, "dependencies": { + "koa": "^2.13.4", "layotto": "^0.0.1" } } diff --git a/sdk/js-sdk/demo/rpc/http/server.js b/sdk/js-sdk/demo/rpc/http/server.js new file mode 100644 index 0000000000..36f26aa618 --- /dev/null +++ b/sdk/js-sdk/demo/rpc/http/server.js @@ -0,0 +1,10 @@ +const Koa = require('koa'); +const app = new Koa(); + +// response +app.use(ctx => { + console.log('%s %s, headers: %j', ctx.method, ctx.url, ctx.headers); + ctx.body = 'Hello Koa'; +}); + +app.listen(8889); diff --git a/sdk/js-sdk/package.json b/sdk/js-sdk/package.json index 1c83e506d5..c5fa7968e5 100644 --- a/sdk/js-sdk/package.json +++ b/sdk/js-sdk/package.json @@ -50,7 +50,7 @@ }, "dependencies": { "@grpc/grpc-js": "^1.4.1", - "google-protobuf": "^3.19.0-rc.1" + "google-protobuf": "^3.19.0" }, "engines": { "node": ">=14.0.0" diff --git a/sdk/js-sdk/src/Client.ts b/sdk/js-sdk/src/Client.ts index 0d71ae217b..85c3f89055 100644 --- a/sdk/js-sdk/src/Client.ts +++ b/sdk/js-sdk/src/Client.ts @@ -2,6 +2,8 @@ import { ChannelCredentials } from '@grpc/grpc-js'; import { RuntimeClient } from '../proto/runtime_grpc_pb'; import State from './State'; import Hello from './Hello'; +import Invoker from './Invoker'; +import Lock from './Lock'; export default class Client { readonly port: string; @@ -9,8 +11,8 @@ export default class Client { readonly hello: Hello; // readonly pubsub: IClientPubSub; readonly state: State; - // readonly binding: IClientBinding; - // readonly invoker: IClientInvoker; + readonly invoker: Invoker; + readonly lock: Lock; // readonly secret: IClientSecret; // readonly actor: IClientActor; @@ -22,10 +24,7 @@ export default class Client { this.runtime = new RuntimeClient(`127.0.0.1:${this.port}`, clientCredentials); this.hello = new Hello(this.runtime); this.state = new State(this.runtime); - // this.pubsub = new GRPCClientPubSub(client); - // this.binding = new GRPCClientBinding(client); - // this.invoker = new GRPCClientInvoker(client); - // this.secret = new GRPCClientSecret(client); - // this.actor = new GRPCClientActor(client); + this.invoker = new Invoker(this.runtime); + this.lock = new Lock(this.runtime); } } diff --git a/sdk/js-sdk/src/Invoker.ts b/sdk/js-sdk/src/Invoker.ts new file mode 100644 index 0000000000..d53a3abb83 --- /dev/null +++ b/sdk/js-sdk/src/Invoker.ts @@ -0,0 +1,41 @@ +import { Any } from "google-protobuf/google/protobuf/any_pb"; +import { + InvokeServiceRequest, + CommonInvokeRequest, + HTTPExtension, + InvokeResponse, +} from '../proto/runtime_pb'; +import { API, RequestMetadata } from './API'; + +export default class Invoker extends API { + async invoke(id: string, methodName: string, httpVerb = HTTPExtension.Verb.GET, data: string | object = {}, meta?: RequestMetadata): Promise { + const message = new CommonInvokeRequest(); + message.setMethod(methodName); + + const httpExtension = new HTTPExtension(); + httpExtension.setVerb(httpVerb); + message.setHttpExtension(httpExtension); + + const dataSerialized = new Any(); + if (typeof data === 'string') { + message.setContentType(''); + dataSerialized.setValue(Buffer.from(data, 'utf8')); + } else { + message.setContentType('application/json'); + dataSerialized.setValue(Buffer.from(JSON.stringify(data), 'utf8')); + } + message.setData(dataSerialized); + + const req = new InvokeServiceRequest(); + req.setId(id); + req.setMessage(message); + + return new Promise((resolve, reject) => { + this.runtime.invokeService(req, this.createMetadata(meta), (err, res: InvokeResponse) => { + if (err) return reject(err); + const data = JSON.parse(res.getData()); + resolve(data); + }); + }); + } +} diff --git a/sdk/js-sdk/src/Lock.ts b/sdk/js-sdk/src/Lock.ts new file mode 100644 index 0000000000..d956d46ea6 --- /dev/null +++ b/sdk/js-sdk/src/Lock.ts @@ -0,0 +1,40 @@ +import * as crypto from 'crypto'; +import { TryLockRequest, TryLockResponse, UnlockRequest, UnlockResponse } from '../proto/runtime_pb'; +import { API, RequestMetadata } from './API'; + +export default class Lock extends API { + // A non-blocking method trying to get a lock with ttl + // expire is the time before expire. The time unit is second. + async tryLock(storeName: string, resourceId: string, lockOwner: string, expire: number, meta?: RequestMetadata): Promise { + const req = new TryLockRequest(); + req.setStoreName(storeName); + req.setResourceId(resourceId); + req.setLockOwner(lockOwner); + req.setExpire(expire); + + return new Promise((resolve, reject) => { + this.runtime.tryLock(req, this.createMetadata(meta), (err, res: TryLockResponse) => { + if (err) return reject(err); + resolve(res.getSuccess()); + }); + }); + } + + async unLock(storeName: string, resourceId: string, lockOwner: string, meta?: RequestMetadata): Promise { + const req = new UnlockRequest(); + req.setStoreName(storeName); + req.setResourceId(resourceId); + req.setLockOwner(lockOwner); + + return new Promise((resolve, reject) => { + this.runtime.unlock(req, this.createMetadata(meta), (err, res: UnlockResponse) => { + if (err) return reject(err); + resolve(res.getStatus()); + }); + }); + } + + uuid() { + return crypto.randomUUID(); + } +} diff --git a/sdk/js-sdk/src/types/Invoker.ts b/sdk/js-sdk/src/types/Invoker.ts new file mode 100644 index 0000000000..39cc353723 --- /dev/null +++ b/sdk/js-sdk/src/types/Invoker.ts @@ -0,0 +1,3 @@ +import { HTTPExtension } from '../../proto/runtime_pb'; + +export const HTTPExtensionVerb = HTTPExtension.Verb; diff --git a/sdk/js-sdk/src/types/Lock.ts b/sdk/js-sdk/src/types/Lock.ts new file mode 100644 index 0000000000..f7157428c4 --- /dev/null +++ b/sdk/js-sdk/src/types/Lock.ts @@ -0,0 +1,3 @@ +import { UnlockResponse } from '../../proto/runtime_pb'; + +export const UnlockResponseStatus = UnlockResponse.Status; diff --git a/sdk/js-sdk/src/utils.ts b/sdk/js-sdk/src/utils.ts new file mode 100644 index 0000000000..d226684170 --- /dev/null +++ b/sdk/js-sdk/src/utils.ts @@ -0,0 +1,5 @@ +import { setTimeout } from 'timers/promises'; + +export async function sleep(ms: number) { + await setTimeout(ms); +} diff --git a/sdk/js-sdk/test/unit/Invoker.test.ts b/sdk/js-sdk/test/unit/Invoker.test.ts new file mode 100644 index 0000000000..022894dcb1 --- /dev/null +++ b/sdk/js-sdk/test/unit/Invoker.test.ts @@ -0,0 +1,26 @@ +import { strict as assert } from 'assert'; +import { Client } from '../../src'; +import { HTTPExtensionVerb } from '../../src/types/Invoker'; + +describe.skip('Invoker.test.ts', () => { + let client: Client; + + beforeAll(() => { + client = new Client(); + }); + + describe('invoke()', () => { + it('should invoke HelloService:1.0 with text success', async () => { + const state = await client.invoker.invoke('HelloService:1.0', '/hello', undefined, 'hello runtime with js-sdk'); + assert.equal(state, null); + }); + + it('should invoke HelloService:1.0 with json success', async () => { + const state = await client.invoker.invoke('HelloService:1.0', '/hello', HTTPExtensionVerb.POST, { + 'hello runtime': 'I am js-sdk client', + }); + assert.equal(state, null); + }); + }); +}); + diff --git a/sdk/js-sdk/test/unit/Lock.test.ts b/sdk/js-sdk/test/unit/Lock.test.ts new file mode 100644 index 0000000000..d6fcdf2960 --- /dev/null +++ b/sdk/js-sdk/test/unit/Lock.test.ts @@ -0,0 +1,42 @@ +import { strict as assert } from 'assert'; +import { Client } from '../../src'; +import { UnlockResponseStatus } from '../../src/types/Lock'; +import { sleep } from '.,/../../src/utils'; + +describe('Lock.test.ts', () => { + let client: Client; + const storeName = 'redis'; + + beforeAll(() => { + client = new Client(); + }); + + it('should unLock not exists resource', async () => { + const resourceId = 'js-sdk-lock-not-exists'; + const lockOwner = client.lock.uuid(); + const status = await client.lock.unLock(storeName, resourceId, lockOwner); + assert.equal(status, UnlockResponseStatus.LOCK_UNEXIST); + }); + + it('should lock 2 seconds work', async () => { + const resourceId = 'js-sdk-lock-2-seconds'; + const lockOwner = client.lock.uuid(); + const success1 = await client.lock.tryLock(storeName, resourceId, lockOwner, 2); + assert.equal(success1, true); + const success2 = await client.lock.tryLock(storeName, resourceId, lockOwner, 2); + assert.equal(success2, false); + await sleep(2500); + // wait for lock exipre after 2.5s + const success3 = await client.lock.tryLock(storeName, resourceId, lockOwner, 2); + assert.equal(success3, true); + + // unlock by other owner will fail + const lockOwner2 = client.lock.uuid(); + const status1 = await client.lock.unLock(storeName, resourceId, lockOwner2); + assert.equal(status1, UnlockResponseStatus.LOCK_BELONG_TO_OTHERS); + + // unlock success by owner + const status2 = await client.lock.unLock(storeName, resourceId, lockOwner); + assert.equal(status2, UnlockResponseStatus.SUCCESS); + }); +}); From 22dc76c3e3bc53708c4a4ee20ad7f999f741b8d6 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sun, 24 Oct 2021 22:50:26 +0800 Subject: [PATCH 04/13] feat(js-sdk): Impl Sequencer API --- sdk/js-sdk/README.md | 18 +++++++++++++++++ sdk/js-sdk/proto/runtime_pb.d.ts | 6 +++--- sdk/js-sdk/proto/runtime_pb.js | 16 +++++++-------- sdk/js-sdk/src/Client.ts | 9 +++++++-- sdk/js-sdk/src/Sequencer.ts | 28 ++++++++++++++++++++++++++ sdk/js-sdk/src/types/Sequencer.ts | 9 +++++++++ sdk/js-sdk/test/unit/Invoker.test.ts | 2 +- sdk/js-sdk/test/unit/Sequencer.test.ts | 26 ++++++++++++++++++++++++ spec/proto/runtime/v1/runtime.proto | 3 ++- 9 files changed, 102 insertions(+), 15 deletions(-) create mode 100644 sdk/js-sdk/src/Sequencer.ts create mode 100644 sdk/js-sdk/src/types/Sequencer.ts create mode 100644 sdk/js-sdk/test/unit/Sequencer.test.ts diff --git a/sdk/js-sdk/README.md b/sdk/js-sdk/README.md index bbc51d6406..42027a378c 100644 --- a/sdk/js-sdk/README.md +++ b/sdk/js-sdk/README.md @@ -61,3 +61,21 @@ Enable trace debug log for grpc-js: ```bash GRPC_TRACE=compression GRPC_VERBOSITY=debug GRPC_TRACE=all npm run test test/unit/Invoker.test.ts ``` + +### Running redis under Docker + +```bash +docker pull redis:latest +docker run -itd --name redis-test -p 6380:6379 redis +``` + +### Running etcd under Docker + +```bash +docker pull quay.io/coreos/etcd +docker run -itd -p 2379:2379 --name etcd quay.io/coreos/etcd /usr/local/bin/etcd -advertise-client-urls http://0.0.0.0:2379 -listen-client-urls http://0.0.0.0:2379 +``` + +## Get Start with gRPC on Node.js + +See https://grpc.io/docs/languages/node/quickstart/ diff --git a/sdk/js-sdk/proto/runtime_pb.d.ts b/sdk/js-sdk/proto/runtime_pb.d.ts index 744019fd54..109213219f 100644 --- a/sdk/js-sdk/proto/runtime_pb.d.ts +++ b/sdk/js-sdk/proto/runtime_pb.d.ts @@ -248,8 +248,8 @@ export namespace SequencerOptions { } export class GetNextIdResponse extends jspb.Message { - getNextId(): number; - setNextId(value: number): GetNextIdResponse; + getNextId(): string; + setNextId(value: string): GetNextIdResponse; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): GetNextIdResponse.AsObject; @@ -263,7 +263,7 @@ export class GetNextIdResponse extends jspb.Message { export namespace GetNextIdResponse { export type AsObject = { - nextId: number, + nextId: string, } } diff --git a/sdk/js-sdk/proto/runtime_pb.js b/sdk/js-sdk/proto/runtime_pb.js index db7edb7018..d6ed9050e1 100644 --- a/sdk/js-sdk/proto/runtime_pb.js +++ b/sdk/js-sdk/proto/runtime_pb.js @@ -2629,7 +2629,7 @@ proto.spec.proto.runtime.v1.GetNextIdResponse.prototype.toObject = function(opt_ */ proto.spec.proto.runtime.v1.GetNextIdResponse.toObject = function(includeInstance, msg) { var f, obj = { - nextId: jspb.Message.getFieldWithDefault(msg, 1, 0) + nextId: jspb.Message.getFieldWithDefault(msg, 1, "0") }; if (includeInstance) { @@ -2667,7 +2667,7 @@ proto.spec.proto.runtime.v1.GetNextIdResponse.deserializeBinaryFromReader = func var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {number} */ (reader.readInt64()); + var value = /** @type {string} */ (reader.readInt64String()); msg.setNextId(value); break; default: @@ -2700,8 +2700,8 @@ proto.spec.proto.runtime.v1.GetNextIdResponse.prototype.serializeBinary = functi proto.spec.proto.runtime.v1.GetNextIdResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getNextId(); - if (f !== 0) { - writer.writeInt64( + if (parseInt(f, 10) !== 0) { + writer.writeInt64String( 1, f ); @@ -2711,19 +2711,19 @@ proto.spec.proto.runtime.v1.GetNextIdResponse.serializeBinaryToWriter = function /** * optional int64 next_id = 1; - * @return {number} + * @return {string} */ proto.spec.proto.runtime.v1.GetNextIdResponse.prototype.getNextId = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "0")); }; /** - * @param {number} value + * @param {string} value * @return {!proto.spec.proto.runtime.v1.GetNextIdResponse} returns this */ proto.spec.proto.runtime.v1.GetNextIdResponse.prototype.setNextId = function(value) { - return jspb.Message.setProto3IntField(this, 1, value); + return jspb.Message.setProto3StringIntField(this, 1, value); }; diff --git a/sdk/js-sdk/src/Client.ts b/sdk/js-sdk/src/Client.ts index 85c3f89055..93b6481b92 100644 --- a/sdk/js-sdk/src/Client.ts +++ b/sdk/js-sdk/src/Client.ts @@ -4,6 +4,7 @@ import State from './State'; import Hello from './Hello'; import Invoker from './Invoker'; import Lock from './Lock'; +import Sequencer from './Sequencer'; export default class Client { readonly port: string; @@ -13,18 +14,22 @@ export default class Client { readonly state: State; readonly invoker: Invoker; readonly lock: Lock; + readonly sequencer: Sequencer; // readonly secret: IClientSecret; // readonly actor: IClientActor; constructor(port: string = process.env.runtime_GRPC_PORT || '34904') { + // debug with env runtime_GRPC_HOST + const host = process.env.runtime_GRPC_HOST || '127.0.0.1'; this.port = port; const clientCredentials = ChannelCredentials.createInsecure(); - console.log(`[Layotto-JS] Start connection to port:${this.port}`); - this.runtime = new RuntimeClient(`127.0.0.1:${this.port}`, clientCredentials); + console.log(`[Layotto-JS] Start connection to ${host}:${this.port}`); + this.runtime = new RuntimeClient(`${host}:${this.port}`, clientCredentials); this.hello = new Hello(this.runtime); this.state = new State(this.runtime); this.invoker = new Invoker(this.runtime); this.lock = new Lock(this.runtime); + this.sequencer = new Sequencer(this.runtime); } } diff --git a/sdk/js-sdk/src/Sequencer.ts b/sdk/js-sdk/src/Sequencer.ts new file mode 100644 index 0000000000..6862fe0962 --- /dev/null +++ b/sdk/js-sdk/src/Sequencer.ts @@ -0,0 +1,28 @@ +import { + GetNextIdRequest, + GetNextIdResponse, + SequencerOptions as SequencerOptionsPB, +} from '../proto/runtime_pb'; +import { API, RequestMetadata } from './API'; +import { SequencerOptions } from './types/Sequencer'; + +export default class Sequencer extends API { + // Get next unique id with some auto-increment guarantee + async getNextId(storeName: string, key: string, options?: SequencerOptions, meta?: RequestMetadata): Promise { + const req = new GetNextIdRequest(); + req.setStoreName(storeName); + req.setKey(key); + if (options) { + const sequencerOptions = new SequencerOptionsPB(); + sequencerOptions.setIncrement(options.increment); + req.setOptions(sequencerOptions); + } + + return new Promise((resolve, reject) => { + this.runtime.getNextId(req, this.createMetadata(meta), (err, res: GetNextIdResponse) => { + if (err) return reject(err); + resolve(res.getNextId()); + }); + }); + } +} diff --git a/sdk/js-sdk/src/types/Sequencer.ts b/sdk/js-sdk/src/types/Sequencer.ts new file mode 100644 index 0000000000..0c76a9b6fd --- /dev/null +++ b/sdk/js-sdk/src/types/Sequencer.ts @@ -0,0 +1,9 @@ +import { + SequencerOptions as SequencerOptionsPB, +} from '../../proto/runtime_pb'; + +export const SequencerOptionsAutoIncrement = SequencerOptionsPB.AutoIncrement; + +export type SequencerOptions = { + increment: SequencerOptionsPB.AutoIncrement; +}; diff --git a/sdk/js-sdk/test/unit/Invoker.test.ts b/sdk/js-sdk/test/unit/Invoker.test.ts index 022894dcb1..9f56ce5137 100644 --- a/sdk/js-sdk/test/unit/Invoker.test.ts +++ b/sdk/js-sdk/test/unit/Invoker.test.ts @@ -2,7 +2,7 @@ import { strict as assert } from 'assert'; import { Client } from '../../src'; import { HTTPExtensionVerb } from '../../src/types/Invoker'; -describe.skip('Invoker.test.ts', () => { +describe('Invoker.test.ts', () => { let client: Client; beforeAll(() => { diff --git a/sdk/js-sdk/test/unit/Sequencer.test.ts b/sdk/js-sdk/test/unit/Sequencer.test.ts new file mode 100644 index 0000000000..c874df13f3 --- /dev/null +++ b/sdk/js-sdk/test/unit/Sequencer.test.ts @@ -0,0 +1,26 @@ +import { strict as assert } from 'assert'; +import { Client } from '../../src'; +// import { SequencerOptionsAutoIncrement } from '../../src/types/Sequencer'; + +describe('Sequencer.test.ts', () => { + let client: Client; + const storeName = 'etcd'; + + beforeAll(() => { + client = new Client(); + }); + + it('should get next id success', async () => { + let lastId = '0'; + let currentId = '0'; + const ids: string[] = []; + for (let i = 0; i < 20; i++) { + lastId = currentId; + currentId = await client.sequencer.getNextId(storeName, 'user_info'); + assert(BigInt(currentId) > BigInt(lastId)); + ids.push(currentId); + } + assert.equal(ids.length, 20); + console.log('ids: %j', ids); + }); +}); diff --git a/spec/proto/runtime/v1/runtime.proto b/spec/proto/runtime/v1/runtime.proto index c68586838c..9249cd8562 100644 --- a/spec/proto/runtime/v1/runtime.proto +++ b/spec/proto/runtime/v1/runtime.proto @@ -163,7 +163,8 @@ message SequencerOptions { message GetNextIdResponse{ // The next unique id - int64 next_id = 1; + // Fixed int64 overflow problems on JavaScript https://github.com/improbable-eng/ts-protoc-gen#gotchas + int64 next_id = 1 [jstype = JS_STRING]; } message TryLockRequest { From f311045aade779a1daffb6c05f504d9a7ea75003 Mon Sep 17 00:00:00 2001 From: seeflood <349895584@qq.com> Date: Mon, 25 Oct 2021 21:37:35 +0800 Subject: [PATCH 05/13] add license headers --- .licenserc.yaml | 12 +- configs/config_integration_redis_etcd.json | 196 +++++++++++++++++++++ sdk/js-sdk/.github/workflows/nodejs.yml | 13 ++ sdk/js-sdk/README.md | 44 +++-- sdk/js-sdk/demo/helloworld.ts | 14 ++ sdk/js-sdk/demo/rpc/http/server.js | 14 ++ sdk/js-sdk/demo/state.ts | 14 ++ sdk/js-sdk/scripts/build-grpc.sh | 13 ++ sdk/js-sdk/src/API.ts | 14 ++ sdk/js-sdk/src/Client.ts | 14 ++ sdk/js-sdk/src/Hello.ts | 14 ++ sdk/js-sdk/src/Invoker.ts | 14 ++ sdk/js-sdk/src/Lock.ts | 14 ++ sdk/js-sdk/src/Sequencer.ts | 14 ++ sdk/js-sdk/src/State.ts | 14 ++ sdk/js-sdk/src/index.ts | 14 ++ sdk/js-sdk/src/types/Invoker.ts | 14 ++ sdk/js-sdk/src/types/Lock.ts | 14 ++ sdk/js-sdk/src/types/Sequencer.ts | 14 ++ sdk/js-sdk/src/types/State.ts | 14 ++ sdk/js-sdk/src/utils.ts | 14 ++ sdk/js-sdk/test/unit/Client.test.ts | 14 ++ sdk/js-sdk/test/unit/Invoker.test.ts | 14 ++ sdk/js-sdk/test/unit/Lock.test.ts | 16 +- sdk/js-sdk/test/unit/Sequencer.test.ts | 14 ++ sdk/js-sdk/test/unit/State.test.ts | 14 ++ 26 files changed, 553 insertions(+), 21 deletions(-) create mode 100644 configs/config_integration_redis_etcd.json diff --git a/.licenserc.yaml b/.licenserc.yaml index 79e581581c..77f1ee451d 100644 --- a/.licenserc.yaml +++ b/.licenserc.yaml @@ -23,13 +23,21 @@ header: - 'sdk/' paths-ignore: + # js related + - 'sdk/js-sdk/node_modules/' + - 'sdk/js-sdk/demo/' + - '**/*.config.js' + - '**/*pb.d.ts' + - '**/*pb.js' + # java related + - 'sdk/java-sdk/sdk/target/' + - '**/*Grpc.java' + - '**/*Proto.java' - '**/*.json' - '**/*.log' - '**/*.log.*' - '**/*.lst' - '**/*.pb.go' - - '**/*Grpc.java' - - '**/*Proto.java' - '**/*.proto' - '**/*.yaml' - '**/*.xml' diff --git a/configs/config_integration_redis_etcd.json b/configs/config_integration_redis_etcd.json new file mode 100644 index 0000000000..bd1f33e8fa --- /dev/null +++ b/configs/config_integration_redis_etcd.json @@ -0,0 +1,196 @@ +{ + "servers": [ + { + "default_log_path": "stdout", + "default_log_level": "DEBUG", + "routers": [ + { + "router_config_name": "http_router", + "virtual_hosts": [ + { + "name": "http_host", + "domains": [ + "*" + ], + "routers": [ + { + "match": { + "headers": [ + { + "name": "id", + "value": "HelloService:1.0" + } + ] + }, + "route": { + "cluster_name": "http_server" + } + } + ] + } + ] + }, + { + "router_config_name": "actuator_dont_need_router" + } + ], + "listeners": [ + { + "name": "grpc", + "address": "127.0.0.1:34904", + "bind_port": true, + "filter_chains": [ + { + "filters": [ + { + "type": "grpc", + "config": { + "server_name": "runtime", + "grpc_config": { + "rpcs": { + "mosn": { + "config": { + "channel": [ + { + "size": 16, + "protocol": "http", + "listener": "egress_runtime_http" + } + ] + } + } + }, + "hellos": { + "helloworld": { + "hello": "greeting" + } + }, + "config_stores": { + "etcd": { + "address": [ + "127.0.0.1:2379" + ], + "timeout": "10" + } + }, + "state": { + "redis": { + "metadata": { + "redisHost": "localhost:6380", + "redisPassword": "" + } + } + }, + "sequencer": { + "etcd": { + "metadata": { + "endpoints": "localhost:2379", + "segmentCacheEnable": "false", + "segmentStep": "1", + "username": "", + "password": "", + "dialTimeout": "5" + } + }, + "redis": { + "metadata": { + "redisHost": "127.0.0.1:6380", + "redisPassword": "" + } + } + }, + "lock": { + "etcd": { + "metadata": { + "endpoints": "localhost:2379", + "username": "", + "password": "", + "keyPrefixPath": "/lock", + "dialTimeout": "5" + } + }, + "redis": { + "metadata": { + "redisHost": "localhost:6380", + "redisPassword": "" + } + } + }, + "app": { + "app_id": "app1", + "grpc_callback_port": 9999 + } + } + } + } + ] + } + ] + }, + { + "name": "actuator", + "address": "127.0.0.1:34999", + "bind_port": true, + "filter_chains": [ + { + "filters": [ + { + "type": "proxy", + "config": { + "downstream_protocol": "Http1", + "upstream_protocol": "Http1", + "router_config_name": "actuator_dont_need_router" + } + } + ] + } + ], + "stream_filters": [ + { + "type": "actuator_filter" + } + ] + }, + { + "name": "egress_runtime_http", + "type": "egress", + "address": "0.0.0.0:12221", + "bind_port": true, + "network": "tcp", + "filter_chains": [ + { + "filters": [ + { + "type": "proxy", + "config": { + "downstream_protocol": "Http1", + "name": "proxy_config", + "router_config_name": "http_router", + "upstream_protocol": "Http1" + } + } + ] + } + ] + } + ] + } + ], + "cluster_manager": { + "tls_context": {}, + "clusters": [ + { + "name": "http_server", + "type": "SIMPLE", + "lb_type": "LB_RANDOM", + "hosts": [ + { + "address": "127.0.0.1:8889", + "hostname": "downstream_machine1", + "weight": 1 + } + ] + } + ] + } +} diff --git a/sdk/js-sdk/.github/workflows/nodejs.yml b/sdk/js-sdk/.github/workflows/nodejs.yml index 734409e777..4590023e77 100644 --- a/sdk/js-sdk/.github/workflows/nodejs.yml +++ b/sdk/js-sdk/.github/workflows/nodejs.yml @@ -1,3 +1,16 @@ +# +# Copyright 2021 Layotto Authors +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions diff --git a/sdk/js-sdk/README.md b/sdk/js-sdk/README.md index 42027a378c..2e90379d6f 100644 --- a/sdk/js-sdk/README.md +++ b/sdk/js-sdk/README.md @@ -38,44 +38,52 @@ npm run build:grpc ``` ### Run Tests +### step 1. Set up the environment -run the unit tests in your local env: - -- Start Layotto first, see [How to run layotto](https://mosn.io/layotto/#/zh/start/state/start?id=%e7%ac%ac%e4%ba%8c%e6%ad%a5%ef%bc%9a%e8%bf%90%e8%a1%8clayotto) +- Running redis under Docker ```bash -cd ${projectpath}/cmd/layotto -go build - -./layotto start -c ../../configs/config_state_redis.json +docker pull redis:latest +docker run -itd --name redis-test -p 6380:6379 redis ``` -- Then, run unit tests script by npm +- Running etcd under Docker ```bash -npm run test:unit +docker pull quay.io/coreos/etcd +docker run -itd -p 2379:2379 --name etcd quay.io/coreos/etcd /usr/local/bin/etcd -advertise-client-urls http://0.0.0.0:2379 -listen-client-urls http://0.0.0.0:2379 ``` -Enable trace debug log for grpc-js: +- Start a echoserver for testing the rpc api +```shell +go run demo/rpc/http/echoserver/echoserver.go +``` + +If you want to know more about this,check https://mosn.io/layotto/#/zh/start/rpc/helloworld + +- Start Layotto, see [How to run layotto](https://mosn.io/layotto/#/zh/start/state/start?id=%e7%ac%ac%e4%ba%8c%e6%ad%a5%ef%bc%9a%e8%bf%90%e8%a1%8clayotto) ```bash -GRPC_TRACE=compression GRPC_VERBOSITY=debug GRPC_TRACE=all npm run test test/unit/Invoker.test.ts +cd ${projectpath}/cmd/layotto +go build + +./layotto start -c ../../configs/config_integration_redis_etcd.json ``` -### Running redis under Docker +### step 2: Run the tests +- Then, run the test script by npm ```bash -docker pull redis:latest -docker run -itd --name redis-test -p 6380:6379 redis +npm run test:unit ``` -### Running etcd under Docker +Enable trace debug log for grpc-js: ```bash -docker pull quay.io/coreos/etcd -docker run -itd -p 2379:2379 --name etcd quay.io/coreos/etcd /usr/local/bin/etcd -advertise-client-urls http://0.0.0.0:2379 -listen-client-urls http://0.0.0.0:2379 +GRPC_TRACE=compression GRPC_VERBOSITY=debug GRPC_TRACE=all npm run test test/unit/Invoker.test.ts ``` -## Get Start with gRPC on Node.js +## Reference +### Get Start with gRPC on Node.js See https://grpc.io/docs/languages/node/quickstart/ diff --git a/sdk/js-sdk/demo/helloworld.ts b/sdk/js-sdk/demo/helloworld.ts index b4a7776496..036f558c01 100644 --- a/sdk/js-sdk/demo/helloworld.ts +++ b/sdk/js-sdk/demo/helloworld.ts @@ -1,3 +1,17 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { strict as assert } from 'assert'; import { Client } from 'layotto'; diff --git a/sdk/js-sdk/demo/rpc/http/server.js b/sdk/js-sdk/demo/rpc/http/server.js index 36f26aa618..20b9a6a2e0 100644 --- a/sdk/js-sdk/demo/rpc/http/server.js +++ b/sdk/js-sdk/demo/rpc/http/server.js @@ -1,3 +1,17 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ const Koa = require('koa'); const app = new Koa(); diff --git a/sdk/js-sdk/demo/state.ts b/sdk/js-sdk/demo/state.ts index 2fbbc2a5a3..8b0da7bf16 100644 --- a/sdk/js-sdk/demo/state.ts +++ b/sdk/js-sdk/demo/state.ts @@ -1,3 +1,17 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { strict as assert } from 'assert' import { Client } from 'layotto'; diff --git a/sdk/js-sdk/scripts/build-grpc.sh b/sdk/js-sdk/scripts/build-grpc.sh index 878d8f1c5e..eb6cc98dff 100755 --- a/sdk/js-sdk/scripts/build-grpc.sh +++ b/sdk/js-sdk/scripts/build-grpc.sh @@ -1,4 +1,17 @@ #!/bin/bash +# +# Copyright 2021 Layotto Authors +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. OS=$(echo `uname`|tr '[:upper:]' '[:lower:]') ARCH=$(uname -m) diff --git a/sdk/js-sdk/src/API.ts b/sdk/js-sdk/src/API.ts index 8e7942d85b..202e88f16c 100644 --- a/sdk/js-sdk/src/API.ts +++ b/sdk/js-sdk/src/API.ts @@ -1,3 +1,17 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { Metadata } from '@grpc/grpc-js'; import { RuntimeClient } from '../proto/runtime_grpc_pb'; diff --git a/sdk/js-sdk/src/Client.ts b/sdk/js-sdk/src/Client.ts index 93b6481b92..993b3b10a0 100644 --- a/sdk/js-sdk/src/Client.ts +++ b/sdk/js-sdk/src/Client.ts @@ -1,3 +1,17 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { ChannelCredentials } from '@grpc/grpc-js'; import { RuntimeClient } from '../proto/runtime_grpc_pb'; import State from './State'; diff --git a/sdk/js-sdk/src/Hello.ts b/sdk/js-sdk/src/Hello.ts index 4316f69572..09a1c1e160 100644 --- a/sdk/js-sdk/src/Hello.ts +++ b/sdk/js-sdk/src/Hello.ts @@ -1,3 +1,17 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { SayHelloRequest } from '../proto/runtime_pb'; diff --git a/sdk/js-sdk/src/Invoker.ts b/sdk/js-sdk/src/Invoker.ts index d53a3abb83..f6d2de9885 100644 --- a/sdk/js-sdk/src/Invoker.ts +++ b/sdk/js-sdk/src/Invoker.ts @@ -1,3 +1,17 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { Any } from "google-protobuf/google/protobuf/any_pb"; import { InvokeServiceRequest, diff --git a/sdk/js-sdk/src/Lock.ts b/sdk/js-sdk/src/Lock.ts index d956d46ea6..13cc6d2998 100644 --- a/sdk/js-sdk/src/Lock.ts +++ b/sdk/js-sdk/src/Lock.ts @@ -1,3 +1,17 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import * as crypto from 'crypto'; import { TryLockRequest, TryLockResponse, UnlockRequest, UnlockResponse } from '../proto/runtime_pb'; import { API, RequestMetadata } from './API'; diff --git a/sdk/js-sdk/src/Sequencer.ts b/sdk/js-sdk/src/Sequencer.ts index 6862fe0962..585ac8d28f 100644 --- a/sdk/js-sdk/src/Sequencer.ts +++ b/sdk/js-sdk/src/Sequencer.ts @@ -1,3 +1,17 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { GetNextIdRequest, GetNextIdResponse, diff --git a/sdk/js-sdk/src/State.ts b/sdk/js-sdk/src/State.ts index 41c7e4e1c9..cd8713dbda 100644 --- a/sdk/js-sdk/src/State.ts +++ b/sdk/js-sdk/src/State.ts @@ -1,3 +1,17 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { SaveStateRequest, StateItem as StateItemPB, diff --git a/sdk/js-sdk/src/index.ts b/sdk/js-sdk/src/index.ts index 98de5d811d..a666bc0ed2 100644 --- a/sdk/js-sdk/src/index.ts +++ b/sdk/js-sdk/src/index.ts @@ -1,3 +1,17 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import Client from './Client'; export { diff --git a/sdk/js-sdk/src/types/Invoker.ts b/sdk/js-sdk/src/types/Invoker.ts index 39cc353723..014f5c11d1 100644 --- a/sdk/js-sdk/src/types/Invoker.ts +++ b/sdk/js-sdk/src/types/Invoker.ts @@ -1,3 +1,17 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { HTTPExtension } from '../../proto/runtime_pb'; export const HTTPExtensionVerb = HTTPExtension.Verb; diff --git a/sdk/js-sdk/src/types/Lock.ts b/sdk/js-sdk/src/types/Lock.ts index f7157428c4..025a3777a8 100644 --- a/sdk/js-sdk/src/types/Lock.ts +++ b/sdk/js-sdk/src/types/Lock.ts @@ -1,3 +1,17 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { UnlockResponse } from '../../proto/runtime_pb'; export const UnlockResponseStatus = UnlockResponse.Status; diff --git a/sdk/js-sdk/src/types/Sequencer.ts b/sdk/js-sdk/src/types/Sequencer.ts index 0c76a9b6fd..a557342eb7 100644 --- a/sdk/js-sdk/src/types/Sequencer.ts +++ b/sdk/js-sdk/src/types/Sequencer.ts @@ -1,3 +1,17 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { SequencerOptions as SequencerOptionsPB, } from '../../proto/runtime_pb'; diff --git a/sdk/js-sdk/src/types/State.ts b/sdk/js-sdk/src/types/State.ts index b7beb5ec4c..55d33f3284 100644 --- a/sdk/js-sdk/src/types/State.ts +++ b/sdk/js-sdk/src/types/State.ts @@ -1,3 +1,17 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { StateOptions as StateOptionsPB, } from '../../proto/runtime_pb'; diff --git a/sdk/js-sdk/src/utils.ts b/sdk/js-sdk/src/utils.ts index d226684170..58c924299b 100644 --- a/sdk/js-sdk/src/utils.ts +++ b/sdk/js-sdk/src/utils.ts @@ -1,3 +1,17 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { setTimeout } from 'timers/promises'; export async function sleep(ms: number) { diff --git a/sdk/js-sdk/test/unit/Client.test.ts b/sdk/js-sdk/test/unit/Client.test.ts index ce892da308..360c58eabd 100644 --- a/sdk/js-sdk/test/unit/Client.test.ts +++ b/sdk/js-sdk/test/unit/Client.test.ts @@ -1,3 +1,17 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { strict as assert } from 'assert'; import { Client } from '../../src'; diff --git a/sdk/js-sdk/test/unit/Invoker.test.ts b/sdk/js-sdk/test/unit/Invoker.test.ts index 9f56ce5137..705847e60b 100644 --- a/sdk/js-sdk/test/unit/Invoker.test.ts +++ b/sdk/js-sdk/test/unit/Invoker.test.ts @@ -1,3 +1,17 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { strict as assert } from 'assert'; import { Client } from '../../src'; import { HTTPExtensionVerb } from '../../src/types/Invoker'; diff --git a/sdk/js-sdk/test/unit/Lock.test.ts b/sdk/js-sdk/test/unit/Lock.test.ts index d6fcdf2960..a8bdd7ecc7 100644 --- a/sdk/js-sdk/test/unit/Lock.test.ts +++ b/sdk/js-sdk/test/unit/Lock.test.ts @@ -1,7 +1,21 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { strict as assert } from 'assert'; import { Client } from '../../src'; import { UnlockResponseStatus } from '../../src/types/Lock'; -import { sleep } from '.,/../../src/utils'; +import { sleep } from '../../src/utils'; describe('Lock.test.ts', () => { let client: Client; diff --git a/sdk/js-sdk/test/unit/Sequencer.test.ts b/sdk/js-sdk/test/unit/Sequencer.test.ts index c874df13f3..7a55c5e019 100644 --- a/sdk/js-sdk/test/unit/Sequencer.test.ts +++ b/sdk/js-sdk/test/unit/Sequencer.test.ts @@ -1,3 +1,17 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { strict as assert } from 'assert'; import { Client } from '../../src'; // import { SequencerOptionsAutoIncrement } from '../../src/types/Sequencer'; diff --git a/sdk/js-sdk/test/unit/State.test.ts b/sdk/js-sdk/test/unit/State.test.ts index 6218058b1a..7e24112d51 100644 --- a/sdk/js-sdk/test/unit/State.test.ts +++ b/sdk/js-sdk/test/unit/State.test.ts @@ -1,3 +1,17 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { strict as assert } from 'assert'; import { Client } from '../../src'; import { StateOperation, StateOperationType } from '../../src/types/State'; From 869a8299f2a1a891f22eebd1793dafca935d52f6 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Thu, 28 Oct 2021 23:06:03 +0800 Subject: [PATCH 06/13] feat(js-sdk): Impl Configuration API --- sdk/js-sdk/README.md | 4 + sdk/js-sdk/demo/configuration/subscribe.ts | 89 ++++++++++++ sdk/js-sdk/scripts/build-grpc.sh | 1 + sdk/js-sdk/src/Client.ts | 21 +-- sdk/js-sdk/src/Configuration.ts | 147 +++++++++++++++++++ sdk/js-sdk/src/index.ts | 4 +- sdk/js-sdk/src/types/Configuration.ts | 71 ++++++++++ sdk/js-sdk/src/types/common.ts | 28 ++++ sdk/js-sdk/test/unit/Configuration.test.ts | 155 +++++++++++++++++++++ 9 files changed, 510 insertions(+), 10 deletions(-) create mode 100644 sdk/js-sdk/demo/configuration/subscribe.ts create mode 100644 sdk/js-sdk/src/Configuration.ts create mode 100644 sdk/js-sdk/src/types/Configuration.ts create mode 100644 sdk/js-sdk/src/types/common.ts create mode 100644 sdk/js-sdk/test/unit/Configuration.test.ts diff --git a/sdk/js-sdk/README.md b/sdk/js-sdk/README.md index 2e90379d6f..282254f8ff 100644 --- a/sdk/js-sdk/README.md +++ b/sdk/js-sdk/README.md @@ -87,3 +87,7 @@ GRPC_TRACE=compression GRPC_VERBOSITY=debug GRPC_TRACE=all npm run test test/uni ### Get Start with gRPC on Node.js See https://grpc.io/docs/languages/node/quickstart/ + +### Go Proxy in China + +See https://learnku.com/go/wikis/38122 diff --git a/sdk/js-sdk/demo/configuration/subscribe.ts b/sdk/js-sdk/demo/configuration/subscribe.ts new file mode 100644 index 0000000000..8ae510c099 --- /dev/null +++ b/sdk/js-sdk/demo/configuration/subscribe.ts @@ -0,0 +1,89 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { strict as assert } from 'assert'; +import { Client, utils } from 'layotto'; + +const client = new Client(); +assert(client); + +async function main() { + const hello = await client.hello.sayHello('helloworld', 'js-sdk'); + console.log('%s', hello); + + await client.configuration.save({ + storeName: 'etcd', + appId: 'js-sdk-demo', + items: [ + { + key: 'hello', + content: 'world', + }, + ], + }); + + const call = client.configuration.subscribe({ + storeName: 'etcd', + appId: 'js-sdk-demo', + keys: ['hello'], + onData(items) { + console.log('get items: %j', items); + }, + onClose(err) { + console.error('close with error: %s', err); + } + }); + await utils.sleep(100); + + await client.configuration.save({ + storeName: 'etcd', + appId: 'js-sdk-demo', + items: [ + { + key: 'hello', + content: 'world first', + }, + ], + }); + + await utils.sleep(500); + await client.configuration.save({ + storeName: 'etcd', + appId: 'js-sdk-demo', + items: [ + { + key: 'hello', + content: 'world second after 500ms', + }, + ], + }); + + await utils.sleep(500); + await client.configuration.save({ + storeName: 'etcd', + appId: 'js-sdk-demo', + items: [ + { + key: 'hello', + content: 'world third after 1000ms', + }, + ], + }); + + await utils.sleep(500); + call.end(); + call.destroy(); +} + +main(); diff --git a/sdk/js-sdk/scripts/build-grpc.sh b/sdk/js-sdk/scripts/build-grpc.sh index eb6cc98dff..16a5f3f7a1 100755 --- a/sdk/js-sdk/scripts/build-grpc.sh +++ b/sdk/js-sdk/scripts/build-grpc.sh @@ -16,6 +16,7 @@ OS=$(echo `uname`|tr '[:upper:]' '[:lower:]') ARCH=$(uname -m) # Proto buf generation +# https://medium.com/blokur/how-to-implement-a-grpc-client-and-server-in-typescript-fa3ac807855e PATH_ROOT=$(pwd) PATH_PROTO_ROOT="${PATH_ROOT}/../../spec/proto/runtime/v1" PATH_PROTO_OUTPUT="${PATH_ROOT}/proto" diff --git a/sdk/js-sdk/src/Client.ts b/sdk/js-sdk/src/Client.ts index 993b3b10a0..1f7b76097a 100644 --- a/sdk/js-sdk/src/Client.ts +++ b/sdk/js-sdk/src/Client.ts @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { debuglog } from 'node:util'; import { ChannelCredentials } from '@grpc/grpc-js'; import { RuntimeClient } from '../proto/runtime_grpc_pb'; import State from './State'; @@ -19,31 +20,33 @@ import Hello from './Hello'; import Invoker from './Invoker'; import Lock from './Lock'; import Sequencer from './Sequencer'; +import Configuration from './Configuration'; + +const debug = debuglog('layotto:client'); export default class Client { + readonly host: string; readonly port: string; readonly runtime: RuntimeClient; readonly hello: Hello; - // readonly pubsub: IClientPubSub; readonly state: State; readonly invoker: Invoker; readonly lock: Lock; readonly sequencer: Sequencer; - // readonly secret: IClientSecret; - // readonly actor: IClientActor; + readonly configuration: Configuration; - constructor(port: string = process.env.runtime_GRPC_PORT || '34904') { - // debug with env runtime_GRPC_HOST - const host = process.env.runtime_GRPC_HOST || '127.0.0.1'; + constructor(port: string = process.env.runtime_GRPC_PORT || '34904', + host: string = process.env.runtime_GRPC_HOST || '127.0.0.1') { + this.host = host; this.port = port; const clientCredentials = ChannelCredentials.createInsecure(); - - console.log(`[Layotto-JS] Start connection to ${host}:${this.port}`); - this.runtime = new RuntimeClient(`${host}:${this.port}`, clientCredentials); + this.runtime = new RuntimeClient(`${this.host}:${this.port}`, clientCredentials); this.hello = new Hello(this.runtime); this.state = new State(this.runtime); this.invoker = new Invoker(this.runtime); this.lock = new Lock(this.runtime); this.sequencer = new Sequencer(this.runtime); + this.configuration = new Configuration(this.runtime); + debug('Start connection to %s:%s', this.host, this.port); } } diff --git a/sdk/js-sdk/src/Configuration.ts b/sdk/js-sdk/src/Configuration.ts new file mode 100644 index 0000000000..c6efbfeec8 --- /dev/null +++ b/sdk/js-sdk/src/Configuration.ts @@ -0,0 +1,147 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { debuglog } from 'node:util'; +import { + GetConfigurationRequest as GetConfigurationRequestPB, + GetConfigurationResponse as GetConfigurationResponsePB, + SaveConfigurationRequest as SaveConfigurationRequestPB, + ConfigurationItem as ConfigurationItemPB, + DeleteConfigurationRequest as DeleteConfigurationRequestPB, + SubscribeConfigurationRequest as SubscribeConfigurationRequestPB, + SubscribeConfigurationResponse as SubscribeConfigurationResponsePB, +} from '../proto/runtime_pb'; +import { API, RequestMetadata } from './API'; +import { + GetConfigurationRequest, + GetConfigurationItem, + SaveConfigurationRequest, + DeleteConfigurationRequest, + SubscribeConfigurationRequest, +} from './types/Configuration'; +import { convertArrayToKVString } from './types/common'; + +const debug = debuglog('layotto:configuration'); + +export default class Configuration extends API { + // GetConfiguration gets configuration from configuration store. + async get(request: GetConfigurationRequest, grpcMeta?: RequestMetadata): Promise { + const req = new GetConfigurationRequestPB(); + req.setStoreName(request.storeName); + req.setAppId(request.appId); + req.setKeysList(request.keys); + if (request.group) req.setGroup(request.group); + if (request.label) req.setLabel(request.label); + if (request.subscribeUpdate !== undefined) { + req.setSubscribeUpdate(request.subscribeUpdate); + } + // TODO: support set metadataMap + return new Promise((resolve, reject) => { + this.runtime.getConfiguration(req, this.createMetadata(grpcMeta), (err, res: GetConfigurationResponsePB) => { + if (err) return reject(err); + resolve(res.getItemsList().map(item => this.createGetConfigurationItem(item))); + }); + }); + } + + // SaveConfiguration saves configuration into configuration store. + async save(request: SaveConfigurationRequest, grpcMeta?: RequestMetadata): Promise { + const req = new SaveConfigurationRequestPB(); + req.setStoreName(request.storeName); + req.setAppId(request.appId); + req.setItemsList(request.items.map(item => { + const configurationItem = new ConfigurationItemPB(); + configurationItem.setKey(item.key); + configurationItem.setContent(item.content); + if (item.group) configurationItem.setGroup(item.group); + if (item.label) configurationItem.setLabel(item.label); + return configurationItem; + })); + + return new Promise((resolve, reject) => { + this.runtime.saveConfiguration(req, this.createMetadata(grpcMeta), (err) => { + if (err) return reject(err); + resolve(); + }); + }); + } + + // DeleteConfiguration deletes configuration from configuration store. + async delete(request: DeleteConfigurationRequest, grpcMeta?: RequestMetadata): Promise { + const req = new DeleteConfigurationRequestPB(); + req.setStoreName(request.storeName); + req.setAppId(request.appId); + req.setKeysList(request.keys); + if (request.group) req.setGroup(request.group); + if (request.label) req.setLabel(request.label); + + return new Promise((resolve, reject) => { + this.runtime.deleteConfiguration(req, this.createMetadata(grpcMeta), (err) => { + if (err) return reject(err); + resolve(); + }); + }); + } + + // SubscribeConfiguration gets configuration from configuration store and subscribe the updates. + subscribe(request: SubscribeConfigurationRequest, grpcMeta?: RequestMetadata) { + const req = new SubscribeConfigurationRequestPB(); + req.setStoreName(request.storeName); + req.setAppId(request.appId); + req.setKeysList(request.keys); + if (request.group) req.setGroup(request.group); + if (request.label) req.setLabel(request.label); + + let lastError: Error; + let isCloseOrEnd = false; + const call = this.runtime.subscribeConfiguration(this.createMetadata(grpcMeta)); + call.on('readable', () => { + const res: SubscribeConfigurationResponsePB = call.read(); + debug('readable emit, has res: %s', !!res); + if (!res) return; + const items: GetConfigurationItem[] = res.getItemsList().map(item => this.createGetConfigurationItem(item)); + request.onData(items); + }); + call.on('error', (err) => { + debug('error emit, isCloseOrEnd: %s, %s', isCloseOrEnd, err); + lastError = err; + }); + call.on('close', () => { + debug('close emit, isCloseOrEnd: %s', isCloseOrEnd); + if (isCloseOrEnd) return; + isCloseOrEnd = true; + request.onClose(lastError); + }); + call.on('end', () => { + debug('end emit, isCloseOrEnd: %s', isCloseOrEnd); + if (isCloseOrEnd) return; + isCloseOrEnd = true; + request.onClose(lastError); + }); + call.write(req); + return call; + } + + private createGetConfigurationItem(item: ConfigurationItemPB): GetConfigurationItem { + const obj = item.toObject(); + return { + key: obj.key, + content: obj.content, + group: obj.group, + label: obj.label, + tags: convertArrayToKVString(obj.tagsMap), + metadata: convertArrayToKVString(obj.metadataMap), + }; + } +} diff --git a/sdk/js-sdk/src/index.ts b/sdk/js-sdk/src/index.ts index a666bc0ed2..6e93b659ac 100644 --- a/sdk/js-sdk/src/index.ts +++ b/sdk/js-sdk/src/index.ts @@ -13,7 +13,9 @@ * limitations under the License. */ import Client from './Client'; +import * as utils from './utils'; export { - Client + Client, + utils } diff --git a/sdk/js-sdk/src/types/Configuration.ts b/sdk/js-sdk/src/types/Configuration.ts new file mode 100644 index 0000000000..ad7f037ce4 --- /dev/null +++ b/sdk/js-sdk/src/types/Configuration.ts @@ -0,0 +1,71 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { KVString } from './common'; + +export type GetConfigurationRequest = { + storeName: string; + appId: string; + keys: string[]; + group?: string; + label?: string; + subscribeUpdate?: boolean; + metadata?: KVString; +}; + +export type GetConfigurationItem = { + key: string; + content: string; + group: string; + label: string; + tags: KVString; + metadata: KVString; +}; + +export type SaveConfigurationItem = { + key: string, + content: string, + group?: string, + label?: string, + tags?: KVString, + metadata?: KVString, +}; + +export type SaveConfigurationRequest = { + storeName: string; + appId: string; + items: SaveConfigurationItem[]; + metadata?: KVString; +}; + +export type DeleteConfigurationRequest = { + storeName: string; + appId: string; + keys: string[]; + group?: string; + label?: string; + metadata?: KVString; +}; + +export type SubscribeConfigurationRequest = { + storeName: string; + appId: string; + keys: string[]; + group?: string; + label?: string; + metadata?: KVString; + onData(items: GetConfigurationItem[]): void; + onClose(err?: Error): void; +}; diff --git a/sdk/js-sdk/src/types/common.ts b/sdk/js-sdk/src/types/common.ts new file mode 100644 index 0000000000..857b7f1a19 --- /dev/null +++ b/sdk/js-sdk/src/types/common.ts @@ -0,0 +1,28 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export type KV = { + [key: string]: Type; +}; + +export type KVString = KV; + +export function convertArrayToKVString(items: [string, string][]) { + const kv: KVString = {}; + for (const item of items) { + kv[item[0]] = item[1]; + } + return kv; +}; diff --git a/sdk/js-sdk/test/unit/Configuration.test.ts b/sdk/js-sdk/test/unit/Configuration.test.ts new file mode 100644 index 0000000000..b3378de934 --- /dev/null +++ b/sdk/js-sdk/test/unit/Configuration.test.ts @@ -0,0 +1,155 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { strict as assert } from 'assert'; +import { Client } from '../../src'; +import { sleep } from '../../src/utils'; + +describe('Configuration.test.ts', () => { + let client: Client; + const storeName = 'etcd'; + const appId = 'js-sdk-unittest'; + const key1 = `hello1-${Date.now()}`; + const key2 = `hello2-${Date.now()}`; + + beforeAll(() => { + client = new Client(); + }); + + it('should save/get/delete configuration work', async () => { + let configs = await client.configuration.get({ + storeName, + appId, + keys: [key1, key2], + }); + assert.equal(configs.length, 0); + // save success + + await client.configuration.save({ + storeName, + appId, + items: [ + { + key: key1, + content: 'world1 哈哈,😄', + }, + { + key: key2, + content: 'world2 哈哈,😄', + }, + ], + }); + + configs = await client.configuration.get({ + storeName, + appId, + keys: [key1, key2], + }); + assert.equal(configs.length, 2); + assert.equal(configs[0].key, key1); + assert.equal(configs[0].content, 'world1 哈哈,😄'); + assert.equal(configs[1].key, key2); + assert.equal(configs[1].content, 'world2 哈哈,😄'); + + // delete them + await client.configuration.delete({ + storeName, + appId, + keys: [key1, key2], + }); + configs = await client.configuration.get({ + storeName, + appId, + keys: [key1, key2], + }); + assert.equal(configs.length, 0); + }); + + it('should subscribe work', async () => { + await client.configuration.save({ + storeName, + appId, + items: [ + { + key: key1, + content: 'world1 哈哈,😄', + }, + { + key: key2, + content: 'world2 哈哈,😄', + }, + ], + }); + const configs = await client.configuration.get({ + storeName, + appId, + keys: [key1, key2], + }); + assert.equal(configs.length, 2); + + let lastConfig = {}; + const call = client.configuration.subscribe({ + storeName, + appId, + keys: [key1, key2], + onData(items) { + console.log('get items', items); + for (const item of items) { + lastConfig[item.key] = item.content; + } + }, + onClose(err) { + console.log('close, error: %s', err); + }, + }); + console.log('call send', call.destroyed); + await sleep(500); + await client.configuration.save({ + storeName, + appId, + items: [ + { + key: key1, + content: 'world1111 哈哈,😄', + }, + { + key: key2, + content: 'world2222 哈哈,😄', + }, + ], + }); + await sleep(500); + assert.equal(lastConfig[key1], 'world1111 哈哈,😄'); + assert.equal(lastConfig[key2], 'world2222 哈哈,😄'); + + await client.configuration.save({ + storeName, + appId, + items: [ + { + key: key2, + content: 'world2222-update2 哈哈,😄', + }, + ], + }); + + await sleep(500); + assert.equal(lastConfig[key1], 'world1111 哈哈,😄'); + assert.equal(lastConfig[key2], 'world2222-update2 哈哈,😄'); + + call.end(); + call.destroy(); + await sleep(500); + }); +}); From 5940b25b4d4cfcb8471fa36230270d8523025a98 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Fri, 29 Oct 2021 23:52:05 +0800 Subject: [PATCH 07/13] refactor(js-sdk): use Request args on SDK API --- demo/configuration/etcd/etcd.go | 3 +- sdk/js-sdk/README.md | 7 +- sdk/js-sdk/demo/configuration/subscribe.ts | 4 +- sdk/js-sdk/demo/helloworld.ts | 5 +- sdk/js-sdk/demo/package.json | 2 +- sdk/js-sdk/demo/state.js | 11 +- sdk/js-sdk/demo/state.mjs | 11 +- sdk/js-sdk/demo/state.ts | 12 ++- sdk/js-sdk/src/API.ts | 12 +-- sdk/js-sdk/src/Configuration.ts | 18 ++-- sdk/js-sdk/src/Hello.ts | 19 ++-- sdk/js-sdk/src/Invoker.ts | 54 ++++++---- sdk/js-sdk/src/Lock.ts | 38 ++++--- sdk/js-sdk/src/Sequencer.ts | 22 ++-- sdk/js-sdk/src/State.ts | 117 +++++++++++---------- sdk/js-sdk/src/index.ts | 4 +- sdk/js-sdk/src/types/Configuration.ts | 11 +- sdk/js-sdk/src/types/Hello.ts | 6 ++ sdk/js-sdk/src/types/Invoker.ts | 13 ++- sdk/js-sdk/src/types/Lock.ts | 15 ++- sdk/js-sdk/src/types/Sequencer.ts | 9 +- sdk/js-sdk/src/types/State.ts | 40 ++++++- sdk/js-sdk/src/types/common.ts | 6 +- sdk/js-sdk/src/utils.ts | 28 +++++ sdk/js-sdk/test/unit/Client.test.ts | 2 + sdk/js-sdk/test/unit/Configuration.test.ts | 11 +- sdk/js-sdk/test/unit/Invoker.test.ts | 19 +++- sdk/js-sdk/test/unit/Lock.test.ts | 24 ++--- sdk/js-sdk/test/unit/Sequencer.test.ts | 28 ++++- sdk/js-sdk/test/unit/State.test.ts | 82 +++++++++++---- 30 files changed, 418 insertions(+), 215 deletions(-) create mode 100644 sdk/js-sdk/src/types/Hello.ts diff --git a/demo/configuration/etcd/etcd.go b/demo/configuration/etcd/etcd.go index 5a0c88ef4d..791278c04a 100644 --- a/demo/configuration/etcd/etcd.go +++ b/demo/configuration/etcd/etcd.go @@ -19,8 +19,9 @@ package main import ( "context" "fmt" - client "mosn.io/layotto/sdk/go-sdk/client" "time" + + client "mosn.io/layotto/sdk/go-sdk/client" ) func main() { diff --git a/sdk/js-sdk/README.md b/sdk/js-sdk/README.md index 282254f8ff..a628ee302e 100644 --- a/sdk/js-sdk/README.md +++ b/sdk/js-sdk/README.md @@ -15,10 +15,13 @@ const storeName = 'redis'; const key = 'foo-js-sdk'; const value = `bar, from js-sdk, ${Date()}`; -await client.state.save(storeName, { key, value }); +await client.state.save({ + storeName, + states: { key, value }, +}); console.log('saveState success, key: %j, value: %j', key, value); -const resValue = await client.state.get(storeName, key); +const resValue = await client.state.get({ storeName, key }); console.log('getState success, key: %j, value: %j, toString: %j', key, resValue, Buffer.from(resValue).toString('utf8')); ``` diff --git a/sdk/js-sdk/demo/configuration/subscribe.ts b/sdk/js-sdk/demo/configuration/subscribe.ts index 8ae510c099..b27a1a7b7d 100644 --- a/sdk/js-sdk/demo/configuration/subscribe.ts +++ b/sdk/js-sdk/demo/configuration/subscribe.ts @@ -19,7 +19,9 @@ const client = new Client(); assert(client); async function main() { - const hello = await client.hello.sayHello('helloworld', 'js-sdk'); + const hello = await client.hello.sayHello({ + name: 'js-sdk', + }); console.log('%s', hello); await client.configuration.save({ diff --git a/sdk/js-sdk/demo/helloworld.ts b/sdk/js-sdk/demo/helloworld.ts index 036f558c01..d11f6eb204 100644 --- a/sdk/js-sdk/demo/helloworld.ts +++ b/sdk/js-sdk/demo/helloworld.ts @@ -19,7 +19,10 @@ const client = new Client(); assert(client); async function main() { - const hello = await client.hello.sayHello('helloworld', 'js-sdk'); + const hello = await client.hello.sayHello({ + serviceName: 'helloworld', + name: 'js-sdk', + }); console.log('%s', hello); } diff --git a/sdk/js-sdk/demo/package.json b/sdk/js-sdk/demo/package.json index ab460ed026..92ac9cc075 100644 --- a/sdk/js-sdk/demo/package.json +++ b/sdk/js-sdk/demo/package.json @@ -7,7 +7,7 @@ "test:all": "npm run test:cjs && npm run test:esm && npm run test:ts", "test:cjs": "node ./state.js", "test:esm": "node ./state.mjs", - "test:ts": "ts-node ./state.ts" + "test:ts": "ts-node ./state.ts && ts-node ./configuration/subscribe.ts" }, "dependencies": { "koa": "^2.13.4", diff --git a/sdk/js-sdk/demo/state.js b/sdk/js-sdk/demo/state.js index 99a61a390c..c2ff2a0158 100644 --- a/sdk/js-sdk/demo/state.js +++ b/sdk/js-sdk/demo/state.js @@ -9,12 +9,15 @@ async function main() { const key = 'foo-js-sdk'; const value = `bar, from js-sdk, ${Date()}`; - await client.state.save(storeName, [ - { key, value }, - ]); + await client.state.save({ + storeName, + states: [ + { key, value }, + ], + }); console.log('saveState success, key: %j, value: %j', key, value); - const state = await client.state.get(storeName, key); + const state = await client.state.get({ storeName, key }); console.log('getState success, key: %j, value: %j, toString: %j', key, state.value, Buffer.from(state.value).toString('utf8')); } diff --git a/sdk/js-sdk/demo/state.mjs b/sdk/js-sdk/demo/state.mjs index 26c418e415..ce5a11b9a4 100644 --- a/sdk/js-sdk/demo/state.mjs +++ b/sdk/js-sdk/demo/state.mjs @@ -9,12 +9,15 @@ async function main() { const key = 'foo-js-sdk'; const value = `bar, from js-sdk, ${Date()}`; - await client.state.save(storeName, [ - { key, value }, - ]); + await client.state.save({ + storeName, + states: [ + { key, value }, + ], + }); console.log('saveState success, key: %j, value: %j', key, value); - const state = await client.state.get(storeName, key); + const state = await client.state.get({ storeName, key }); console.log('getState success, key: %j, value: %j, toString: %j', key, state.value, Buffer.from(state.value).toString('utf8')); } diff --git a/sdk/js-sdk/demo/state.ts b/sdk/js-sdk/demo/state.ts index 8b0da7bf16..cdb73dee0b 100644 --- a/sdk/js-sdk/demo/state.ts +++ b/sdk/js-sdk/demo/state.ts @@ -23,15 +23,19 @@ async function main() { const key = 'foo-js-sdk'; const value = `bar, from js-sdk, ${Date()}`; - await client.state.save(storeName, [ - { key, value }, - ], { traceid: 'mock-tracerid-123123' }); + await client.state.save({ + storeName, + states: [ + { key, value }, + ], + requestMeta: { traceid: 'mock-tracerid-123123' }, + }); console.log('saveState success, key: %j, value: %j', key, value); // await client.state.save(storeName, { key, value }); // console.log('saveState success, key: %j, value: %j', key, value); - const state = await client.state.get(storeName, key); + const state = await client.state.get({ storeName, key }); assert(state); console.log('getState success, key: %j, value: %j, toString: %j', key, state.value, Buffer.from(state.value).toString('utf8')); diff --git a/sdk/js-sdk/src/API.ts b/sdk/js-sdk/src/API.ts index 202e88f16c..8392e7b67d 100644 --- a/sdk/js-sdk/src/API.ts +++ b/sdk/js-sdk/src/API.ts @@ -14,11 +14,7 @@ */ import { Metadata } from '@grpc/grpc-js'; import { RuntimeClient } from '../proto/runtime_grpc_pb'; - -// gRPC meta data -export type RequestMetadata = { - [key: string]: string; -}; +import { RequestWithMeta } from './types/common'; export class API { readonly runtime: RuntimeClient; @@ -26,10 +22,10 @@ export class API { this.runtime = runtime; } - createMetadata(meta?: RequestMetadata) { + createMetadata(request: RequestWithMeta): Metadata { const metadata = new Metadata(); - for (const key in meta) { - metadata.add(key, meta[key]); + for (const key in request.requestMeta) { + metadata.add(key, request.requestMeta[key]); } return metadata; } diff --git a/sdk/js-sdk/src/Configuration.ts b/sdk/js-sdk/src/Configuration.ts index c6efbfeec8..19563cca9e 100644 --- a/sdk/js-sdk/src/Configuration.ts +++ b/sdk/js-sdk/src/Configuration.ts @@ -22,7 +22,7 @@ import { SubscribeConfigurationRequest as SubscribeConfigurationRequestPB, SubscribeConfigurationResponse as SubscribeConfigurationResponsePB, } from '../proto/runtime_pb'; -import { API, RequestMetadata } from './API'; +import { API } from './API'; import { GetConfigurationRequest, GetConfigurationItem, @@ -36,7 +36,7 @@ const debug = debuglog('layotto:configuration'); export default class Configuration extends API { // GetConfiguration gets configuration from configuration store. - async get(request: GetConfigurationRequest, grpcMeta?: RequestMetadata): Promise { + async get(request: GetConfigurationRequest): Promise { const req = new GetConfigurationRequestPB(); req.setStoreName(request.storeName); req.setAppId(request.appId); @@ -48,7 +48,7 @@ export default class Configuration extends API { } // TODO: support set metadataMap return new Promise((resolve, reject) => { - this.runtime.getConfiguration(req, this.createMetadata(grpcMeta), (err, res: GetConfigurationResponsePB) => { + this.runtime.getConfiguration(req, this.createMetadata(request), (err, res: GetConfigurationResponsePB) => { if (err) return reject(err); resolve(res.getItemsList().map(item => this.createGetConfigurationItem(item))); }); @@ -56,7 +56,7 @@ export default class Configuration extends API { } // SaveConfiguration saves configuration into configuration store. - async save(request: SaveConfigurationRequest, grpcMeta?: RequestMetadata): Promise { + async save(request: SaveConfigurationRequest): Promise { const req = new SaveConfigurationRequestPB(); req.setStoreName(request.storeName); req.setAppId(request.appId); @@ -70,7 +70,7 @@ export default class Configuration extends API { })); return new Promise((resolve, reject) => { - this.runtime.saveConfiguration(req, this.createMetadata(grpcMeta), (err) => { + this.runtime.saveConfiguration(req, this.createMetadata(request), (err) => { if (err) return reject(err); resolve(); }); @@ -78,7 +78,7 @@ export default class Configuration extends API { } // DeleteConfiguration deletes configuration from configuration store. - async delete(request: DeleteConfigurationRequest, grpcMeta?: RequestMetadata): Promise { + async delete(request: DeleteConfigurationRequest): Promise { const req = new DeleteConfigurationRequestPB(); req.setStoreName(request.storeName); req.setAppId(request.appId); @@ -87,7 +87,7 @@ export default class Configuration extends API { if (request.label) req.setLabel(request.label); return new Promise((resolve, reject) => { - this.runtime.deleteConfiguration(req, this.createMetadata(grpcMeta), (err) => { + this.runtime.deleteConfiguration(req, this.createMetadata(request), (err) => { if (err) return reject(err); resolve(); }); @@ -95,7 +95,7 @@ export default class Configuration extends API { } // SubscribeConfiguration gets configuration from configuration store and subscribe the updates. - subscribe(request: SubscribeConfigurationRequest, grpcMeta?: RequestMetadata) { + subscribe(request: SubscribeConfigurationRequest) { const req = new SubscribeConfigurationRequestPB(); req.setStoreName(request.storeName); req.setAppId(request.appId); @@ -105,7 +105,7 @@ export default class Configuration extends API { let lastError: Error; let isCloseOrEnd = false; - const call = this.runtime.subscribeConfiguration(this.createMetadata(grpcMeta)); + const call = this.runtime.subscribeConfiguration(this.createMetadata(request)); call.on('readable', () => { const res: SubscribeConfigurationResponsePB = call.read(); debug('readable emit, has res: %s', !!res); diff --git a/sdk/js-sdk/src/Hello.ts b/sdk/js-sdk/src/Hello.ts index 09a1c1e160..9d793bb1f9 100644 --- a/sdk/js-sdk/src/Hello.ts +++ b/sdk/js-sdk/src/Hello.ts @@ -13,20 +13,21 @@ * limitations under the License. */ import { - SayHelloRequest + SayHelloRequest as SayHelloRequestPB, + SayHelloResponse as SayHelloResponsePB, } from '../proto/runtime_pb'; -import { API, RequestMetadata } from './API'; +import { API } from './API'; +import { SayHelloRequest } from './types/Hello'; export default class Hello extends API { - async sayHello(serviceName = 'helloworld', name = '', meta?: RequestMetadata): Promise { - const req = new SayHelloRequest(); - req.setServiceName(serviceName); - if (name) { - req.setName(name); - } + async sayHello(request?: SayHelloRequest): Promise { + const req = new SayHelloRequestPB(); + if (!request) request = {}; + req.setServiceName(request.serviceName || 'helloworld'); + if (request.name) req.setName(request.name); return new Promise((resolve, reject) => { - this.runtime.sayHello(req, this.createMetadata(meta), (err, res) => { + this.runtime.sayHello(req, this.createMetadata(request as SayHelloRequest), (err, res: SayHelloResponsePB) => { if (err) return reject(err); resolve(res.getHello()); }); diff --git a/sdk/js-sdk/src/Invoker.ts b/sdk/js-sdk/src/Invoker.ts index f6d2de9885..a93344dcf2 100644 --- a/sdk/js-sdk/src/Invoker.ts +++ b/sdk/js-sdk/src/Invoker.ts @@ -12,43 +12,55 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Any } from "google-protobuf/google/protobuf/any_pb"; +import { Any } from 'google-protobuf/google/protobuf/any_pb'; import { - InvokeServiceRequest, - CommonInvokeRequest, + InvokeServiceRequest as InvokeServiceRequestPB, + CommonInvokeRequest as CommonInvokeRequestPB, HTTPExtension, - InvokeResponse, + InvokeResponse as InvokeResponsePB, } from '../proto/runtime_pb'; -import { API, RequestMetadata } from './API'; +import { API } from './API'; +import { InvokeServiceRequest, InvokeResponse } from './types/Invoker'; export default class Invoker extends API { - async invoke(id: string, methodName: string, httpVerb = HTTPExtension.Verb.GET, data: string | object = {}, meta?: RequestMetadata): Promise { - const message = new CommonInvokeRequest(); - message.setMethod(methodName); + async invoke(request: InvokeServiceRequest): Promise { + const message = new CommonInvokeRequestPB(); + message.setMethod(request.method); + const httpVerb = request.httpVerb || HTTPExtension.Verb.GET; const httpExtension = new HTTPExtension(); httpExtension.setVerb(httpVerb); message.setHttpExtension(httpExtension); - const dataSerialized = new Any(); - if (typeof data === 'string') { - message.setContentType(''); - dataSerialized.setValue(Buffer.from(data, 'utf8')); - } else { - message.setContentType('application/json'); - dataSerialized.setValue(Buffer.from(JSON.stringify(data), 'utf8')); + if (request.data) { + const dataSerialized = new Any(); + if (typeof request.data === 'string') { + message.setContentType('text/plain; charset=UTF-8'); + dataSerialized.setValue(Buffer.from(request.data, 'utf8')); + } else { + message.setContentType('application/json'); + dataSerialized.setValue(Buffer.from(JSON.stringify(request.data), 'utf8')); + } + message.setData(dataSerialized); } - message.setData(dataSerialized); - const req = new InvokeServiceRequest(); - req.setId(id); + const req = new InvokeServiceRequestPB(); + req.setId(request.id); req.setMessage(message); return new Promise((resolve, reject) => { - this.runtime.invokeService(req, this.createMetadata(meta), (err, res: InvokeResponse) => { + this.runtime.invokeService(req, this.createMetadata(request), (err, res: InvokeResponsePB) => { if (err) return reject(err); - const data = JSON.parse(res.getData()); - resolve(data); + const contentType = res.getContentType().split(';', 1)[0].toLowerCase(); + const content = res.getData() as Buffer; + const response: InvokeResponse = { contentType, content }; + if (contentType === 'application/json') { + response.content = JSON.parse(content.toString()); + } + if (contentType === 'text/plain') { + response.content = content.toString(); + } + resolve(response); }); }); } diff --git a/sdk/js-sdk/src/Lock.ts b/sdk/js-sdk/src/Lock.ts index 13cc6d2998..2b9a6edfef 100644 --- a/sdk/js-sdk/src/Lock.ts +++ b/sdk/js-sdk/src/Lock.ts @@ -13,37 +13,43 @@ * limitations under the License. */ import * as crypto from 'crypto'; -import { TryLockRequest, TryLockResponse, UnlockRequest, UnlockResponse } from '../proto/runtime_pb'; -import { API, RequestMetadata } from './API'; +import { + TryLockRequest as TryLockRequestPB, + TryLockResponse as TryLockResponsePB, + UnlockRequest as UnlockRequestPB, + UnlockResponse as UnlockResponsePB, +} from '../proto/runtime_pb'; +import { API } from './API'; +import { TryLockRequest, UnlockRequest } from './types/Lock'; export default class Lock extends API { // A non-blocking method trying to get a lock with ttl // expire is the time before expire. The time unit is second. - async tryLock(storeName: string, resourceId: string, lockOwner: string, expire: number, meta?: RequestMetadata): Promise { - const req = new TryLockRequest(); - req.setStoreName(storeName); - req.setResourceId(resourceId); - req.setLockOwner(lockOwner); - req.setExpire(expire); + async tryLock(request: TryLockRequest): Promise { + const req = new TryLockRequestPB(); + req.setStoreName(request.storeName); + req.setResourceId(request.resourceId); + req.setLockOwner(request.lockOwner); + req.setExpire(request.expire); return new Promise((resolve, reject) => { - this.runtime.tryLock(req, this.createMetadata(meta), (err, res: TryLockResponse) => { + this.runtime.tryLock(req, this.createMetadata(request), (err, res: TryLockResponsePB) => { if (err) return reject(err); resolve(res.getSuccess()); }); }); } - async unLock(storeName: string, resourceId: string, lockOwner: string, meta?: RequestMetadata): Promise { - const req = new UnlockRequest(); - req.setStoreName(storeName); - req.setResourceId(resourceId); - req.setLockOwner(lockOwner); + async unLock(request: UnlockRequest): Promise { + const req = new UnlockRequestPB(); + req.setStoreName(request.storeName); + req.setResourceId(request.resourceId); + req.setLockOwner(request.lockOwner); return new Promise((resolve, reject) => { - this.runtime.unlock(req, this.createMetadata(meta), (err, res: UnlockResponse) => { + this.runtime.unlock(req, this.createMetadata(request), (err, res: UnlockResponsePB) => { if (err) return reject(err); - resolve(res.getStatus()); + resolve(res.toObject()); }); }); } diff --git a/sdk/js-sdk/src/Sequencer.ts b/sdk/js-sdk/src/Sequencer.ts index 585ac8d28f..3ef568d8ee 100644 --- a/sdk/js-sdk/src/Sequencer.ts +++ b/sdk/js-sdk/src/Sequencer.ts @@ -13,27 +13,27 @@ * limitations under the License. */ import { - GetNextIdRequest, - GetNextIdResponse, + GetNextIdRequest as GetNextIdRequestPB, + GetNextIdResponse as GetNextIdResponsePB, SequencerOptions as SequencerOptionsPB, } from '../proto/runtime_pb'; -import { API, RequestMetadata } from './API'; -import { SequencerOptions } from './types/Sequencer'; +import { API } from './API'; +import { GetNextIdRequest } from './types/Sequencer'; export default class Sequencer extends API { // Get next unique id with some auto-increment guarantee - async getNextId(storeName: string, key: string, options?: SequencerOptions, meta?: RequestMetadata): Promise { - const req = new GetNextIdRequest(); - req.setStoreName(storeName); - req.setKey(key); - if (options) { + async getNextId(request: GetNextIdRequest): Promise { + const req = new GetNextIdRequestPB(); + req.setStoreName(request.storeName); + req.setKey(request.key); + if (request.options) { const sequencerOptions = new SequencerOptionsPB(); - sequencerOptions.setIncrement(options.increment); + sequencerOptions.setIncrement(request.options.increment); req.setOptions(sequencerOptions); } return new Promise((resolve, reject) => { - this.runtime.getNextId(req, this.createMetadata(meta), (err, res: GetNextIdResponse) => { + this.runtime.getNextId(req, this.createMetadata(request), (err, res: GetNextIdResponsePB) => { if (err) return reject(err); resolve(res.getNextId()); }); diff --git a/sdk/js-sdk/src/State.ts b/sdk/js-sdk/src/State.ts index cd8713dbda..a80ae9c605 100644 --- a/sdk/js-sdk/src/State.ts +++ b/sdk/js-sdk/src/State.ts @@ -13,39 +13,45 @@ * limitations under the License. */ import { - SaveStateRequest, + SaveStateRequest as SaveStateRequestPB, StateItem as StateItemPB, - Etag, + Etag as EtagPB, StateOptions as StateOptionsPB, - GetStateRequest, - GetBulkStateRequest, - DeleteStateRequest, - DeleteBulkStateRequest, - ExecuteStateTransactionRequest, - TransactionalStateOperation, + GetStateRequest as GetStateRequestPB, + GetBulkStateRequest as GetBulkStateRequestPB, + DeleteStateRequest as DeleteStateRequestPB, + DeleteBulkStateRequest as DeleteBulkStateRequestPB, + ExecuteStateTransactionRequest as ExecuteStateTransactionRequestPB, + TransactionalStateOperation as TransactionalStateOperationPB, } from '../proto/runtime_pb'; -import { API, RequestMetadata } from './API'; +import { API } from './API'; import { + DeleteBulkStateRequest, DeleteStateItem, + DeleteStateRequest, + ExecuteStateTransactionRequest, + GetBulkStateRequest, + GetStateRequest, ResponseStateItem, + SaveStateRequest, StateItem, - StateOperation, - StateOptions, } from './types/State'; +import { isEmptyPBMessage } from './utils'; export default class State extends API { // Saves an array of state objects - async save(storeName: string, states: StateItem[] | StateItem, meta?: RequestMetadata): Promise { + async save(request: SaveStateRequest): Promise { + let states = request.states; if (!Array.isArray(states)) { states = [states]; } const stateList = this.createStateItemPBList(states); - const req = new SaveStateRequest(); - req.setStoreName(storeName); + const req = new SaveStateRequestPB(); + req.setStoreName(request.storeName); req.setStatesList(stateList); return new Promise((resolve, reject) => { - this.runtime.saveState(req, this.createMetadata(meta), (err) => { + this.runtime.saveState(req, this.createMetadata(request), (err) => { if (err) return reject(err); resolve(); }); @@ -53,19 +59,19 @@ export default class State extends API { } // Gets the state for a specific key - async get(storeName: string, key: string, meta?: RequestMetadata): Promise { - const req = new GetStateRequest(); - req.setStoreName(storeName); - req.setKey(key); + async get(request: GetStateRequest): Promise { + const req = new GetStateRequestPB(); + req.setStoreName(request.storeName); + req.setKey(request.key); return new Promise((resolve, reject) => { - this.runtime.getState(req, this.createMetadata(meta), (err, res) => { + this.runtime.getState(req, this.createMetadata(request), (err, res) => { if (err) return reject(err); - if (this.isEmpty(res)) { + if (isEmptyPBMessage(res)) { return resolve(null); } resolve({ - key, + key: request.key, value: res.getData_asU8(), etag: res.getEtag(), }); @@ -74,19 +80,20 @@ export default class State extends API { } // Gets a bulk of state items for a list of keys - async getBulk(storeName: string, keys: string[], parallelism = 10, meta?: RequestMetadata): Promise { - const req = new GetBulkStateRequest(); - req.setStoreName(storeName); - req.setKeysList(keys); - req.setParallelism(parallelism); + async getBulk(request: GetBulkStateRequest): Promise { + const req = new GetBulkStateRequestPB(); + req.setStoreName(request.storeName); + req.setKeysList(request.keys); + if (request.parallelism) req.setParallelism(request.parallelism); return new Promise((resolve, reject) => { - this.runtime.getBulkState(req, this.createMetadata(meta), (err, res) => { + this.runtime.getBulkState(req, this.createMetadata(request), (err, res) => { if (err) return reject(err); const states: ResponseStateItem[] = []; const itemsList = res.getItemsList(); for (const item of itemsList) { - if (this.isEmpty(item)) { + // pb.message.array[0] is key, pb.message.array[1] is value + if (isEmptyPBMessage(item, 1)) { continue; } states.push({ @@ -102,24 +109,24 @@ export default class State extends API { } // Deletes the state for a specific key - async delete(storeName: string, key: string, etag = '', options?: StateOptions, meta?: RequestMetadata): Promise { - const req = new DeleteStateRequest(); - req.setStoreName(storeName); - req.setKey(key); - if (etag) { - const etagInstance = new Etag(); - etagInstance.setValue(etag); + async delete(request: DeleteStateRequest): Promise { + const req = new DeleteStateRequestPB(); + req.setStoreName(request.storeName); + req.setKey(request.key); + if (request.etag) { + const etagInstance = new EtagPB(); + etagInstance.setValue(request.etag); req.setEtag(etagInstance); } - if (options) { + if (request.options) { const optionsInstance = new StateOptionsPB(); - optionsInstance.setConcurrency(options.concurrency); - optionsInstance.setConsistency(options.consistency); + optionsInstance.setConcurrency(request.options.concurrency); + optionsInstance.setConsistency(request.options.consistency); req.setOptions(optionsInstance); } return new Promise((resolve, reject) => { - this.runtime.deleteState(req, this.createMetadata(meta), (err) => { + this.runtime.deleteState(req, this.createMetadata(request), (err) => { if (err) return reject(err); resolve(); }); @@ -127,14 +134,14 @@ export default class State extends API { } // Deletes a bulk of state items for a list of keys - async deleteBulk(storeName: string, states: DeleteStateItem[], meta?: RequestMetadata): Promise { - const req = new DeleteBulkStateRequest(); - req.setStoreName(storeName); - const stateList = this.createStateItemPBList(states); + async deleteBulk(request: DeleteBulkStateRequest): Promise { + const req = new DeleteBulkStateRequestPB(); + req.setStoreName(request.storeName); + const stateList = this.createStateItemPBList(request.states); req.setStatesList(stateList); return new Promise((resolve, reject) => { - this.runtime.deleteBulkState(req, this.createMetadata(meta), (err) => { + this.runtime.deleteBulkState(req, this.createMetadata(request), (err) => { if (err) return reject(err); resolve(); }); @@ -142,12 +149,12 @@ export default class State extends API { } // Executes transactions for a specified store - async executeTransaction(storeName: string, operations: StateOperation[], meta?: RequestMetadata): Promise { - const req = new ExecuteStateTransactionRequest(); - req.setStorename(storeName); - const operationsList: TransactionalStateOperation[] = []; - for (const operation of operations) { - const ops = new TransactionalStateOperation(); + async executeTransaction(request: ExecuteStateTransactionRequest): Promise { + const req = new ExecuteStateTransactionRequestPB(); + req.setStorename(request.storeName); + const operationsList: TransactionalStateOperationPB[] = []; + for (const operation of request.operations) { + const ops = new TransactionalStateOperationPB(); ops.setOperationtype(operation.operationType); const stateItem = this.createStateItemPB(operation.request); ops.setRequest(stateItem); @@ -156,7 +163,7 @@ export default class State extends API { req.setOperationsList(operationsList); return new Promise((resolve, reject) => { - this.runtime.executeStateTransaction(req, this.createMetadata(meta), (err, _res) => { + this.runtime.executeStateTransaction(req, this.createMetadata(request), (err, _res) => { if (err) return reject(err); resolve(); }); @@ -174,7 +181,7 @@ export default class State extends API { } } if (item.etag !== undefined) { - const etag = new Etag(); + const etag = new EtagPB(); etag.setValue(item.etag); stateItem.setEtag(etag); } @@ -194,8 +201,4 @@ export default class State extends API { } return list; } - - private isEmpty(obj: { getEtag(): string }) { - return obj.getEtag() === ''; - } } diff --git a/sdk/js-sdk/src/index.ts b/sdk/js-sdk/src/index.ts index 6e93b659ac..d2b3e1e37b 100644 --- a/sdk/js-sdk/src/index.ts +++ b/sdk/js-sdk/src/index.ts @@ -14,8 +14,10 @@ */ import Client from './Client'; import * as utils from './utils'; +import * as RumtimeTypes from '../proto/runtime_pb'; export { Client, - utils + utils, + RumtimeTypes, } diff --git a/sdk/js-sdk/src/types/Configuration.ts b/sdk/js-sdk/src/types/Configuration.ts index ad7f037ce4..e374da1410 100644 --- a/sdk/js-sdk/src/types/Configuration.ts +++ b/sdk/js-sdk/src/types/Configuration.ts @@ -12,8 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -import { KVString } from './common'; +import { KVString, RequestWithMeta } from './common'; export type GetConfigurationRequest = { storeName: string; @@ -23,7 +22,7 @@ export type GetConfigurationRequest = { label?: string; subscribeUpdate?: boolean; metadata?: KVString; -}; +} & RequestWithMeta; export type GetConfigurationItem = { key: string; @@ -48,7 +47,7 @@ export type SaveConfigurationRequest = { appId: string; items: SaveConfigurationItem[]; metadata?: KVString; -}; +} & RequestWithMeta; export type DeleteConfigurationRequest = { storeName: string; @@ -57,7 +56,7 @@ export type DeleteConfigurationRequest = { group?: string; label?: string; metadata?: KVString; -}; +} & RequestWithMeta; export type SubscribeConfigurationRequest = { storeName: string; @@ -68,4 +67,4 @@ export type SubscribeConfigurationRequest = { metadata?: KVString; onData(items: GetConfigurationItem[]): void; onClose(err?: Error): void; -}; +} & RequestWithMeta; diff --git a/sdk/js-sdk/src/types/Hello.ts b/sdk/js-sdk/src/types/Hello.ts new file mode 100644 index 0000000000..dab5f367ae --- /dev/null +++ b/sdk/js-sdk/src/types/Hello.ts @@ -0,0 +1,6 @@ +import { RequestWithMeta } from './common'; + +export type SayHelloRequest = { + serviceName?: string; + name?: string; +} & RequestWithMeta; diff --git a/sdk/js-sdk/src/types/Invoker.ts b/sdk/js-sdk/src/types/Invoker.ts index 014f5c11d1..4163019356 100644 --- a/sdk/js-sdk/src/types/Invoker.ts +++ b/sdk/js-sdk/src/types/Invoker.ts @@ -13,5 +13,16 @@ * limitations under the License. */ import { HTTPExtension } from '../../proto/runtime_pb'; +import { RequestWithMeta } from './common'; -export const HTTPExtensionVerb = HTTPExtension.Verb; +export type InvokeServiceRequest = { + id: string; + method: string; + httpVerb?: HTTPExtension.Verb; + data?: string | object; +} & RequestWithMeta; + +export type InvokeResponse = { + contentType: string; + content: string | Buffer | object; +}; diff --git a/sdk/js-sdk/src/types/Lock.ts b/sdk/js-sdk/src/types/Lock.ts index 025a3777a8..399c970658 100644 --- a/sdk/js-sdk/src/types/Lock.ts +++ b/sdk/js-sdk/src/types/Lock.ts @@ -12,6 +12,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { UnlockResponse } from '../../proto/runtime_pb'; +import { RequestWithMeta } from './common'; -export const UnlockResponseStatus = UnlockResponse.Status; +export type TryLockRequest = { + storeName: string; + resourceId: string; + lockOwner: string; + expire: number; +} & RequestWithMeta; + +export type UnlockRequest = { + storeName: string; + resourceId: string; + lockOwner: string; +} & RequestWithMeta; diff --git a/sdk/js-sdk/src/types/Sequencer.ts b/sdk/js-sdk/src/types/Sequencer.ts index a557342eb7..64bd750e5e 100644 --- a/sdk/js-sdk/src/types/Sequencer.ts +++ b/sdk/js-sdk/src/types/Sequencer.ts @@ -15,9 +15,14 @@ import { SequencerOptions as SequencerOptionsPB, } from '../../proto/runtime_pb'; - -export const SequencerOptionsAutoIncrement = SequencerOptionsPB.AutoIncrement; +import { RequestWithMeta } from './common'; export type SequencerOptions = { increment: SequencerOptionsPB.AutoIncrement; }; + +export type GetNextIdRequest = { + storeName: string; + key: string; + options?: SequencerOptions; +} & RequestWithMeta; diff --git a/sdk/js-sdk/src/types/State.ts b/sdk/js-sdk/src/types/State.ts index 55d33f3284..5b09e2ee56 100644 --- a/sdk/js-sdk/src/types/State.ts +++ b/sdk/js-sdk/src/types/State.ts @@ -15,13 +15,11 @@ import { StateOptions as StateOptionsPB, } from '../../proto/runtime_pb'; - -export type StateConcurrency = StateOptionsPB.StateConcurrency; -export type StateConsistency = StateOptionsPB.StateConsistency; +import { RequestWithMeta } from './common'; export type StateOptions = { - concurrency: StateConcurrency; - consistency: StateConsistency; + concurrency: StateOptionsPB.StateConcurrency; + consistency: StateOptionsPB.StateConsistency; }; export type StateItem = { @@ -54,3 +52,35 @@ export type StateOperation = { request: StateItem | DeleteStateItem; }; +export type SaveStateRequest = { + storeName: string; + states: StateItem[] | StateItem; +} & RequestWithMeta; + +export type GetStateRequest = { + storeName: string; + key: string; +} & RequestWithMeta; + +export type GetBulkStateRequest = { + storeName: string; + keys: string[]; + parallelism?: number; +} & RequestWithMeta; + +export type DeleteStateRequest = { + storeName: string; + key: string; + etag?: string; + options?: StateOptions +} & RequestWithMeta; + +export type DeleteBulkStateRequest = { + storeName: string; + states: DeleteStateItem[]; +} & RequestWithMeta; + +export type ExecuteStateTransactionRequest = { + storeName: string; + operations: StateOperation[]; +} & RequestWithMeta; diff --git a/sdk/js-sdk/src/types/common.ts b/sdk/js-sdk/src/types/common.ts index 857b7f1a19..5e21a9941e 100644 --- a/sdk/js-sdk/src/types/common.ts +++ b/sdk/js-sdk/src/types/common.ts @@ -17,7 +17,11 @@ export type KV = { [key: string]: Type; }; -export type KVString = KV; +export type KVString = KV; + +export type RequestWithMeta = { + requestMeta?: KVString; +}; export function convertArrayToKVString(items: [string, string][]) { const kv: KVString = {}; diff --git a/sdk/js-sdk/src/utils.ts b/sdk/js-sdk/src/utils.ts index 58c924299b..d6ea591b12 100644 --- a/sdk/js-sdk/src/utils.ts +++ b/sdk/js-sdk/src/utils.ts @@ -17,3 +17,31 @@ import { setTimeout } from 'timers/promises'; export async function sleep(ms: number) { await setTimeout(ms); } + +// jspb.Message +// https://github.com/protocolbuffers/protobuf/blob/master/js/message.js#L233 +// +// use array to detect not exists or empty +// console.log(res) +// not exists +// { +// wrappers_: null, +// messageId_: undefined, +// arrayIndexOffset_: -1, +// array: [], +// pivot_: 1.7976931348623157e+308, +// convertedPrimitiveFields_: {} +// } +// empty data +// { +// wrappers_: null, +// messageId_: undefined, +// arrayIndexOffset_: -1, +// array: [ <1 empty item>, '1' ], +// pivot_: 1.7976931348623157e+308, +// convertedPrimitiveFields_: {} +// } +export function isEmptyPBMessage(item, emptyLength = 0) { + if (item.array.length === emptyLength) return true; + return false; +} diff --git a/sdk/js-sdk/test/unit/Client.test.ts b/sdk/js-sdk/test/unit/Client.test.ts index 360c58eabd..89cfa59d6b 100644 --- a/sdk/js-sdk/test/unit/Client.test.ts +++ b/sdk/js-sdk/test/unit/Client.test.ts @@ -21,6 +21,8 @@ describe('Client.test.ts', () => { client = new Client(); const hello = await client.hello.sayHello(); assert.equal(hello, 'greeting, '); + const hello2 = await client.hello.sayHello({ name: 'js-sdk' }); + assert.equal(hello2, 'greeting, js-sdk'); }); it('should create a Client with default port', () => { diff --git a/sdk/js-sdk/test/unit/Configuration.test.ts b/sdk/js-sdk/test/unit/Configuration.test.ts index b3378de934..7ab0b00931 100644 --- a/sdk/js-sdk/test/unit/Configuration.test.ts +++ b/sdk/js-sdk/test/unit/Configuration.test.ts @@ -13,8 +13,7 @@ * limitations under the License. */ import { strict as assert } from 'assert'; -import { Client } from '../../src'; -import { sleep } from '../../src/utils'; +import { Client, utils } from '../../src'; describe('Configuration.test.ts', () => { let client: Client; @@ -114,7 +113,7 @@ describe('Configuration.test.ts', () => { }, }); console.log('call send', call.destroyed); - await sleep(500); + await utils.sleep(500); await client.configuration.save({ storeName, appId, @@ -129,7 +128,7 @@ describe('Configuration.test.ts', () => { }, ], }); - await sleep(500); + await utils.sleep(500); assert.equal(lastConfig[key1], 'world1111 哈哈,😄'); assert.equal(lastConfig[key2], 'world2222 哈哈,😄'); @@ -144,12 +143,12 @@ describe('Configuration.test.ts', () => { ], }); - await sleep(500); + await utils.sleep(500); assert.equal(lastConfig[key1], 'world1111 哈哈,😄'); assert.equal(lastConfig[key2], 'world2222-update2 哈哈,😄'); call.end(); call.destroy(); - await sleep(500); + await utils.sleep(500); }); }); diff --git a/sdk/js-sdk/test/unit/Invoker.test.ts b/sdk/js-sdk/test/unit/Invoker.test.ts index 705847e60b..711cca4cd9 100644 --- a/sdk/js-sdk/test/unit/Invoker.test.ts +++ b/sdk/js-sdk/test/unit/Invoker.test.ts @@ -14,9 +14,9 @@ */ import { strict as assert } from 'assert'; import { Client } from '../../src'; -import { HTTPExtensionVerb } from '../../src/types/Invoker'; +import { RumtimeTypes } from '../../src'; -describe('Invoker.test.ts', () => { +describe.skip('Invoker.test.ts', () => { let client: Client; beforeAll(() => { @@ -25,13 +25,22 @@ describe('Invoker.test.ts', () => { describe('invoke()', () => { it('should invoke HelloService:1.0 with text success', async () => { - const state = await client.invoker.invoke('HelloService:1.0', '/hello', undefined, 'hello runtime with js-sdk'); + const state = await client.invoker.invoke({ + id: 'HelloService:1.0', + method: '/hello', + data: 'hello runtime with js-sdk', + }); assert.equal(state, null); }); it('should invoke HelloService:1.0 with json success', async () => { - const state = await client.invoker.invoke('HelloService:1.0', '/hello', HTTPExtensionVerb.POST, { - 'hello runtime': 'I am js-sdk client', + const state = await client.invoker.invoke({ + id: 'HelloService:1.0', + method: '/hello', + httpVerb: RumtimeTypes.HTTPExtension.Verb.POST, + data: { + 'hello runtime': 'I am js-sdk client', + }, }); assert.equal(state, null); }); diff --git a/sdk/js-sdk/test/unit/Lock.test.ts b/sdk/js-sdk/test/unit/Lock.test.ts index a8bdd7ecc7..9689c37893 100644 --- a/sdk/js-sdk/test/unit/Lock.test.ts +++ b/sdk/js-sdk/test/unit/Lock.test.ts @@ -13,9 +13,7 @@ * limitations under the License. */ import { strict as assert } from 'assert'; -import { Client } from '../../src'; -import { UnlockResponseStatus } from '../../src/types/Lock'; -import { sleep } from '../../src/utils'; +import { Client, RumtimeTypes, utils } from '../../src'; describe('Lock.test.ts', () => { let client: Client; @@ -28,29 +26,29 @@ describe('Lock.test.ts', () => { it('should unLock not exists resource', async () => { const resourceId = 'js-sdk-lock-not-exists'; const lockOwner = client.lock.uuid(); - const status = await client.lock.unLock(storeName, resourceId, lockOwner); - assert.equal(status, UnlockResponseStatus.LOCK_UNEXIST); + const result = await client.lock.unLock({ storeName, resourceId, lockOwner }); + assert.equal(result.status, RumtimeTypes.UnlockResponse.Status.LOCK_UNEXIST); }); it('should lock 2 seconds work', async () => { const resourceId = 'js-sdk-lock-2-seconds'; const lockOwner = client.lock.uuid(); - const success1 = await client.lock.tryLock(storeName, resourceId, lockOwner, 2); + const success1 = await client.lock.tryLock({ storeName, resourceId, lockOwner, expire: 2 }); assert.equal(success1, true); - const success2 = await client.lock.tryLock(storeName, resourceId, lockOwner, 2); + const success2 = await client.lock.tryLock({ storeName, resourceId, lockOwner, expire: 2 }); assert.equal(success2, false); - await sleep(2500); + await utils.sleep(2500); // wait for lock exipre after 2.5s - const success3 = await client.lock.tryLock(storeName, resourceId, lockOwner, 2); + const success3 = await client.lock.tryLock({ storeName, resourceId, lockOwner, expire: 2 }); assert.equal(success3, true); // unlock by other owner will fail const lockOwner2 = client.lock.uuid(); - const status1 = await client.lock.unLock(storeName, resourceId, lockOwner2); - assert.equal(status1, UnlockResponseStatus.LOCK_BELONG_TO_OTHERS); + const status1 = await client.lock.unLock({ storeName, resourceId, lockOwner: lockOwner2 }); + assert.equal(status1.status, RumtimeTypes.UnlockResponse.Status.LOCK_BELONG_TO_OTHERS); // unlock success by owner - const status2 = await client.lock.unLock(storeName, resourceId, lockOwner); - assert.equal(status2, UnlockResponseStatus.SUCCESS); + const status2 = await client.lock.unLock({ storeName, resourceId, lockOwner }); + assert.equal(status2.status, RumtimeTypes.UnlockResponse.Status.SUCCESS); }); }); diff --git a/sdk/js-sdk/test/unit/Sequencer.test.ts b/sdk/js-sdk/test/unit/Sequencer.test.ts index 7a55c5e019..90780befca 100644 --- a/sdk/js-sdk/test/unit/Sequencer.test.ts +++ b/sdk/js-sdk/test/unit/Sequencer.test.ts @@ -13,8 +13,7 @@ * limitations under the License. */ import { strict as assert } from 'assert'; -import { Client } from '../../src'; -// import { SequencerOptionsAutoIncrement } from '../../src/types/Sequencer'; +import { Client, RumtimeTypes } from '../../src'; describe('Sequencer.test.ts', () => { let client: Client; @@ -30,7 +29,30 @@ describe('Sequencer.test.ts', () => { const ids: string[] = []; for (let i = 0; i < 20; i++) { lastId = currentId; - currentId = await client.sequencer.getNextId(storeName, 'user_info'); + currentId = await client.sequencer.getNextId({ + storeName, + key: 'user_info', + }); + assert(BigInt(currentId) > BigInt(lastId)); + ids.push(currentId); + } + assert.equal(ids.length, 20); + console.log('ids: %j', ids); + }); + + it('should get next id with options increment:WEAK success', async () => { + let lastId = '0'; + let currentId = '0'; + const ids: string[] = []; + for (let i = 0; i < 20; i++) { + lastId = currentId; + currentId = await client.sequencer.getNextId({ + storeName, + key: 'user_info', + options: { + increment: RumtimeTypes.SequencerOptions.AutoIncrement.WEAK, + }, + }); assert(BigInt(currentId) > BigInt(lastId)); ids.push(currentId); } diff --git a/sdk/js-sdk/test/unit/State.test.ts b/sdk/js-sdk/test/unit/State.test.ts index 7e24112d51..67cfa0ab46 100644 --- a/sdk/js-sdk/test/unit/State.test.ts +++ b/sdk/js-sdk/test/unit/State.test.ts @@ -27,14 +27,20 @@ describe('State.test.ts', () => { describe('get(), getBulk()', () => { it('should get not exists key', async () => { const key = 'js-sdk-unit-notexists-' + Date.now(); - const state = await client.state.get(storeName, key); + const state = await client.state.get({ storeName, key }); assert.equal(state, null); }); it('should get empty value', async () => { const key = 'js-sdk-unit-empty-' + Date.now(); - await client.state.save(storeName, { key, value: '' }); - const state = await client.state.get(storeName, key); + await client.state.save({ + storeName, + states: { + key, + value: '', + }, + }); + const state = await client.state.get({ storeName, key }); assert(state); assert.equal(state.value.length, 0); assert.equal(state.key, key); @@ -44,13 +50,20 @@ describe('State.test.ts', () => { it('should save one item and get key success', async () => { const key = 'js-sdk-unit-' + Date.now(); const value = `hello js-sdk, with 中文, 😄, at ${Date()}`; - await client.state.save(storeName, { key, value }, { traceid: `mock-traceid-unittest-${Date.now()}` }); - const state = await client.state.get(storeName, key); + await client.state.save({ + storeName, + states: { key, value }, + requestMeta: { traceid: `mock-traceid-unittest-${Date.now()}` }, + }); + const state = await client.state.get({ storeName, key }); assert(state); assert.equal(Buffer.from(state.value).toString(), value); - await client.state.save(storeName, { key, value }); - const state2 = await client.state.get(storeName, key); + await client.state.save({ + storeName, + states: { key, value }, + }); + const state2 = await client.state.get({ storeName, key }); assert(state2); assert.equal(Buffer.from(state2.value).toString(), value); }); @@ -62,16 +75,19 @@ describe('State.test.ts', () => { const value = `key${i}:hello js-sdk, with 中文, 😄, at ${Date()}`; items.push({ key, value }); } - await client.state.save(storeName, items); + await client.state.save({ + storeName, + states: items, + }); for (const { key, value } of items) { - const state = await client.state.get(storeName, key); + const state = await client.state.get({ storeName, key }); assert(state); assert.equal(Buffer.from(state.value).toString(), value); } const keys = items.map(i => i.key); - const states = await client.state.getBulk(storeName, keys); + const states = await client.state.getBulk({ storeName, keys }); assert.equal(states.length, items.length); for (let i = 0; i < states.length; i++) { const state = states[i]; @@ -81,7 +97,9 @@ describe('State.test.ts', () => { assert.equal(Buffer.from(state.value).toString(), item.value); } - const states2 = await client.state.getBulk(storeName, keys, undefined, { foo: 'bar' }); + const states2 = await client.state.getBulk({ + storeName, keys, requestMeta: { foo: 'bar' }, + }); assert.equal(states2.length, items.length); }); }); @@ -90,15 +108,15 @@ describe('State.test.ts', () => { it('should delete one key success', async () => { const key = 'js-sdk-unit-delete-' + Date.now(); // delete not exists - await client.state.delete(storeName, key); + await client.state.delete({ storeName, key }); const value = `hello js-sdk, with 中文, 😄, at ${Date()}`; - await client.state.save(storeName, { key, value }); + await client.state.save({ storeName, states: { key, value } }); // delete exists - await client.state.delete(storeName, key); + await client.state.delete({ storeName, key }); - const state = await client.state.get(storeName, key); + const state = await client.state.get({ storeName, key }); assert.equal(state, null); }); @@ -112,14 +130,36 @@ describe('State.test.ts', () => { keys.push({ key }); } // delete not exists - await client.state.deleteBulk(storeName, keys); + await client.state.deleteBulk({ storeName, states: keys }); + let states = await client.state.getBulk({ + storeName, + keys: keys.map(i => i.key), + }); + assert.equal(states.length, 0); - await client.state.save(storeName, items); + await client.state.save({ storeName, states: items }); + states = await client.state.getBulk({ + storeName, + keys: keys.map(i => i.key), + }); + assert.equal(states.length, 20); - // delete exists - await client.state.deleteBulk(storeName, keys); + // delete 5 keys + await client.state.deleteBulk({ storeName, states: keys.slice(0, 5) }); + + states = await client.state.getBulk({ + storeName, + keys: keys.map(i => i.key), + }); + assert.equal(states.length, 15); + + // delete all exists + await client.state.deleteBulk({ storeName, states: keys }); - const states = await client.state.getBulk(storeName, keys.map(i => i.key)); + states = await client.state.getBulk({ + storeName, + keys: keys.map(i => i.key), + }); assert.equal(states.length, 0); }); }); @@ -139,7 +179,7 @@ describe('State.test.ts', () => { } // not work now: mosn error // 2021-10-24 14:06:52,590 [ERROR] [mosn.proxy.panic] [grpc] [unary] grpc unary handle panic: interface conversion: interface {} is *state.SetRequest, not state.SetRequest, method: /spec.proto.runtime.v1.Runtime/ExecuteStateTransaction, stack:goroutine 8213 [running]: - await client.state.executeTransaction(storeName, operations); + await client.state.executeTransaction({ storeName, operations }); // const states = await client.state.getBulk(storeName, keys.map(i => i.key)); // assert.equal(states.length, 20); }); From b14831b51f64790409294668ac8ea9aee0766bc4 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sat, 30 Oct 2021 08:47:36 +0800 Subject: [PATCH 08/13] Separate client and server --- sdk/js-sdk/README.md | 2 +- sdk/js-sdk/src/{ => client}/API.ts | 4 +- sdk/js-sdk/src/{ => client}/Client.ts | 56 +++++++++++++------ sdk/js-sdk/src/{ => client}/Configuration.ts | 6 +- sdk/js-sdk/src/{ => client}/Hello.ts | 4 +- sdk/js-sdk/src/{ => client}/Invoker.ts | 4 +- sdk/js-sdk/src/{ => client}/Lock.ts | 4 +- sdk/js-sdk/src/{ => client}/Sequencer.ts | 4 +- sdk/js-sdk/src/{ => client}/State.ts | 6 +- sdk/js-sdk/src/index.ts | 2 +- .../test/unit/{ => client}/Client.test.ts | 3 +- .../unit/{ => client}/Configuration.test.ts | 2 +- .../test/unit/{ => client}/Invoker.test.ts | 4 +- .../test/unit/{ => client}/Lock.test.ts | 2 +- .../test/unit/{ => client}/Sequencer.test.ts | 2 +- .../test/unit/{ => client}/State.test.ts | 4 +- 16 files changed, 66 insertions(+), 43 deletions(-) rename sdk/js-sdk/src/{ => client}/API.ts (89%) rename sdk/js-sdk/src/{ => client}/Client.ts (52%) rename sdk/js-sdk/src/{ => client}/Configuration.ts (97%) rename sdk/js-sdk/src/{ => client}/Hello.ts (93%) rename sdk/js-sdk/src/{ => client}/Invoker.ts (95%) rename sdk/js-sdk/src/{ => client}/Lock.ts (95%) rename sdk/js-sdk/src/{ => client}/Sequencer.ts (94%) rename sdk/js-sdk/src/{ => client}/State.ts (98%) rename sdk/js-sdk/test/unit/{ => client}/Client.test.ts (94%) rename sdk/js-sdk/test/unit/{ => client}/Configuration.test.ts (98%) rename sdk/js-sdk/test/unit/{ => client}/Invoker.test.ts (94%) rename sdk/js-sdk/test/unit/{ => client}/Lock.test.ts (97%) rename sdk/js-sdk/test/unit/{ => client}/Sequencer.test.ts (97%) rename sdk/js-sdk/test/unit/{ => client}/State.test.ts (98%) diff --git a/sdk/js-sdk/README.md b/sdk/js-sdk/README.md index a628ee302e..55cd2416c1 100644 --- a/sdk/js-sdk/README.md +++ b/sdk/js-sdk/README.md @@ -83,7 +83,7 @@ npm run test:unit Enable trace debug log for grpc-js: ```bash -GRPC_TRACE=compression GRPC_VERBOSITY=debug GRPC_TRACE=all npm run test test/unit/Invoker.test.ts +GRPC_TRACE=compression GRPC_VERBOSITY=debug GRPC_TRACE=all npm run test test/unit/client/Invoker.test.ts ``` ## Reference diff --git a/sdk/js-sdk/src/API.ts b/sdk/js-sdk/src/client/API.ts similarity index 89% rename from sdk/js-sdk/src/API.ts rename to sdk/js-sdk/src/client/API.ts index 8392e7b67d..cbefe0d7ad 100644 --- a/sdk/js-sdk/src/API.ts +++ b/sdk/js-sdk/src/client/API.ts @@ -13,8 +13,8 @@ * limitations under the License. */ import { Metadata } from '@grpc/grpc-js'; -import { RuntimeClient } from '../proto/runtime_grpc_pb'; -import { RequestWithMeta } from './types/common'; +import { RuntimeClient } from '../../proto/runtime_grpc_pb'; +import { RequestWithMeta } from '../types/common'; export class API { readonly runtime: RuntimeClient; diff --git a/sdk/js-sdk/src/Client.ts b/sdk/js-sdk/src/client/Client.ts similarity index 52% rename from sdk/js-sdk/src/Client.ts rename to sdk/js-sdk/src/client/Client.ts index 1f7b76097a..bdeabf022b 100644 --- a/sdk/js-sdk/src/Client.ts +++ b/sdk/js-sdk/src/client/Client.ts @@ -14,7 +14,7 @@ */ import { debuglog } from 'node:util'; import { ChannelCredentials } from '@grpc/grpc-js'; -import { RuntimeClient } from '../proto/runtime_grpc_pb'; +import { RuntimeClient } from '../../proto/runtime_grpc_pb'; import State from './State'; import Hello from './Hello'; import Invoker from './Invoker'; @@ -27,26 +27,50 @@ const debug = debuglog('layotto:client'); export default class Client { readonly host: string; readonly port: string; - readonly runtime: RuntimeClient; - readonly hello: Hello; - readonly state: State; - readonly invoker: Invoker; - readonly lock: Lock; - readonly sequencer: Sequencer; - readonly configuration: Configuration; + private _runtime: RuntimeClient; + private _hello: Hello; + private _state: State; + private _invoker: Invoker; + private _lock: Lock; + private _sequencer: Sequencer; + private _configuration: Configuration; constructor(port: string = process.env.runtime_GRPC_PORT || '34904', host: string = process.env.runtime_GRPC_HOST || '127.0.0.1') { this.host = host; this.port = port; const clientCredentials = ChannelCredentials.createInsecure(); - this.runtime = new RuntimeClient(`${this.host}:${this.port}`, clientCredentials); - this.hello = new Hello(this.runtime); - this.state = new State(this.runtime); - this.invoker = new Invoker(this.runtime); - this.lock = new Lock(this.runtime); - this.sequencer = new Sequencer(this.runtime); - this.configuration = new Configuration(this.runtime); - debug('Start connection to %s:%s', this.host, this.port); + this._runtime = new RuntimeClient(`${this.host}:${this.port}`, clientCredentials); + debug('Start connection to %s:%s', this.host, this.port); + } + + get hello() { + if (!this._hello) this._hello = new Hello(this._runtime); + return this._hello; + } + + get state() { + if (!this._state) this._state = new State(this._runtime); + return this._state; + } + + get invoker() { + if (!this._invoker) this._invoker = new Invoker(this._runtime); + return this._invoker; + } + + get lock() { + if (!this._lock) this._lock = new Lock(this._runtime); + return this._lock; + } + + get sequencer() { + if (!this._sequencer) this._sequencer = new Sequencer(this._runtime); + return this._sequencer; + } + + get configuration() { + if (!this._configuration) this._configuration = new Configuration(this._runtime); + return this._configuration; } } diff --git a/sdk/js-sdk/src/Configuration.ts b/sdk/js-sdk/src/client/Configuration.ts similarity index 97% rename from sdk/js-sdk/src/Configuration.ts rename to sdk/js-sdk/src/client/Configuration.ts index 19563cca9e..79cb48eba7 100644 --- a/sdk/js-sdk/src/Configuration.ts +++ b/sdk/js-sdk/src/client/Configuration.ts @@ -21,7 +21,7 @@ import { DeleteConfigurationRequest as DeleteConfigurationRequestPB, SubscribeConfigurationRequest as SubscribeConfigurationRequestPB, SubscribeConfigurationResponse as SubscribeConfigurationResponsePB, -} from '../proto/runtime_pb'; +} from '../../proto/runtime_pb'; import { API } from './API'; import { GetConfigurationRequest, @@ -29,8 +29,8 @@ import { SaveConfigurationRequest, DeleteConfigurationRequest, SubscribeConfigurationRequest, -} from './types/Configuration'; -import { convertArrayToKVString } from './types/common'; +} from '../types/Configuration'; +import { convertArrayToKVString } from '../types/common'; const debug = debuglog('layotto:configuration'); diff --git a/sdk/js-sdk/src/Hello.ts b/sdk/js-sdk/src/client/Hello.ts similarity index 93% rename from sdk/js-sdk/src/Hello.ts rename to sdk/js-sdk/src/client/Hello.ts index 9d793bb1f9..f8f6bd4356 100644 --- a/sdk/js-sdk/src/Hello.ts +++ b/sdk/js-sdk/src/client/Hello.ts @@ -15,9 +15,9 @@ import { SayHelloRequest as SayHelloRequestPB, SayHelloResponse as SayHelloResponsePB, -} from '../proto/runtime_pb'; +} from '../../proto/runtime_pb'; import { API } from './API'; -import { SayHelloRequest } from './types/Hello'; +import { SayHelloRequest } from '../types/Hello'; export default class Hello extends API { async sayHello(request?: SayHelloRequest): Promise { diff --git a/sdk/js-sdk/src/Invoker.ts b/sdk/js-sdk/src/client/Invoker.ts similarity index 95% rename from sdk/js-sdk/src/Invoker.ts rename to sdk/js-sdk/src/client/Invoker.ts index a93344dcf2..c9cbae91b8 100644 --- a/sdk/js-sdk/src/Invoker.ts +++ b/sdk/js-sdk/src/client/Invoker.ts @@ -18,9 +18,9 @@ import { CommonInvokeRequest as CommonInvokeRequestPB, HTTPExtension, InvokeResponse as InvokeResponsePB, -} from '../proto/runtime_pb'; +} from '../../proto/runtime_pb'; import { API } from './API'; -import { InvokeServiceRequest, InvokeResponse } from './types/Invoker'; +import { InvokeServiceRequest, InvokeResponse } from '../types/Invoker'; export default class Invoker extends API { async invoke(request: InvokeServiceRequest): Promise { diff --git a/sdk/js-sdk/src/Lock.ts b/sdk/js-sdk/src/client/Lock.ts similarity index 95% rename from sdk/js-sdk/src/Lock.ts rename to sdk/js-sdk/src/client/Lock.ts index 2b9a6edfef..ca74a55fd9 100644 --- a/sdk/js-sdk/src/Lock.ts +++ b/sdk/js-sdk/src/client/Lock.ts @@ -18,9 +18,9 @@ import { TryLockResponse as TryLockResponsePB, UnlockRequest as UnlockRequestPB, UnlockResponse as UnlockResponsePB, -} from '../proto/runtime_pb'; +} from '../../proto/runtime_pb'; import { API } from './API'; -import { TryLockRequest, UnlockRequest } from './types/Lock'; +import { TryLockRequest, UnlockRequest } from '../types/Lock'; export default class Lock extends API { // A non-blocking method trying to get a lock with ttl diff --git a/sdk/js-sdk/src/Sequencer.ts b/sdk/js-sdk/src/client/Sequencer.ts similarity index 94% rename from sdk/js-sdk/src/Sequencer.ts rename to sdk/js-sdk/src/client/Sequencer.ts index 3ef568d8ee..632a3a77ba 100644 --- a/sdk/js-sdk/src/Sequencer.ts +++ b/sdk/js-sdk/src/client/Sequencer.ts @@ -16,9 +16,9 @@ import { GetNextIdRequest as GetNextIdRequestPB, GetNextIdResponse as GetNextIdResponsePB, SequencerOptions as SequencerOptionsPB, -} from '../proto/runtime_pb'; +} from '../../proto/runtime_pb'; import { API } from './API'; -import { GetNextIdRequest } from './types/Sequencer'; +import { GetNextIdRequest } from '../types/Sequencer'; export default class Sequencer extends API { // Get next unique id with some auto-increment guarantee diff --git a/sdk/js-sdk/src/State.ts b/sdk/js-sdk/src/client/State.ts similarity index 98% rename from sdk/js-sdk/src/State.ts rename to sdk/js-sdk/src/client/State.ts index a80ae9c605..d5286df08b 100644 --- a/sdk/js-sdk/src/State.ts +++ b/sdk/js-sdk/src/client/State.ts @@ -23,7 +23,7 @@ import { DeleteBulkStateRequest as DeleteBulkStateRequestPB, ExecuteStateTransactionRequest as ExecuteStateTransactionRequestPB, TransactionalStateOperation as TransactionalStateOperationPB, -} from '../proto/runtime_pb'; +} from '../../proto/runtime_pb'; import { API } from './API'; import { DeleteBulkStateRequest, @@ -35,8 +35,8 @@ import { ResponseStateItem, SaveStateRequest, StateItem, -} from './types/State'; -import { isEmptyPBMessage } from './utils'; +} from '../types/State'; +import { isEmptyPBMessage } from '../utils'; export default class State extends API { // Saves an array of state objects diff --git a/sdk/js-sdk/src/index.ts b/sdk/js-sdk/src/index.ts index d2b3e1e37b..76f230d74e 100644 --- a/sdk/js-sdk/src/index.ts +++ b/sdk/js-sdk/src/index.ts @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import Client from './Client'; +import Client from './client/Client'; import * as utils from './utils'; import * as RumtimeTypes from '../proto/runtime_pb'; diff --git a/sdk/js-sdk/test/unit/Client.test.ts b/sdk/js-sdk/test/unit/client/Client.test.ts similarity index 94% rename from sdk/js-sdk/test/unit/Client.test.ts rename to sdk/js-sdk/test/unit/client/Client.test.ts index 89cfa59d6b..c2bdd5d823 100644 --- a/sdk/js-sdk/test/unit/Client.test.ts +++ b/sdk/js-sdk/test/unit/client/Client.test.ts @@ -13,7 +13,7 @@ * limitations under the License. */ import { strict as assert } from 'assert'; -import { Client } from '../../src'; +import { Client } from '../../../src'; describe('Client.test.ts', () => { let client: Client; @@ -27,7 +27,6 @@ describe('Client.test.ts', () => { it('should create a Client with default port', () => { assert.equal(client.port, '34904'); - assert(client.runtime); assert(client.state); }); }); diff --git a/sdk/js-sdk/test/unit/Configuration.test.ts b/sdk/js-sdk/test/unit/client/Configuration.test.ts similarity index 98% rename from sdk/js-sdk/test/unit/Configuration.test.ts rename to sdk/js-sdk/test/unit/client/Configuration.test.ts index 7ab0b00931..6a28e23109 100644 --- a/sdk/js-sdk/test/unit/Configuration.test.ts +++ b/sdk/js-sdk/test/unit/client/Configuration.test.ts @@ -13,7 +13,7 @@ * limitations under the License. */ import { strict as assert } from 'assert'; -import { Client, utils } from '../../src'; +import { Client, utils } from '../../../src'; describe('Configuration.test.ts', () => { let client: Client; diff --git a/sdk/js-sdk/test/unit/Invoker.test.ts b/sdk/js-sdk/test/unit/client/Invoker.test.ts similarity index 94% rename from sdk/js-sdk/test/unit/Invoker.test.ts rename to sdk/js-sdk/test/unit/client/Invoker.test.ts index 711cca4cd9..7022cad0e0 100644 --- a/sdk/js-sdk/test/unit/Invoker.test.ts +++ b/sdk/js-sdk/test/unit/client/Invoker.test.ts @@ -13,8 +13,8 @@ * limitations under the License. */ import { strict as assert } from 'assert'; -import { Client } from '../../src'; -import { RumtimeTypes } from '../../src'; +import { Client } from '../../../src'; +import { RumtimeTypes } from '../../../src'; describe.skip('Invoker.test.ts', () => { let client: Client; diff --git a/sdk/js-sdk/test/unit/Lock.test.ts b/sdk/js-sdk/test/unit/client/Lock.test.ts similarity index 97% rename from sdk/js-sdk/test/unit/Lock.test.ts rename to sdk/js-sdk/test/unit/client/Lock.test.ts index 9689c37893..396dcb3625 100644 --- a/sdk/js-sdk/test/unit/Lock.test.ts +++ b/sdk/js-sdk/test/unit/client/Lock.test.ts @@ -13,7 +13,7 @@ * limitations under the License. */ import { strict as assert } from 'assert'; -import { Client, RumtimeTypes, utils } from '../../src'; +import { Client, RumtimeTypes, utils } from '../../../src'; describe('Lock.test.ts', () => { let client: Client; diff --git a/sdk/js-sdk/test/unit/Sequencer.test.ts b/sdk/js-sdk/test/unit/client/Sequencer.test.ts similarity index 97% rename from sdk/js-sdk/test/unit/Sequencer.test.ts rename to sdk/js-sdk/test/unit/client/Sequencer.test.ts index 90780befca..7cabcb087b 100644 --- a/sdk/js-sdk/test/unit/Sequencer.test.ts +++ b/sdk/js-sdk/test/unit/client/Sequencer.test.ts @@ -13,7 +13,7 @@ * limitations under the License. */ import { strict as assert } from 'assert'; -import { Client, RumtimeTypes } from '../../src'; +import { Client, RumtimeTypes } from '../../../src'; describe('Sequencer.test.ts', () => { let client: Client; diff --git a/sdk/js-sdk/test/unit/State.test.ts b/sdk/js-sdk/test/unit/client/State.test.ts similarity index 98% rename from sdk/js-sdk/test/unit/State.test.ts rename to sdk/js-sdk/test/unit/client/State.test.ts index 67cfa0ab46..d135b428db 100644 --- a/sdk/js-sdk/test/unit/State.test.ts +++ b/sdk/js-sdk/test/unit/client/State.test.ts @@ -13,8 +13,8 @@ * limitations under the License. */ import { strict as assert } from 'assert'; -import { Client } from '../../src'; -import { StateOperation, StateOperationType } from '../../src/types/State'; +import { Client } from '../../../src'; +import { StateOperation, StateOperationType } from '../../../src/types/State'; describe('State.test.ts', () => { let client: Client; From 59a0dae21a1221426e131e9d766d90891bb51ac8 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sat, 30 Oct 2021 15:33:23 +0800 Subject: [PATCH 09/13] feat(js-sdk): Impl PubSub API --- configs/config_integration_redis_etcd.json | 8 ++ sdk/js-sdk/demo/pubsub/client.mjs | 17 ++++ sdk/js-sdk/demo/pubsub/client.ts | 31 +++++++ sdk/js-sdk/demo/pubsub/server.ts | 12 +++ sdk/js-sdk/package.json | 2 + sdk/js-sdk/src/client/API.ts | 3 +- sdk/js-sdk/src/client/Client.ts | 9 +- sdk/js-sdk/src/client/Configuration.ts | 2 +- sdk/js-sdk/src/client/Invoker.ts | 22 +++-- sdk/js-sdk/src/client/PubSub.ts | 39 +++++++++ sdk/js-sdk/src/index.ts | 2 + sdk/js-sdk/src/server/GRPCServerImpl.ts | 86 +++++++++++++++++++ sdk/js-sdk/src/server/PubSub.ts | 18 ++++ sdk/js-sdk/src/server/Server.ts | 68 +++++++++++++++ sdk/js-sdk/src/types/PubSub.ts | 10 +++ sdk/js-sdk/test/unit/client/Client.test.ts | 2 +- .../test/unit/client/Configuration.test.ts | 2 +- sdk/js-sdk/test/unit/client/Invoker.test.ts | 2 +- sdk/js-sdk/test/unit/client/PubSub.test.ts | 33 +++++++ sdk/js-sdk/test/unit/client/Sequencer.test.ts | 2 +- sdk/js-sdk/test/unit/client/State.test.ts | 2 +- sdk/js-sdk/test/unit/server/PubSub.test.ts | 51 +++++++++++ sdk/js-sdk/test/unit/server/publishClient.ts | 32 +++++++ sdk/js-sdk/tslint.json | 7 ++ 24 files changed, 448 insertions(+), 14 deletions(-) create mode 100644 sdk/js-sdk/demo/pubsub/client.mjs create mode 100644 sdk/js-sdk/demo/pubsub/client.ts create mode 100644 sdk/js-sdk/demo/pubsub/server.ts create mode 100644 sdk/js-sdk/src/client/PubSub.ts create mode 100644 sdk/js-sdk/src/server/GRPCServerImpl.ts create mode 100644 sdk/js-sdk/src/server/PubSub.ts create mode 100644 sdk/js-sdk/src/server/Server.ts create mode 100644 sdk/js-sdk/src/types/PubSub.ts create mode 100644 sdk/js-sdk/test/unit/client/PubSub.test.ts create mode 100644 sdk/js-sdk/test/unit/server/PubSub.test.ts create mode 100644 sdk/js-sdk/test/unit/server/publishClient.ts create mode 100644 sdk/js-sdk/tslint.json diff --git a/configs/config_integration_redis_etcd.json b/configs/config_integration_redis_etcd.json index bd1f33e8fa..fb174b7890 100644 --- a/configs/config_integration_redis_etcd.json +++ b/configs/config_integration_redis_etcd.json @@ -116,6 +116,14 @@ } } }, + "pub_subs": { + "redis": { + "metadata": { + "redisHost": "localhost:6380", + "redisPassword": "" + } + } + }, "app": { "app_id": "app1", "grpc_callback_port": 9999 diff --git a/sdk/js-sdk/demo/pubsub/client.mjs b/sdk/js-sdk/demo/pubsub/client.mjs new file mode 100644 index 0000000000..c25a942381 --- /dev/null +++ b/sdk/js-sdk/demo/pubsub/client.mjs @@ -0,0 +1,17 @@ +import { strict as assert } from 'assert'; +import { Client } from 'layotto'; + +const client = new Client(); +assert(client); + +async function main() { + const pubsubName = 'redis'; + const topic = 'topic1'; + const value = `bar, from js-sdk, ${Date()}`; + + await client.pubsub.publish({ + pubsubName, topic, data: { value }, + }); +} + +main(); diff --git a/sdk/js-sdk/demo/pubsub/client.ts b/sdk/js-sdk/demo/pubsub/client.ts new file mode 100644 index 0000000000..40904272a1 --- /dev/null +++ b/sdk/js-sdk/demo/pubsub/client.ts @@ -0,0 +1,31 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { strict as assert } from 'assert' +import { Client } from 'layotto'; + +const client = new Client(); +assert(client); + +async function main() { + const pubsubName = 'redis'; + const topic = 'topic1'; + const value = `bar, from js-sdk, ${Date()}`; + + await client.pubsub.publish({ + pubsubName, topic, data: { value }, + }); +} + +main(); diff --git a/sdk/js-sdk/demo/pubsub/server.ts b/sdk/js-sdk/demo/pubsub/server.ts new file mode 100644 index 0000000000..6a95b4e1e3 --- /dev/null +++ b/sdk/js-sdk/demo/pubsub/server.ts @@ -0,0 +1,12 @@ +import { Server } from 'layotto'; + +async function main() { + const server = new Server(); + server.pubsub.subscribe('redis', 'topic1', async (data) => { + console.log('topic1 event data: %j', data); + }); + + await server.start(); +} + +main(); diff --git a/sdk/js-sdk/package.json b/sdk/js-sdk/package.json index c5fa7968e5..207292d8ab 100644 --- a/sdk/js-sdk/package.json +++ b/sdk/js-sdk/package.json @@ -38,6 +38,7 @@ "homepage": "https://github.com/mosn/layotto#readme", "devDependencies": { "@eggjs/tsconfig": "^1.0.0", + "@types/google-protobuf": "^3.15.5", "@types/jest": "^27.0.2", "egg-ci": "^1.19.0", "grpc-tools": "^1.11.2", @@ -46,6 +47,7 @@ "ts-jest": "^27.0.7", "ts-node": "^10.3.0", "tslint": "^6.1.3", + "tslint-config-prettier": "^1.18.0", "typescript": "^4.4.4" }, "dependencies": { diff --git a/sdk/js-sdk/src/client/API.ts b/sdk/js-sdk/src/client/API.ts index cbefe0d7ad..b59803edd7 100644 --- a/sdk/js-sdk/src/client/API.ts +++ b/sdk/js-sdk/src/client/API.ts @@ -24,7 +24,8 @@ export class API { createMetadata(request: RequestWithMeta): Metadata { const metadata = new Metadata(); - for (const key in request.requestMeta) { + if (!request.requestMeta) return metadata; + for (const key of Object.keys(request.requestMeta)) { metadata.add(key, request.requestMeta[key]); } return metadata; diff --git a/sdk/js-sdk/src/client/Client.ts b/sdk/js-sdk/src/client/Client.ts index bdeabf022b..31a78396aa 100644 --- a/sdk/js-sdk/src/client/Client.ts +++ b/sdk/js-sdk/src/client/Client.ts @@ -21,8 +21,9 @@ import Invoker from './Invoker'; import Lock from './Lock'; import Sequencer from './Sequencer'; import Configuration from './Configuration'; +import PubSub from './PubSub'; -const debug = debuglog('layotto:client'); +const debug = debuglog('layotto:client:main'); export default class Client { readonly host: string; @@ -34,6 +35,7 @@ export default class Client { private _lock: Lock; private _sequencer: Sequencer; private _configuration: Configuration; + private _pubsub: PubSub; constructor(port: string = process.env.runtime_GRPC_PORT || '34904', host: string = process.env.runtime_GRPC_HOST || '127.0.0.1') { @@ -73,4 +75,9 @@ export default class Client { if (!this._configuration) this._configuration = new Configuration(this._runtime); return this._configuration; } + + get pubsub() { + if (!this._pubsub) this._pubsub = new PubSub(this._runtime); + return this._pubsub; + } } diff --git a/sdk/js-sdk/src/client/Configuration.ts b/sdk/js-sdk/src/client/Configuration.ts index 79cb48eba7..001fb71e6e 100644 --- a/sdk/js-sdk/src/client/Configuration.ts +++ b/sdk/js-sdk/src/client/Configuration.ts @@ -32,7 +32,7 @@ import { } from '../types/Configuration'; import { convertArrayToKVString } from '../types/common'; -const debug = debuglog('layotto:configuration'); +const debug = debuglog('layotto:client:configuration'); export default class Configuration extends API { // GetConfiguration gets configuration from configuration store. diff --git a/sdk/js-sdk/src/client/Invoker.ts b/sdk/js-sdk/src/client/Invoker.ts index c9cbae91b8..a768d6877d 100644 --- a/sdk/js-sdk/src/client/Invoker.ts +++ b/sdk/js-sdk/src/client/Invoker.ts @@ -52,14 +52,24 @@ export default class Invoker extends API { this.runtime.invokeService(req, this.createMetadata(request), (err, res: InvokeResponsePB) => { if (err) return reject(err); const contentType = res.getContentType().split(';', 1)[0].toLowerCase(); - const content = res.getData() as Buffer; - const response: InvokeResponse = { contentType, content }; + const rawData = res.getData(); + let content; if (contentType === 'application/json') { - response.content = JSON.parse(content.toString()); - } - if (contentType === 'text/plain') { - response.content = content.toString(); + if (rawData) { + content = JSON.parse(Buffer.from(rawData.getValue_asU8()).toString()); + } else { + content = {}; + } + } else if (contentType === 'text/plain') { + if (rawData) { + content = Buffer.from(rawData.getValue_asU8()).toString(); + } else { + content = ''; + } + } else { + content = rawData ? rawData.getValue_asU8() : []; } + const response: InvokeResponse = { contentType, content }; resolve(response); }); }); diff --git a/sdk/js-sdk/src/client/PubSub.ts b/sdk/js-sdk/src/client/PubSub.ts new file mode 100644 index 0000000000..9b48c9c120 --- /dev/null +++ b/sdk/js-sdk/src/client/PubSub.ts @@ -0,0 +1,39 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { + PublishEventRequest as PublishEventRequestPB, +} from '../../proto/runtime_pb'; +import { API } from './API'; +import { PublishEventRequest } from '../types/PubSub'; + +export default class PubSub extends API { + async publish(request: PublishEventRequest): Promise { + const req = new PublishEventRequestPB(); + req.setPubsubName(request.pubsubName); + req.setTopic(request.topic); + // https://mosn.io/layotto/#/zh/design/pubsub/pubsub-api-and-compability-with-dapr-component + // PublishRequest.Data 和 NewMessage.Data 里面放符合 CloudEvent 1.0 规范的 json 数据(能反序列化放进 map[string]interface{}) + req.setData(Buffer.from(JSON.stringify(request.data))); + req.setDataContentType('application/json'); + // FIXME: metadata + + return new Promise((resolve, reject) => { + this.runtime.publishEvent(req, this.createMetadata(request), (err) => { + if (err) return reject(err); + resolve(); + }); + }); + } +} diff --git a/sdk/js-sdk/src/index.ts b/sdk/js-sdk/src/index.ts index 76f230d74e..261769235d 100644 --- a/sdk/js-sdk/src/index.ts +++ b/sdk/js-sdk/src/index.ts @@ -13,11 +13,13 @@ * limitations under the License. */ import Client from './client/Client'; +import Server from './server/Server'; import * as utils from './utils'; import * as RumtimeTypes from '../proto/runtime_pb'; export { Client, + Server, utils, RumtimeTypes, } diff --git a/sdk/js-sdk/src/server/GRPCServerImpl.ts b/sdk/js-sdk/src/server/GRPCServerImpl.ts new file mode 100644 index 0000000000..85280e63e1 --- /dev/null +++ b/sdk/js-sdk/src/server/GRPCServerImpl.ts @@ -0,0 +1,86 @@ +import { debuglog } from 'node:util'; +import * as grpc from '@grpc/grpc-js'; +import { Empty } from 'google-protobuf/google/protobuf/empty_pb'; +import { IAppCallbackServer } from '../../proto/appcallback_grpc_pb'; +import { + ListTopicSubscriptionsResponse, + TopicSubscription, + TopicEventRequest, + TopicEventResponse, +} from '../../proto/appcallback_pb'; +import { PubSubCallback } from '../types/PubSub'; + +const debug = debuglog('layotto:server:grpc'); + +// @ts-ignore +export default class GRPCServerImpl implements IAppCallbackServer { + private readonly _handlersTopics: { [key: string]: PubSubCallback }; + constructor() { + this._handlersTopics = {}; + } + + private createPubSubHandlerKey(pubsubName: string, topic: string): string { + return `${pubsubName}|${topic}`.toLowerCase(); + } + + registerPubSubSubscriptionHandler(pubsubName: string, topic: string, callback: PubSubCallback): void { + const handlerKey = this.createPubSubHandlerKey(pubsubName, topic); + if (this._handlersTopics[handlerKey]) { + throw new Error(`Topic: "${handlerKey}" handler was exists`); + } + this._handlersTopics[handlerKey] = callback; + debug('PubSub Event from topic: "%s" is registered', handlerKey); + } + + async onTopicEvent(call: grpc.ServerUnaryCall, + callback: grpc.sendUnaryData): Promise { + const req = call.request; + const res = new TopicEventResponse(); + const handlerKey = this.createPubSubHandlerKey(req.getPubsubName(), req.getTopic()); + + const handler = this._handlersTopics[handlerKey]; + if (!handler) { + debug('PubSub Event from topic: "%s" was not handled, drop now', handlerKey); + // FIXME: should retry? + res.setStatus(TopicEventResponse.TopicEventResponseStatus.DROP); + return callback(null, res); + } + + // https://mosn.io/layotto/#/zh/design/pubsub/pubsub-api-and-compability-with-dapr-component + // PublishRequest.Data 和 NewMessage.Data 里面放符合 CloudEvent 1.0 规范的 json 数据(能反序列化放进 map[string]interface{}) + const rawData = Buffer.from(req.getData_asU8()).toString(); + debug('PubSub Event from topic: "%s" raw data: %j, typeof %s', handlerKey, rawData, typeof rawData); + let data; + try { + data = JSON.parse(rawData); + } catch { + data = rawData; + } + + try { + await handler(data); + res.setStatus(TopicEventResponse.TopicEventResponseStatus.SUCCESS); + } catch (e) { + // FIXME: should retry? + debug('PubSub Event from topic: "%s" handler throw error: %s, drop now', handlerKey, e); + res.setStatus(TopicEventResponse.TopicEventResponseStatus.DROP); + } + + callback(null, res); + } + + async listTopicSubscriptions(_call: grpc.ServerUnaryCall, + callback: grpc.sendUnaryData): Promise { + const res = new ListTopicSubscriptionsResponse(); + const subscriptionsList = Object.keys(this._handlersTopics).map(key => { + const splits = key.split('|'); + const sub = new TopicSubscription(); + sub.setPubsubName(splits[0]); + sub.setTopic(splits[1]); + return sub; + }); + debug('listTopicSubscriptions call: %j', subscriptionsList); + res.setSubscriptionsList(subscriptionsList); + callback(null, res); + } +} diff --git a/sdk/js-sdk/src/server/PubSub.ts b/sdk/js-sdk/src/server/PubSub.ts new file mode 100644 index 0000000000..33d96f7377 --- /dev/null +++ b/sdk/js-sdk/src/server/PubSub.ts @@ -0,0 +1,18 @@ +import { debuglog } from 'node:util'; +import { PubSubCallback } from '../types/PubSub'; +import GRPCServerImpl from './GRPCServerImpl'; + +const debug = debuglog('layotto:server:pubsub'); + +export default class PubSub { + readonly server: GRPCServerImpl; + + constructor(server: GRPCServerImpl) { + this.server = server; + } + + async subscribe(pubsubName: string, topic: string, cb: PubSubCallback): Promise { + debug('Registering onTopicEvent Handler: PubSub = %s, Topic = %s', pubsubName, topic); + this.server.registerPubSubSubscriptionHandler(pubsubName, topic, cb); + } +} diff --git a/sdk/js-sdk/src/server/Server.ts b/sdk/js-sdk/src/server/Server.ts new file mode 100644 index 0000000000..edc9ca230b --- /dev/null +++ b/sdk/js-sdk/src/server/Server.ts @@ -0,0 +1,68 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { debuglog } from 'node:util'; +import { ServerCredentials, Server as GRPCServer } from '@grpc/grpc-js'; +import { AppCallbackService } from '../../proto/appcallback_grpc_pb'; +import GRPCServerImpl from './GRPCServerImpl'; +import PubSub from './PubSub'; +import { sleep } from '../utils'; + +const debug = debuglog('layotto:server:main'); + +export default class Server { + readonly port: string; + readonly pubsub: PubSub; + private readonly _serverImpl: GRPCServerImpl; + private readonly _server: GRPCServer; + + constructor(port: string = process.env.appcallback_GRPC_PORT || '9999') { + this.port = port; + this._serverImpl = new GRPCServerImpl(); + this.pubsub = new PubSub(this._serverImpl); + + this._server = new GRPCServer(); + // @ts-ignore + this._server.addService(AppCallbackService, this._serverImpl); + debug('AppCallbackService start and listen on port:%s', this.port); + } + + async start(): Promise { + await this._bind(); + this._server.start(); + await sleep(250); + } + + async close(): Promise { + return new Promise((resolve, reject) => { + this._server.tryShutdown((err) => { + if (err) return reject(err); + debug('Closed Server'); + resolve(); + }); + }); + } + + private async _bind(): Promise { + debug('Starting to listen on 127.0.0.1:%s', this.port); + return new Promise((resolve, reject) => { + const serverCredentials = ServerCredentials.createInsecure(); + this._server.bindAsync(`127.0.0.1:${this.port}`, serverCredentials, (err, port) => { + if (err) return reject(err); + debug('Listening on 127.0.0.1:%s', port); + resolve(); + }); + }) + } +} diff --git a/sdk/js-sdk/src/types/PubSub.ts b/sdk/js-sdk/src/types/PubSub.ts new file mode 100644 index 0000000000..8029db10ce --- /dev/null +++ b/sdk/js-sdk/src/types/PubSub.ts @@ -0,0 +1,10 @@ +import { RequestWithMeta, KVString } from './common'; + +export type PubSubCallback = (data: any) => Promise; + +export type PublishEventRequest = { + pubsubName: string; + topic: string; + data: object; + metadata?: KVString; +} & RequestWithMeta; diff --git a/sdk/js-sdk/test/unit/client/Client.test.ts b/sdk/js-sdk/test/unit/client/Client.test.ts index c2bdd5d823..e0de6baa46 100644 --- a/sdk/js-sdk/test/unit/client/Client.test.ts +++ b/sdk/js-sdk/test/unit/client/Client.test.ts @@ -15,7 +15,7 @@ import { strict as assert } from 'assert'; import { Client } from '../../../src'; -describe('Client.test.ts', () => { +describe('client/Client.test.ts', () => { let client: Client; beforeAll(async () => { client = new Client(); diff --git a/sdk/js-sdk/test/unit/client/Configuration.test.ts b/sdk/js-sdk/test/unit/client/Configuration.test.ts index 6a28e23109..dd24e4a912 100644 --- a/sdk/js-sdk/test/unit/client/Configuration.test.ts +++ b/sdk/js-sdk/test/unit/client/Configuration.test.ts @@ -15,7 +15,7 @@ import { strict as assert } from 'assert'; import { Client, utils } from '../../../src'; -describe('Configuration.test.ts', () => { +describe('client/Configuration.test.ts', () => { let client: Client; const storeName = 'etcd'; const appId = 'js-sdk-unittest'; diff --git a/sdk/js-sdk/test/unit/client/Invoker.test.ts b/sdk/js-sdk/test/unit/client/Invoker.test.ts index 7022cad0e0..bc9d6d296b 100644 --- a/sdk/js-sdk/test/unit/client/Invoker.test.ts +++ b/sdk/js-sdk/test/unit/client/Invoker.test.ts @@ -16,7 +16,7 @@ import { strict as assert } from 'assert'; import { Client } from '../../../src'; import { RumtimeTypes } from '../../../src'; -describe.skip('Invoker.test.ts', () => { +describe.skip('client/Invoker.test.ts', () => { let client: Client; beforeAll(() => { diff --git a/sdk/js-sdk/test/unit/client/PubSub.test.ts b/sdk/js-sdk/test/unit/client/PubSub.test.ts new file mode 100644 index 0000000000..6047ab2c28 --- /dev/null +++ b/sdk/js-sdk/test/unit/client/PubSub.test.ts @@ -0,0 +1,33 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Client } from '../../../src'; + +describe('client/PubSub.test.ts', () => { + let client: Client; + beforeAll(async () => { + client = new Client(); + await client.hello.sayHello(); + }); + + it('should publish a topic work', async () => { + const pubsubName = 'redis'; + const topic = 'topic1-client-unit'; + const value = `bar, from js-sdk, ${Date()}`; + + await client.pubsub.publish({ + pubsubName, topic, data: { value }, + }); + }); +}); diff --git a/sdk/js-sdk/test/unit/client/Sequencer.test.ts b/sdk/js-sdk/test/unit/client/Sequencer.test.ts index 7cabcb087b..d8942289e0 100644 --- a/sdk/js-sdk/test/unit/client/Sequencer.test.ts +++ b/sdk/js-sdk/test/unit/client/Sequencer.test.ts @@ -15,7 +15,7 @@ import { strict as assert } from 'assert'; import { Client, RumtimeTypes } from '../../../src'; -describe('Sequencer.test.ts', () => { +describe('client/Sequencer.test.ts', () => { let client: Client; const storeName = 'etcd'; diff --git a/sdk/js-sdk/test/unit/client/State.test.ts b/sdk/js-sdk/test/unit/client/State.test.ts index d135b428db..ba9d541ca1 100644 --- a/sdk/js-sdk/test/unit/client/State.test.ts +++ b/sdk/js-sdk/test/unit/client/State.test.ts @@ -16,7 +16,7 @@ import { strict as assert } from 'assert'; import { Client } from '../../../src'; import { StateOperation, StateOperationType } from '../../../src/types/State'; -describe('State.test.ts', () => { +describe('client/State.test.ts', () => { let client: Client; const storeName = 'redis'; diff --git a/sdk/js-sdk/test/unit/server/PubSub.test.ts b/sdk/js-sdk/test/unit/server/PubSub.test.ts new file mode 100644 index 0000000000..1ef43c2ad3 --- /dev/null +++ b/sdk/js-sdk/test/unit/server/PubSub.test.ts @@ -0,0 +1,51 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { strict as assert } from 'assert'; +import { execSync } from 'child_process'; +import { Server, Client, utils } from '../../../src'; + +describe.skip('server/PubSub.test.ts', () => { + let server: Server; + let client: Client; + const topic1 = 'topic1'; + beforeAll(async () => { + client = new Client(); + await client.hello.sayHello(); + server = new Server(); + await server.start(); + }); + + afterAll(async () => { + await server.close(); + }); + + it('should subscribe a topic work', async () => { + let lastData; + server.pubsub.subscribe('redis', topic1, async (data) => { + console.log('topic event data: %j', data); + lastData = data; + }); + + const cmd = `ts-node ${process.cwd()}/test/unit/server/publishClient.ts`; + const buf = execSync(cmd); + console.log(cmd, buf.toString()); + + for (let i = 0; i < 20; i++) { + await utils.sleep(1000); + if (lastData) break; + } + assert(lastData); + }, 20000); +}); diff --git a/sdk/js-sdk/test/unit/server/publishClient.ts b/sdk/js-sdk/test/unit/server/publishClient.ts new file mode 100644 index 0000000000..ca4f45a1d5 --- /dev/null +++ b/sdk/js-sdk/test/unit/server/publishClient.ts @@ -0,0 +1,32 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { strict as assert } from 'assert' +import { Client } from '../../../src'; + +const client = new Client(); +assert(client); + +async function main() { + const pubsubName = 'redis'; + const topic = 'topic1'; + const value = `bar, from js-sdk, ${Date()}`; + + await client.pubsub.publish({ + pubsubName, topic, data: { value }, + }); + console.log('publish event sent: %j', value); +} + +main(); diff --git a/sdk/js-sdk/tslint.json b/sdk/js-sdk/tslint.json new file mode 100644 index 0000000000..5f147fbc66 --- /dev/null +++ b/sdk/js-sdk/tslint.json @@ -0,0 +1,7 @@ +{ + "rules": { + "no-console": false, + "no-shadowed-variable": false + }, + "extends": ["tslint:recommended", "tslint-config-prettier"] +} From 59ae031992f22b46153ba65963b101f47379e2bd Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sat, 30 Oct 2021 16:01:22 +0800 Subject: [PATCH 10/13] Add license-checker script to Makefile https://mosn.io/layotto/#/zh/development/explanation-for-github-workflow?id=how-to-add-license-headers-for-all-files-automatically --- Makefile | 3 +++ sdk/js-sdk/src/server/GRPCServerImpl.ts | 15 +++++++++++++++ sdk/js-sdk/src/server/PubSub.ts | 15 +++++++++++++++ sdk/js-sdk/src/types/Hello.ts | 15 +++++++++++++++ sdk/js-sdk/src/types/PubSub.ts | 15 +++++++++++++++ 5 files changed, 63 insertions(+) diff --git a/Makefile b/Makefile index b7ed07141b..e2487c2761 100644 --- a/Makefile +++ b/Makefile @@ -49,4 +49,7 @@ build-linux-wasm-layotto: docker build --rm -t ${BUILD_IMAGE} build/contrib/builder/image/faas docker run --rm -v $(shell pwd):/go/src/${PROJECT_NAME} -w /go/src/${PROJECT_NAME} ${BUILD_IMAGE} go build -tags wasmer -o layotto /go/src/${PROJECT_NAME}/cmd/layotto +license-checker: + docker run -it --rm -v $(pwd):/github/workspace apache/skywalking-eyes header fix + .PHONY: build diff --git a/sdk/js-sdk/src/server/GRPCServerImpl.ts b/sdk/js-sdk/src/server/GRPCServerImpl.ts index 85280e63e1..a53d2f6eb7 100644 --- a/sdk/js-sdk/src/server/GRPCServerImpl.ts +++ b/sdk/js-sdk/src/server/GRPCServerImpl.ts @@ -1,3 +1,18 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ import { debuglog } from 'node:util'; import * as grpc from '@grpc/grpc-js'; import { Empty } from 'google-protobuf/google/protobuf/empty_pb'; diff --git a/sdk/js-sdk/src/server/PubSub.ts b/sdk/js-sdk/src/server/PubSub.ts index 33d96f7377..238dc8ad0b 100644 --- a/sdk/js-sdk/src/server/PubSub.ts +++ b/sdk/js-sdk/src/server/PubSub.ts @@ -1,3 +1,18 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ import { debuglog } from 'node:util'; import { PubSubCallback } from '../types/PubSub'; import GRPCServerImpl from './GRPCServerImpl'; diff --git a/sdk/js-sdk/src/types/Hello.ts b/sdk/js-sdk/src/types/Hello.ts index dab5f367ae..d4e34826cc 100644 --- a/sdk/js-sdk/src/types/Hello.ts +++ b/sdk/js-sdk/src/types/Hello.ts @@ -1,3 +1,18 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ import { RequestWithMeta } from './common'; export type SayHelloRequest = { diff --git a/sdk/js-sdk/src/types/PubSub.ts b/sdk/js-sdk/src/types/PubSub.ts index 8029db10ce..c40fb7ddf8 100644 --- a/sdk/js-sdk/src/types/PubSub.ts +++ b/sdk/js-sdk/src/types/PubSub.ts @@ -1,3 +1,18 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ import { RequestWithMeta, KVString } from './common'; export type PubSubCallback = (data: any) => Promise; From 2b7b26ad0f086effd58b099857117df5724f13f9 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sun, 31 Oct 2021 21:45:50 +0800 Subject: [PATCH 11/13] feat(js-sdk): Impl File API --- sdk/js-sdk/README.md | 12 +- sdk/js-sdk/src/client/API.ts | 11 +- sdk/js-sdk/src/client/Client.ts | 7 + sdk/js-sdk/src/client/Configuration.ts | 6 +- sdk/js-sdk/src/client/File.ts | 119 +++++++++++++ sdk/js-sdk/src/client/PubSub.ts | 2 +- sdk/js-sdk/src/client/Sequencer.ts | 1 + sdk/js-sdk/src/client/State.ts | 4 + sdk/js-sdk/src/server/GRPCServerImpl.ts | 2 +- sdk/js-sdk/src/types/File.ts | 20 +++ sdk/js-sdk/src/types/Invoker.ts | 2 +- sdk/js-sdk/src/types/Sequencer.ts | 3 +- sdk/js-sdk/src/types/State.ts | 6 +- sdk/js-sdk/src/types/common.ts | 13 ++ sdk/js-sdk/test/unit/client/File.test.ts | 193 +++++++++++++++++++++ sdk/js-sdk/test/unit/client/State.test.ts | 14 ++ sdk/js-sdk/test/unit/server/PubSub.test.ts | 2 +- 17 files changed, 403 insertions(+), 14 deletions(-) create mode 100644 sdk/js-sdk/src/client/File.ts create mode 100644 sdk/js-sdk/src/types/File.ts create mode 100644 sdk/js-sdk/test/unit/client/File.test.ts diff --git a/sdk/js-sdk/README.md b/sdk/js-sdk/README.md index 55cd2416c1..ad12dc78ba 100644 --- a/sdk/js-sdk/README.md +++ b/sdk/js-sdk/README.md @@ -87,10 +87,10 @@ GRPC_TRACE=compression GRPC_VERBOSITY=debug GRPC_TRACE=all npm run test test/uni ``` ## Reference -### Get Start with gRPC on Node.js -See https://grpc.io/docs/languages/node/quickstart/ - -### Go Proxy in China - -See https://learnku.com/go/wikis/38122 +- [Core concepts, architecture and lifecycle](https://grpc.io/docs/what-is-grpc/core-concepts/) +- [Get Start with gRPC on Node.js](https://grpc.io/docs/languages/node/quickstart/) +- [Node.js gRPC Library](https://grpc.github.io/grpc/node/) +- [Understanding Streams in Node.js](https://nodesource.com/blog/understanding-streams-in-nodejs/) +- [Go Proxy in China](https://learnku.com/go/wikis/38122) +- [How to build a bi-directional streaming gRPC service with Node.js and Java](https://medium.com/@Mark.io/bi-directional-streaming-grpc-with-node-js-and-java-7cbe0f1e0693) diff --git a/sdk/js-sdk/src/client/API.ts b/sdk/js-sdk/src/client/API.ts index b59803edd7..ea4b250ee1 100644 --- a/sdk/js-sdk/src/client/API.ts +++ b/sdk/js-sdk/src/client/API.ts @@ -14,7 +14,7 @@ */ import { Metadata } from '@grpc/grpc-js'; import { RuntimeClient } from '../../proto/runtime_grpc_pb'; -import { RequestWithMeta } from '../types/common'; +import { KVString, RequestWithMeta, Map } from '../types/common'; export class API { readonly runtime: RuntimeClient; @@ -30,4 +30,13 @@ export class API { } return metadata; } + + mergeMetadataToMap(map: Map, ...metadatas: (KVString | undefined)[]) { + for (const metadata of metadatas) { + if (!metadata) continue; + for (const key of Object.keys(metadata)) { + map.set(key, metadata[key]); + } + } + } } diff --git a/sdk/js-sdk/src/client/Client.ts b/sdk/js-sdk/src/client/Client.ts index 31a78396aa..c999069bbb 100644 --- a/sdk/js-sdk/src/client/Client.ts +++ b/sdk/js-sdk/src/client/Client.ts @@ -22,6 +22,7 @@ import Lock from './Lock'; import Sequencer from './Sequencer'; import Configuration from './Configuration'; import PubSub from './PubSub'; +import File from './File'; const debug = debuglog('layotto:client:main'); @@ -36,6 +37,7 @@ export default class Client { private _sequencer: Sequencer; private _configuration: Configuration; private _pubsub: PubSub; + private _file: File; constructor(port: string = process.env.runtime_GRPC_PORT || '34904', host: string = process.env.runtime_GRPC_HOST || '127.0.0.1') { @@ -80,4 +82,9 @@ export default class Client { if (!this._pubsub) this._pubsub = new PubSub(this._runtime); return this._pubsub; } + + get file() { + if (!this._file) this._file = new File(this._runtime); + return this._file; + } } diff --git a/sdk/js-sdk/src/client/Configuration.ts b/sdk/js-sdk/src/client/Configuration.ts index 001fb71e6e..ba1373778b 100644 --- a/sdk/js-sdk/src/client/Configuration.ts +++ b/sdk/js-sdk/src/client/Configuration.ts @@ -46,7 +46,8 @@ export default class Configuration extends API { if (request.subscribeUpdate !== undefined) { req.setSubscribeUpdate(request.subscribeUpdate); } - // TODO: support set metadataMap + this.mergeMetadataToMap(req.getMetadataMap(), request.metadata); + return new Promise((resolve, reject) => { this.runtime.getConfiguration(req, this.createMetadata(request), (err, res: GetConfigurationResponsePB) => { if (err) return reject(err); @@ -68,6 +69,7 @@ export default class Configuration extends API { if (item.label) configurationItem.setLabel(item.label); return configurationItem; })); + this.mergeMetadataToMap(req.getMetadataMap(), request.metadata); return new Promise((resolve, reject) => { this.runtime.saveConfiguration(req, this.createMetadata(request), (err) => { @@ -85,6 +87,7 @@ export default class Configuration extends API { req.setKeysList(request.keys); if (request.group) req.setGroup(request.group); if (request.label) req.setLabel(request.label); + this.mergeMetadataToMap(req.getMetadataMap(), request.metadata); return new Promise((resolve, reject) => { this.runtime.deleteConfiguration(req, this.createMetadata(request), (err) => { @@ -102,6 +105,7 @@ export default class Configuration extends API { req.setKeysList(request.keys); if (request.group) req.setGroup(request.group); if (request.label) req.setLabel(request.label); + this.mergeMetadataToMap(req.getMetadataMap(), request.metadata); let lastError: Error; let isCloseOrEnd = false; diff --git a/sdk/js-sdk/src/client/File.ts b/sdk/js-sdk/src/client/File.ts new file mode 100644 index 0000000000..077a593f2a --- /dev/null +++ b/sdk/js-sdk/src/client/File.ts @@ -0,0 +1,119 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { strict as assert } from 'assert'; +import { debuglog } from 'node:util'; +import { Transform, Readable } from 'stream'; +import { pipeline as pipelinePromise } from 'stream/promises'; +import { + GetFileRequest as GetFileRequestPB, + GetFileResponse as GetFileResponsePB, + PutFileRequest as PutFileRequestPB, + ListFileRequest as ListFileRequestPB, + DelFileRequest as DelFileRequestPB, +} from '../../proto/runtime_pb'; +import { API } from './API'; +import { GetFileRequest, ListFileResponse, PutFileRequest } from '../types/File'; + +const debug = debuglog('layotto:client:file'); + +export default class File extends API { + // Get a file stream + async get(request: GetFileRequest): Promise { + const req = new GetFileRequestPB(); + req.setStoreName(request.storeName); + req.setName(request.name); + this.mergeMetadataToMap(req.getMetadataMap(), request.metadata); + + // convert GetFileResponsePB to Uint8Array + const converter = new Transform({ + objectMode: true, + transform(res: GetFileResponsePB, _, done) { + const data = res.getData_asU8(); + done(null, data); + } + }); + const callStream = this.runtime.getFile(req, this.createMetadata(request)); + // Make sure callStream error handle by converter + callStream.on('error', (err) => converter.emit('error', err)); + return callStream.pipe(converter); + } + + async put(request: PutFileRequest): Promise { + assert(request.stream || request.data, 'Parameters "stream" or "data" was required at least one'); + const stream = request.stream || Readable.from(request.data); + + const ac = new AbortController(); + const signal = ac.signal; + const writeStream = this.runtime.putFile(this.createMetadata(request), (err) => { + if (err) { + debug('putFile %j got server error: %s', request, err); + // abort request and throw error + // FIXME: should tell caller the real err reason, not only AbortError + ac.abort(); + } + }); + await pipelinePromise( + stream, + new Transform({ + objectMode: true, + transform: (chunk: Uint8Array, _, done) => { + const req = new PutFileRequestPB(); + req.setStoreName(request.storeName); + req.setName(request.name); + req.setData(chunk); + this.mergeMetadataToMap(req.getMetadataMap(), request.metadata); + done(null, req); + } + }), + // @ts-ignore + writeStream, + { signal }, + ); + } + + async list(request: GetFileRequest): Promise { + const req = new GetFileRequestPB(); + req.setStoreName(request.storeName); + req.setName(request.name); + this.mergeMetadataToMap(req.getMetadataMap(), { storageType: 'Standard' }, request.metadata); + const listReq = new ListFileRequestPB(); + listReq.setRequest(req); + + return new Promise((resolve, reject) => { + this.runtime.listFile(listReq, this.createMetadata(request), (err, res) => { + if (err) return reject(err); + debug('listFile: %j, res: %j', request, res); + resolve({ + names: res.getFileNameList(), + }); + }); + }); + } + + async delete(request: GetFileRequest): Promise { + const req = new GetFileRequestPB(); + req.setStoreName(request.storeName); + req.setName(request.name); + const delReq = new DelFileRequestPB(); + delReq.setRequest(req); + + return new Promise((resolve, reject) => { + this.runtime.delFile(delReq, this.createMetadata(request), (err) => { + if (err) return reject(err); + resolve(); + }); + }); + } +} diff --git a/sdk/js-sdk/src/client/PubSub.ts b/sdk/js-sdk/src/client/PubSub.ts index 9b48c9c120..658cff0143 100644 --- a/sdk/js-sdk/src/client/PubSub.ts +++ b/sdk/js-sdk/src/client/PubSub.ts @@ -27,7 +27,7 @@ export default class PubSub extends API { // PublishRequest.Data 和 NewMessage.Data 里面放符合 CloudEvent 1.0 规范的 json 数据(能反序列化放进 map[string]interface{}) req.setData(Buffer.from(JSON.stringify(request.data))); req.setDataContentType('application/json'); - // FIXME: metadata + this.mergeMetadataToMap(req.getMetadataMap(), request.metadata); return new Promise((resolve, reject) => { this.runtime.publishEvent(req, this.createMetadata(request), (err) => { diff --git a/sdk/js-sdk/src/client/Sequencer.ts b/sdk/js-sdk/src/client/Sequencer.ts index 632a3a77ba..ac94278852 100644 --- a/sdk/js-sdk/src/client/Sequencer.ts +++ b/sdk/js-sdk/src/client/Sequencer.ts @@ -31,6 +31,7 @@ export default class Sequencer extends API { sequencerOptions.setIncrement(request.options.increment); req.setOptions(sequencerOptions); } + this.mergeMetadataToMap(req.getMetadataMap(), request.metadata); return new Promise((resolve, reject) => { this.runtime.getNextId(req, this.createMetadata(request), (err, res: GetNextIdResponsePB) => { diff --git a/sdk/js-sdk/src/client/State.ts b/sdk/js-sdk/src/client/State.ts index d5286df08b..2412fd503a 100644 --- a/sdk/js-sdk/src/client/State.ts +++ b/sdk/js-sdk/src/client/State.ts @@ -63,6 +63,7 @@ export default class State extends API { const req = new GetStateRequestPB(); req.setStoreName(request.storeName); req.setKey(request.key); + this.mergeMetadataToMap(req.getMetadataMap(), request.metadata); return new Promise((resolve, reject) => { this.runtime.getState(req, this.createMetadata(request), (err, res) => { @@ -85,6 +86,7 @@ export default class State extends API { req.setStoreName(request.storeName); req.setKeysList(request.keys); if (request.parallelism) req.setParallelism(request.parallelism); + this.mergeMetadataToMap(req.getMetadataMap(), request.metadata); return new Promise((resolve, reject) => { this.runtime.getBulkState(req, this.createMetadata(request), (err, res) => { @@ -124,6 +126,7 @@ export default class State extends API { optionsInstance.setConsistency(request.options.consistency); req.setOptions(optionsInstance); } + this.mergeMetadataToMap(req.getMetadataMap(), request.metadata); return new Promise((resolve, reject) => { this.runtime.deleteState(req, this.createMetadata(request), (err) => { @@ -161,6 +164,7 @@ export default class State extends API { operationsList.push(ops); } req.setOperationsList(operationsList); + this.mergeMetadataToMap(req.getMetadataMap(), request.metadata); return new Promise((resolve, reject) => { this.runtime.executeStateTransaction(req, this.createMetadata(request), (err, _res) => { diff --git a/sdk/js-sdk/src/server/GRPCServerImpl.ts b/sdk/js-sdk/src/server/GRPCServerImpl.ts index a53d2f6eb7..ed153f9b3b 100644 --- a/sdk/js-sdk/src/server/GRPCServerImpl.ts +++ b/sdk/js-sdk/src/server/GRPCServerImpl.ts @@ -65,7 +65,7 @@ export default class GRPCServerImpl implements IAppCallbackServer { // PublishRequest.Data 和 NewMessage.Data 里面放符合 CloudEvent 1.0 规范的 json 数据(能反序列化放进 map[string]interface{}) const rawData = Buffer.from(req.getData_asU8()).toString(); debug('PubSub Event from topic: "%s" raw data: %j, typeof %s', handlerKey, rawData, typeof rawData); - let data; + let data: string | object; try { data = JSON.parse(rawData); } catch { diff --git a/sdk/js-sdk/src/types/File.ts b/sdk/js-sdk/src/types/File.ts new file mode 100644 index 0000000000..d751a03085 --- /dev/null +++ b/sdk/js-sdk/src/types/File.ts @@ -0,0 +1,20 @@ +import { Readable } from 'stream'; +import { KVString, RequestWithMeta, RequireOnlyOne } from './common'; + +export type GetFileRequest = { + storeName: string; + name: string; + metadata?: KVString; +} & RequestWithMeta; + +export type PutFileRequest = RequireOnlyOne<{ + storeName: string; + name: string; + stream?: Readable, + data?: Uint8Array, + metadata?: KVString; +}, 'stream' | 'data'> & RequestWithMeta; + +export type ListFileResponse = { + names: string[]; +}; diff --git a/sdk/js-sdk/src/types/Invoker.ts b/sdk/js-sdk/src/types/Invoker.ts index 4163019356..265b5d674b 100644 --- a/sdk/js-sdk/src/types/Invoker.ts +++ b/sdk/js-sdk/src/types/Invoker.ts @@ -24,5 +24,5 @@ export type InvokeServiceRequest = { export type InvokeResponse = { contentType: string; - content: string | Buffer | object; + content: string | Uint8Array | object; }; diff --git a/sdk/js-sdk/src/types/Sequencer.ts b/sdk/js-sdk/src/types/Sequencer.ts index 64bd750e5e..cd06915392 100644 --- a/sdk/js-sdk/src/types/Sequencer.ts +++ b/sdk/js-sdk/src/types/Sequencer.ts @@ -15,7 +15,7 @@ import { SequencerOptions as SequencerOptionsPB, } from '../../proto/runtime_pb'; -import { RequestWithMeta } from './common'; +import { KVString, RequestWithMeta } from './common'; export type SequencerOptions = { increment: SequencerOptionsPB.AutoIncrement; @@ -25,4 +25,5 @@ export type GetNextIdRequest = { storeName: string; key: string; options?: SequencerOptions; + metadata?: KVString; } & RequestWithMeta; diff --git a/sdk/js-sdk/src/types/State.ts b/sdk/js-sdk/src/types/State.ts index 5b09e2ee56..cd1f26d1e8 100644 --- a/sdk/js-sdk/src/types/State.ts +++ b/sdk/js-sdk/src/types/State.ts @@ -15,7 +15,7 @@ import { StateOptions as StateOptionsPB, } from '../../proto/runtime_pb'; -import { RequestWithMeta } from './common'; +import { KVString, RequestWithMeta } from './common'; export type StateOptions = { concurrency: StateOptionsPB.StateConcurrency; @@ -60,12 +60,14 @@ export type SaveStateRequest = { export type GetStateRequest = { storeName: string; key: string; + metadata?: KVString; } & RequestWithMeta; export type GetBulkStateRequest = { storeName: string; keys: string[]; parallelism?: number; + metadata?: KVString; } & RequestWithMeta; export type DeleteStateRequest = { @@ -73,6 +75,7 @@ export type DeleteStateRequest = { key: string; etag?: string; options?: StateOptions + metadata?: KVString; } & RequestWithMeta; export type DeleteBulkStateRequest = { @@ -83,4 +86,5 @@ export type DeleteBulkStateRequest = { export type ExecuteStateTransactionRequest = { storeName: string; operations: StateOperation[]; + metadata?: KVString; } & RequestWithMeta; diff --git a/sdk/js-sdk/src/types/common.ts b/sdk/js-sdk/src/types/common.ts index 5e21a9941e..4392bc60a3 100644 --- a/sdk/js-sdk/src/types/common.ts +++ b/sdk/js-sdk/src/types/common.ts @@ -30,3 +30,16 @@ export function convertArrayToKVString(items: [string, string][]) { } return kv; }; + +export type Map = { + set(k: Type, v: Type): unknown; +}; + +// https://stackoverflow.com/questions/40510611/typescript-interface-require-one-of-two-properties-to-exist/49725198#49725198 +export type RequireOnlyOne = + Pick> + & { + [K in Keys]-?: + Required> + & Partial, undefined>> + }[Keys] diff --git a/sdk/js-sdk/test/unit/client/File.test.ts b/sdk/js-sdk/test/unit/client/File.test.ts new file mode 100644 index 0000000000..89fdae6aca --- /dev/null +++ b/sdk/js-sdk/test/unit/client/File.test.ts @@ -0,0 +1,193 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { strict as assert } from 'assert'; +import { tmpdir } from 'os'; +import { existsSync, createWriteStream, createReadStream } from 'fs'; +import { mkdtemp, rm } from 'fs/promises'; +import { pipeline } from 'stream/promises'; +import { join } from 'path'; +import { Client, utils } from '../../../src'; + +describe('client/File.test.ts', () => { + let client: Client; + let tmpfileDir: string; + const storeName = 'aliOSS'; + // const bucket = 'layotto-js-sdk-local-test'; + + beforeAll(async () => { + client = new Client(); + tmpfileDir = await mkdtemp(join(tmpdir(), 'layotto-js-sdk-file-unittest-tmp-')); + }); + + afterAll(async () => { + // rm -rf + await rm(tmpfileDir, { recursive: true, force: true }); + }); + + describe('get()', () => { + it('should get a file stream success', async () => { + const filepath = join(tmpfileDir, 'getFileStream.jpg'); + console.log(filepath); + assert(!existsSync(filepath)); + + const stream = await client.file.get({ + storeName: 'aliOSS', + name: 'foo/tab3.jpg', + }); + assert(stream); + await pipeline( + stream, + createWriteStream(filepath), + ); + assert(existsSync(filepath)); + }, 30000); + + it('should get a file stream from minio', async () => { + const filepath = join(tmpfileDir, 'minio.jpg'); + console.log(filepath); + assert(!existsSync(filepath)); + + const stream = await client.file.get({ + storeName: 'minio', + name: '1.jpg', + }); + assert(stream); + await pipeline( + stream, + createWriteStream(filepath), + ); + assert(existsSync(filepath)); + }); + + it('should throw error when storeName not exists', async () => { + await assert.rejects( + async () => { + const filepath = join(tmpfileDir, 'storeName-not-exists.jpg'); + const stream = await client.file.get({ + storeName: 'notexists', + name: 'foo.jpg', + }); + await pipeline( + stream, + createWriteStream(filepath), + ); + }, + (err: any) => { + assert.equal(err.code, 3); + assert.equal(err.details, 'not supported store type: notexists'); + return true; + } + ) + }); + }); + + describe('put()', () => { + it('should put a file stream to server success', async () => { + const stream = createReadStream(__filename); + await client.file.put({ + storeName: 'aliOSS', + name: 'layotto_js_sdk_unittest.test.ts', + stream, + }); + }, 10000); + + it('should put bytes data to server success', async () => { + await client.file.put({ + storeName: 'aliOSS', + name: 'layotto_js_sdk_unittest.txt', + data: Buffer.from('哈哈😄,text still work', 'utf8'), + }); + }, 10000); + + it.skip('should work with minio', async () => { + await client.file.put({ + storeName: 'minio', + name: 'layotto_js_sdk_unittest.txt', + data: Buffer.from('哈哈😄,text still work', 'utf8'), + }); + }); + }); + + describe('list()', () => { + it('should list dir success', async () => { + const { names } = await client.file.list({ + storeName, + name: 'layotto-js-sdk-local-test', + }); + console.log(names); + assert(names.length > 0); + }); + + it.skip('should work with minio', async () => { + const { names } = await client.file.list({ + storeName: 'minio', + name: 'layotto-js-sdk-local-test', + }); + console.log(names); + assert(names.length > 0); + }); + }); + + describe('delete()', () => { + it('should put bytes data to server and delete it success', async () => { + const name = `layotto_js_sdk_unittest_need_to_delete_${Date.now()}.txt`; + await client.file.put({ + storeName, + name, + data: Buffer.from('哈哈😄,text still work, delete it now!', 'utf8'), + }); + + await utils.sleep(500); + const filepath = join(tmpfileDir, name); + const stream = await client.file.get({ + storeName, + name, + }); + assert(stream); + await pipeline( + stream, + createWriteStream(filepath), + ); + + // delete it + await client.file.delete({ + storeName, + name, + }); + + // throw error + await assert.rejects( + async () => { + const filepath = join(tmpfileDir, name); + const stream = await client.file.get({ + storeName, + name, + }); + await pipeline( + stream, + createWriteStream(filepath), + ); + }, + (err: any) => { + // console.error(err); + assert.equal(err.code, 13); + assert.match(err.message, /StatusCode=404, ErrorCode=NoSuchKey/); + return true; + } + ); + }, 10000); + }); +}); + diff --git a/sdk/js-sdk/test/unit/client/State.test.ts b/sdk/js-sdk/test/unit/client/State.test.ts index ba9d541ca1..d69c0953c4 100644 --- a/sdk/js-sdk/test/unit/client/State.test.ts +++ b/sdk/js-sdk/test/unit/client/State.test.ts @@ -25,6 +25,20 @@ describe('client/State.test.ts', () => { }); describe('get(), getBulk()', () => { + it('should throw error when storeName not exists', async () => { + await assert.rejects( + async () => { + await client.state.get({ storeName: 'notexists-store', key: 'foo' }); + }, + (err: any) => { + // console.error(err); + assert.equal(err.code, 3); + assert.equal(err.details, 'state store notexists-store is not found'); + return true; + } + ); + }); + it('should get not exists key', async () => { const key = 'js-sdk-unit-notexists-' + Date.now(); const state = await client.state.get({ storeName, key }); diff --git a/sdk/js-sdk/test/unit/server/PubSub.test.ts b/sdk/js-sdk/test/unit/server/PubSub.test.ts index 1ef43c2ad3..e9626d002c 100644 --- a/sdk/js-sdk/test/unit/server/PubSub.test.ts +++ b/sdk/js-sdk/test/unit/server/PubSub.test.ts @@ -16,7 +16,7 @@ import { strict as assert } from 'assert'; import { execSync } from 'child_process'; import { Server, Client, utils } from '../../../src'; -describe.skip('server/PubSub.test.ts', () => { +describe('server/PubSub.test.ts', () => { let server: Server; let client: Client; const topic1 = 'topic1'; From feb482faca250e849ec9b993c49e12e5c7ff02f0 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Wed, 3 Nov 2021 23:26:26 +0800 Subject: [PATCH 12/13] feat(js-sdk): Impl Binding API --- configs/config_integration_redis_etcd.json | 7 +++ sdk/js-sdk/package.json | 1 + sdk/js-sdk/src/client/API.ts | 6 +-- sdk/js-sdk/src/client/Binding.ts | 48 +++++++++++++++++ sdk/js-sdk/src/client/Client.ts | 11 +++- sdk/js-sdk/src/client/File.ts | 4 +- sdk/js-sdk/src/client/Hello.ts | 2 +- sdk/js-sdk/src/client/Invoker.ts | 8 +-- sdk/js-sdk/src/client/State.ts | 8 +-- sdk/js-sdk/src/server/Server.ts | 2 +- sdk/js-sdk/src/types/Binding.ts | 13 +++++ sdk/js-sdk/src/types/Configuration.ts | 34 ++++++------ sdk/js-sdk/src/types/File.ts | 15 +++--- sdk/js-sdk/src/types/Hello.ts | 4 +- sdk/js-sdk/src/types/Invoker.ts | 5 +- sdk/js-sdk/src/types/Lock.ts | 8 +-- sdk/js-sdk/src/types/PubSub.ts | 8 +-- sdk/js-sdk/src/types/Sequencer.ts | 8 +-- sdk/js-sdk/src/types/State.ts | 58 +++++++++++---------- sdk/js-sdk/src/types/common.ts | 25 +++------ sdk/js-sdk/src/utils.ts | 10 ++++ sdk/js-sdk/test/unit/client/Binding.test.ts | 34 ++++++++++++ sdk/js-sdk/test/unit/client/File.test.ts | 11 +++- sdk/js-sdk/test/unit/client/Invoker.test.ts | 17 ++++++ sdk/js-sdk/test/unit/client/State.test.ts | 2 +- 25 files changed, 245 insertions(+), 104 deletions(-) create mode 100644 sdk/js-sdk/src/client/Binding.ts create mode 100644 sdk/js-sdk/src/types/Binding.ts create mode 100644 sdk/js-sdk/test/unit/client/Binding.test.ts diff --git a/configs/config_integration_redis_etcd.json b/configs/config_integration_redis_etcd.json index fb174b7890..75bf6f8211 100644 --- a/configs/config_integration_redis_etcd.json +++ b/configs/config_integration_redis_etcd.json @@ -65,6 +65,13 @@ "hello": "greeting" } }, + "bindings": { + "http": { + "metadata": { + "url": "https://registry.npmmirror.com/layotto/0.0.0" + } + } + }, "config_stores": { "etcd": { "address": [ diff --git a/sdk/js-sdk/package.json b/sdk/js-sdk/package.json index 207292d8ab..a1cefeed8b 100644 --- a/sdk/js-sdk/package.json +++ b/sdk/js-sdk/package.json @@ -48,6 +48,7 @@ "ts-node": "^10.3.0", "tslint": "^6.1.3", "tslint-config-prettier": "^1.18.0", + "type-fest": "^2.5.2", "typescript": "^4.4.4" }, "dependencies": { diff --git a/sdk/js-sdk/src/client/API.ts b/sdk/js-sdk/src/client/API.ts index ea4b250ee1..a4c66723d9 100644 --- a/sdk/js-sdk/src/client/API.ts +++ b/sdk/js-sdk/src/client/API.ts @@ -14,7 +14,7 @@ */ import { Metadata } from '@grpc/grpc-js'; import { RuntimeClient } from '../../proto/runtime_grpc_pb'; -import { KVString, RequestWithMeta, Map } from '../types/common'; +import { KV, RequestWithMeta, Map } from '../types/common'; export class API { readonly runtime: RuntimeClient; @@ -22,7 +22,7 @@ export class API { this.runtime = runtime; } - createMetadata(request: RequestWithMeta): Metadata { + createMetadata(request: RequestWithMeta<{}>): Metadata { const metadata = new Metadata(); if (!request.requestMeta) return metadata; for (const key of Object.keys(request.requestMeta)) { @@ -31,7 +31,7 @@ export class API { return metadata; } - mergeMetadataToMap(map: Map, ...metadatas: (KVString | undefined)[]) { + mergeMetadataToMap(map: Map, ...metadatas: (KV | undefined)[]) { for (const metadata of metadatas) { if (!metadata) continue; for (const key of Object.keys(metadata)) { diff --git a/sdk/js-sdk/src/client/Binding.ts b/sdk/js-sdk/src/client/Binding.ts new file mode 100644 index 0000000000..72f3054a91 --- /dev/null +++ b/sdk/js-sdk/src/client/Binding.ts @@ -0,0 +1,48 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { + InvokeBindingRequest as InvokeBindingRequestPB, + InvokeBindingResponse as InvokeBindingResponsePB, +} from '../../proto/runtime_pb'; +import { API } from './API'; +import { + InvokeBindingRequest, + InvokeBindingResponse, +} from '../types/Binding'; +import { convertMapToKVString } from '../utils'; + +export default class Binding extends API { + async invoke(request: InvokeBindingRequest): Promise { + const req = new InvokeBindingRequestPB(); + req.setName(request.name); + req.setOperation(request.operation); + if (typeof request.data === 'string') { + req.setData(Buffer.from(request.data, 'utf8')); + } else { + req.setData(request.data); + } + this.mergeMetadataToMap(req.getMetadataMap(), request.metadata); + + return new Promise((resolve, reject) => { + this.runtime.invokeBinding(req, this.createMetadata(request), (err, res: InvokeBindingResponsePB) => { + if (err) return reject(err); + resolve({ + data: res.getData_asU8(), + metadata: convertMapToKVString(res.getMetadataMap()), + }); + }); + }); + } +} diff --git a/sdk/js-sdk/src/client/Client.ts b/sdk/js-sdk/src/client/Client.ts index c999069bbb..6a9e9a67a5 100644 --- a/sdk/js-sdk/src/client/Client.ts +++ b/sdk/js-sdk/src/client/Client.ts @@ -23,6 +23,7 @@ import Sequencer from './Sequencer'; import Configuration from './Configuration'; import PubSub from './PubSub'; import File from './File'; +import Binding from './Binding'; const debug = debuglog('layotto:client:main'); @@ -38,9 +39,10 @@ export default class Client { private _configuration: Configuration; private _pubsub: PubSub; private _file: File; + private _binding: Binding; - constructor(port: string = process.env.runtime_GRPC_PORT || '34904', - host: string = process.env.runtime_GRPC_HOST || '127.0.0.1') { + constructor(port: string = process.env.runtime_GRPC_PORT ?? '34904', + host: string = process.env.runtime_GRPC_HOST ?? '127.0.0.1') { this.host = host; this.port = port; const clientCredentials = ChannelCredentials.createInsecure(); @@ -87,4 +89,9 @@ export default class Client { if (!this._file) this._file = new File(this._runtime); return this._file; } + + get binding() { + if (!this._binding) this._binding = new Binding(this._runtime); + return this._binding; + } } diff --git a/sdk/js-sdk/src/client/File.ts b/sdk/js-sdk/src/client/File.ts index 077a593f2a..61f4bc9335 100644 --- a/sdk/js-sdk/src/client/File.ts +++ b/sdk/js-sdk/src/client/File.ts @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { strict as assert } from 'assert'; import { debuglog } from 'node:util'; import { Transform, Readable } from 'stream'; import { pipeline as pipelinePromise } from 'stream/promises'; @@ -51,8 +50,7 @@ export default class File extends API { } async put(request: PutFileRequest): Promise { - assert(request.stream || request.data, 'Parameters "stream" or "data" was required at least one'); - const stream = request.stream || Readable.from(request.data); + const stream = request.stream ?? Readable.from(request.data); const ac = new AbortController(); const signal = ac.signal; diff --git a/sdk/js-sdk/src/client/Hello.ts b/sdk/js-sdk/src/client/Hello.ts index f8f6bd4356..b73faf87c6 100644 --- a/sdk/js-sdk/src/client/Hello.ts +++ b/sdk/js-sdk/src/client/Hello.ts @@ -23,7 +23,7 @@ export default class Hello extends API { async sayHello(request?: SayHelloRequest): Promise { const req = new SayHelloRequestPB(); if (!request) request = {}; - req.setServiceName(request.serviceName || 'helloworld'); + req.setServiceName(request.serviceName ?? 'helloworld'); if (request.name) req.setName(request.name); return new Promise((resolve, reject) => { diff --git a/sdk/js-sdk/src/client/Invoker.ts b/sdk/js-sdk/src/client/Invoker.ts index a768d6877d..298e27884a 100644 --- a/sdk/js-sdk/src/client/Invoker.ts +++ b/sdk/js-sdk/src/client/Invoker.ts @@ -27,7 +27,7 @@ export default class Invoker extends API { const message = new CommonInvokeRequestPB(); message.setMethod(request.method); - const httpVerb = request.httpVerb || HTTPExtension.Verb.GET; + const httpVerb = request.httpVerb ?? HTTPExtension.Verb.GET; const httpExtension = new HTTPExtension(); httpExtension.setVerb(httpVerb); message.setHttpExtension(httpExtension); @@ -35,15 +35,17 @@ export default class Invoker extends API { if (request.data) { const dataSerialized = new Any(); if (typeof request.data === 'string') { - message.setContentType('text/plain; charset=UTF-8'); + message.setContentType(request.contentType ?? 'text/plain; charset=UTF-8'); dataSerialized.setValue(Buffer.from(request.data, 'utf8')); } else { - message.setContentType('application/json'); + message.setContentType(request.contentType ?? 'application/json'); dataSerialized.setValue(Buffer.from(JSON.stringify(request.data), 'utf8')); } message.setData(dataSerialized); } + console.log(message); + const req = new InvokeServiceRequestPB(); req.setId(request.id); req.setMessage(message); diff --git a/sdk/js-sdk/src/client/State.ts b/sdk/js-sdk/src/client/State.ts index 2412fd503a..1f9a1065dc 100644 --- a/sdk/js-sdk/src/client/State.ts +++ b/sdk/js-sdk/src/client/State.ts @@ -18,6 +18,7 @@ import { Etag as EtagPB, StateOptions as StateOptionsPB, GetStateRequest as GetStateRequestPB, + GetStateResponse as GetStateResponsePB, GetBulkStateRequest as GetBulkStateRequestPB, DeleteStateRequest as DeleteStateRequestPB, DeleteBulkStateRequest as DeleteBulkStateRequestPB, @@ -36,7 +37,7 @@ import { SaveStateRequest, StateItem, } from '../types/State'; -import { isEmptyPBMessage } from '../utils'; +import { isEmptyPBMessage, convertMapToKVString } from '../utils'; export default class State extends API { // Saves an array of state objects @@ -66,7 +67,7 @@ export default class State extends API { this.mergeMetadataToMap(req.getMetadataMap(), request.metadata); return new Promise((resolve, reject) => { - this.runtime.getState(req, this.createMetadata(request), (err, res) => { + this.runtime.getState(req, this.createMetadata(request), (err, res: GetStateResponsePB) => { if (err) return reject(err); if (isEmptyPBMessage(res)) { return resolve(null); @@ -75,6 +76,7 @@ export default class State extends API { key: request.key, value: res.getData_asU8(), etag: res.getEtag(), + metadata: convertMapToKVString(res.getMetadataMap()), }); }); }); @@ -102,7 +104,7 @@ export default class State extends API { key: item.getKey(), value: item.getData_asU8(), etag: item.getEtag(), - // metadata: item.getMetadataMap(), + metadata: convertMapToKVString(item.getMetadataMap()), }); } resolve(states); diff --git a/sdk/js-sdk/src/server/Server.ts b/sdk/js-sdk/src/server/Server.ts index edc9ca230b..cb9440385f 100644 --- a/sdk/js-sdk/src/server/Server.ts +++ b/sdk/js-sdk/src/server/Server.ts @@ -27,7 +27,7 @@ export default class Server { private readonly _serverImpl: GRPCServerImpl; private readonly _server: GRPCServer; - constructor(port: string = process.env.appcallback_GRPC_PORT || '9999') { + constructor(port: string = process.env.appcallback_GRPC_PORT ?? '9999') { this.port = port; this._serverImpl = new GRPCServerImpl(); this.pubsub = new PubSub(this._serverImpl); diff --git a/sdk/js-sdk/src/types/Binding.ts b/sdk/js-sdk/src/types/Binding.ts new file mode 100644 index 0000000000..06f2d193ef --- /dev/null +++ b/sdk/js-sdk/src/types/Binding.ts @@ -0,0 +1,13 @@ +import { KV, RequestWithMeta } from './common'; + +export type InvokeBindingRequest = RequestWithMeta<{ + name: string, + data: Uint8Array | string, + metadata: KV + operation: string, +}>; + +export type InvokeBindingResponse = { + data: Uint8Array, + metadata: KV +}; diff --git a/sdk/js-sdk/src/types/Configuration.ts b/sdk/js-sdk/src/types/Configuration.ts index e374da1410..3f18731281 100644 --- a/sdk/js-sdk/src/types/Configuration.ts +++ b/sdk/js-sdk/src/types/Configuration.ts @@ -12,25 +12,25 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { KVString, RequestWithMeta } from './common'; +import { KV, RequestWithMeta } from './common'; -export type GetConfigurationRequest = { +export type GetConfigurationRequest = RequestWithMeta<{ storeName: string; appId: string; keys: string[]; group?: string; label?: string; subscribeUpdate?: boolean; - metadata?: KVString; -} & RequestWithMeta; + metadata?: KV; +}>; export type GetConfigurationItem = { key: string; content: string; group: string; label: string; - tags: KVString; - metadata: KVString; + tags: KV; + metadata: KV; }; export type SaveConfigurationItem = { @@ -38,33 +38,33 @@ export type SaveConfigurationItem = { content: string, group?: string, label?: string, - tags?: KVString, - metadata?: KVString, + tags?: KV, + metadata?: KV, }; -export type SaveConfigurationRequest = { +export type SaveConfigurationRequest = RequestWithMeta<{ storeName: string; appId: string; items: SaveConfigurationItem[]; - metadata?: KVString; -} & RequestWithMeta; + metadata?: KV; +}>; -export type DeleteConfigurationRequest = { +export type DeleteConfigurationRequest = RequestWithMeta<{ storeName: string; appId: string; keys: string[]; group?: string; label?: string; - metadata?: KVString; -} & RequestWithMeta; + metadata?: KV; +}>; -export type SubscribeConfigurationRequest = { +export type SubscribeConfigurationRequest = RequestWithMeta<{ storeName: string; appId: string; keys: string[]; group?: string; label?: string; - metadata?: KVString; + metadata?: KV; onData(items: GetConfigurationItem[]): void; onClose(err?: Error): void; -} & RequestWithMeta; +}>; diff --git a/sdk/js-sdk/src/types/File.ts b/sdk/js-sdk/src/types/File.ts index d751a03085..06890b3a17 100644 --- a/sdk/js-sdk/src/types/File.ts +++ b/sdk/js-sdk/src/types/File.ts @@ -1,19 +1,20 @@ import { Readable } from 'stream'; -import { KVString, RequestWithMeta, RequireOnlyOne } from './common'; +import { RequireExactlyOne } from 'type-fest'; +import { KV, RequestWithMeta } from './common'; -export type GetFileRequest = { +export type GetFileRequest = RequestWithMeta<{ storeName: string; name: string; - metadata?: KVString; -} & RequestWithMeta; + metadata?: KV; +}>; -export type PutFileRequest = RequireOnlyOne<{ +export type PutFileRequest = RequestWithMeta & RequestWithMeta; + metadata?: KV; +}, 'stream' | 'data'>>; export type ListFileResponse = { names: string[]; diff --git a/sdk/js-sdk/src/types/Hello.ts b/sdk/js-sdk/src/types/Hello.ts index d4e34826cc..89a9c0f77f 100644 --- a/sdk/js-sdk/src/types/Hello.ts +++ b/sdk/js-sdk/src/types/Hello.ts @@ -15,7 +15,7 @@ */ import { RequestWithMeta } from './common'; -export type SayHelloRequest = { +export type SayHelloRequest = RequestWithMeta<{ serviceName?: string; name?: string; -} & RequestWithMeta; +}>; diff --git a/sdk/js-sdk/src/types/Invoker.ts b/sdk/js-sdk/src/types/Invoker.ts index 265b5d674b..32cd991dc3 100644 --- a/sdk/js-sdk/src/types/Invoker.ts +++ b/sdk/js-sdk/src/types/Invoker.ts @@ -15,12 +15,13 @@ import { HTTPExtension } from '../../proto/runtime_pb'; import { RequestWithMeta } from './common'; -export type InvokeServiceRequest = { +export type InvokeServiceRequest = RequestWithMeta<{ id: string; method: string; httpVerb?: HTTPExtension.Verb; data?: string | object; -} & RequestWithMeta; + contentType?: string, +}>; export type InvokeResponse = { contentType: string; diff --git a/sdk/js-sdk/src/types/Lock.ts b/sdk/js-sdk/src/types/Lock.ts index 399c970658..ccd2c63636 100644 --- a/sdk/js-sdk/src/types/Lock.ts +++ b/sdk/js-sdk/src/types/Lock.ts @@ -14,15 +14,15 @@ */ import { RequestWithMeta } from './common'; -export type TryLockRequest = { +export type TryLockRequest = RequestWithMeta<{ storeName: string; resourceId: string; lockOwner: string; expire: number; -} & RequestWithMeta; +}>; -export type UnlockRequest = { +export type UnlockRequest = RequestWithMeta<{ storeName: string; resourceId: string; lockOwner: string; -} & RequestWithMeta; +}>; diff --git a/sdk/js-sdk/src/types/PubSub.ts b/sdk/js-sdk/src/types/PubSub.ts index c40fb7ddf8..6e61239a78 100644 --- a/sdk/js-sdk/src/types/PubSub.ts +++ b/sdk/js-sdk/src/types/PubSub.ts @@ -13,13 +13,13 @@ * limitations under the License. * */ -import { RequestWithMeta, KVString } from './common'; +import { RequestWithMeta, KV } from './common'; export type PubSubCallback = (data: any) => Promise; -export type PublishEventRequest = { +export type PublishEventRequest = RequestWithMeta<{ pubsubName: string; topic: string; data: object; - metadata?: KVString; -} & RequestWithMeta; + metadata?: KV; +}>; diff --git a/sdk/js-sdk/src/types/Sequencer.ts b/sdk/js-sdk/src/types/Sequencer.ts index cd06915392..15f76ff246 100644 --- a/sdk/js-sdk/src/types/Sequencer.ts +++ b/sdk/js-sdk/src/types/Sequencer.ts @@ -15,15 +15,15 @@ import { SequencerOptions as SequencerOptionsPB, } from '../../proto/runtime_pb'; -import { KVString, RequestWithMeta } from './common'; +import { KV, RequestWithMeta } from './common'; export type SequencerOptions = { increment: SequencerOptionsPB.AutoIncrement; }; -export type GetNextIdRequest = { +export type GetNextIdRequest = RequestWithMeta<{ storeName: string; key: string; options?: SequencerOptions; - metadata?: KVString; -} & RequestWithMeta; + metadata?: KV; +}>; diff --git a/sdk/js-sdk/src/types/State.ts b/sdk/js-sdk/src/types/State.ts index cd1f26d1e8..474ca4fb01 100644 --- a/sdk/js-sdk/src/types/State.ts +++ b/sdk/js-sdk/src/types/State.ts @@ -12,34 +12,36 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { Except, SetOptional } from 'type-fest'; import { StateOptions as StateOptionsPB, } from '../../proto/runtime_pb'; -import { KVString, RequestWithMeta } from './common'; +import { KV, RequestWithMeta } from './common'; + +export type StateConcurrency = StateOptionsPB.StateConcurrency; +export type StateConsistency = StateOptionsPB.StateConsistency; export type StateOptions = { - concurrency: StateOptionsPB.StateConcurrency; - consistency: StateOptionsPB.StateConsistency; + concurrency: StateConcurrency; + consistency: StateConsistency; }; export type StateItem = { key: string; value: Uint8Array | string; - etag?: string; - options?: StateOptions; + etag: string; + options: StateOptions; } -export type DeleteStateItem = { - key: string; - etag?: string; - options?: StateOptions; -}; +// etag and options is optional on Save State Request +export type SaveStateItem = SetOptional; +export type DeleteStateItem = Except; export type ResponseStateItem = { key: string; value: Uint8Array; etag: string; - // metadata; + metadata: KV; } export enum StateOperationType { @@ -52,39 +54,39 @@ export type StateOperation = { request: StateItem | DeleteStateItem; }; -export type SaveStateRequest = { +export type SaveStateRequest = RequestWithMeta<{ storeName: string; - states: StateItem[] | StateItem; -} & RequestWithMeta; + states: SaveStateItem[] | SaveStateItem; +}>; -export type GetStateRequest = { +export type GetStateRequest = RequestWithMeta<{ storeName: string; key: string; - metadata?: KVString; -} & RequestWithMeta; + metadata?: KV; +}>; -export type GetBulkStateRequest = { +export type GetBulkStateRequest = RequestWithMeta<{ storeName: string; keys: string[]; parallelism?: number; - metadata?: KVString; -} & RequestWithMeta; + metadata?: KV; +}>; -export type DeleteStateRequest = { +export type DeleteStateRequest = RequestWithMeta<{ storeName: string; key: string; etag?: string; options?: StateOptions - metadata?: KVString; -} & RequestWithMeta; + metadata?: KV; +}>; -export type DeleteBulkStateRequest = { +export type DeleteBulkStateRequest = RequestWithMeta<{ storeName: string; states: DeleteStateItem[]; -} & RequestWithMeta; +}>; -export type ExecuteStateTransactionRequest = { +export type ExecuteStateTransactionRequest = RequestWithMeta<{ storeName: string; operations: StateOperation[]; - metadata?: KVString; -} & RequestWithMeta; + metadata?: KV; +}>; diff --git a/sdk/js-sdk/src/types/common.ts b/sdk/js-sdk/src/types/common.ts index 4392bc60a3..13b693c23e 100644 --- a/sdk/js-sdk/src/types/common.ts +++ b/sdk/js-sdk/src/types/common.ts @@ -13,33 +13,24 @@ * limitations under the License. */ +import { Simplify } from 'type-fest'; + export type KV = { [key: string]: Type; }; -export type KVString = KV; +export type RequestWithMeta = Simplify; +}>; -export type RequestWithMeta = { - requestMeta?: KVString; +export type Map = { + set(k: Type, v: Type): unknown; }; export function convertArrayToKVString(items: [string, string][]) { - const kv: KVString = {}; + const kv: KV = {}; for (const item of items) { kv[item[0]] = item[1]; } return kv; }; - -export type Map = { - set(k: Type, v: Type): unknown; -}; - -// https://stackoverflow.com/questions/40510611/typescript-interface-require-one-of-two-properties-to-exist/49725198#49725198 -export type RequireOnlyOne = - Pick> - & { - [K in Keys]-?: - Required> - & Partial, undefined>> - }[Keys] diff --git a/sdk/js-sdk/src/utils.ts b/sdk/js-sdk/src/utils.ts index d6ea591b12..0b48fab5a9 100644 --- a/sdk/js-sdk/src/utils.ts +++ b/sdk/js-sdk/src/utils.ts @@ -13,6 +13,8 @@ * limitations under the License. */ import { setTimeout } from 'timers/promises'; +import { Map as MapPB } from 'google-protobuf'; +import { KV } from './types/common'; export async function sleep(ms: number) { await setTimeout(ms); @@ -45,3 +47,11 @@ export function isEmptyPBMessage(item, emptyLength = 0) { if (item.array.length === emptyLength) return true; return false; } + +export function convertMapToKVString(map: MapPB) { + const kv: KV = {}; + for (const [k, v] of map.entries()) { + kv[k] = v; + } + return kv; +}; diff --git a/sdk/js-sdk/test/unit/client/Binding.test.ts b/sdk/js-sdk/test/unit/client/Binding.test.ts new file mode 100644 index 0000000000..cb695bade9 --- /dev/null +++ b/sdk/js-sdk/test/unit/client/Binding.test.ts @@ -0,0 +1,34 @@ +/* + * Copyright 2021 Layotto Authors + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { strict as assert } from 'assert'; +import { Client } from '../../../src'; + +describe('client/Binding.test.ts', () => { + let client: Client; + beforeAll(async () => { + client = new Client(); + }); + + it('should invoke success', async () => { + const res = await client.binding.invoke({ + name: 'http', + operation: 'get', + data: '😄ok,你好', + metadata: { token: '123' }, + }); + assert.match(Buffer.from(res.data).toString(), /{"name":"layotto",/) + assert.equal(res.metadata.statusCode, '200'); + }); +}); diff --git a/sdk/js-sdk/test/unit/client/File.test.ts b/sdk/js-sdk/test/unit/client/File.test.ts index 89fdae6aca..a1a84ae54b 100644 --- a/sdk/js-sdk/test/unit/client/File.test.ts +++ b/sdk/js-sdk/test/unit/client/File.test.ts @@ -24,7 +24,7 @@ describe('client/File.test.ts', () => { let client: Client; let tmpfileDir: string; const storeName = 'aliOSS'; - // const bucket = 'layotto-js-sdk-local-test'; + const bucket = 'layotto-js-sdk-local-test'; beforeAll(async () => { client = new Client(); @@ -60,8 +60,12 @@ describe('client/File.test.ts', () => { assert(!existsSync(filepath)); const stream = await client.file.get({ - storeName: 'minio', + storeName: 'minioOSS', name: '1.jpg', + metadata: { + bucket, + endpoint: 'http://127.0.0.1:9000', + }, }); assert(stream); await pipeline( @@ -125,6 +129,9 @@ describe('client/File.test.ts', () => { const { names } = await client.file.list({ storeName, name: 'layotto-js-sdk-local-test', + metadata: { + Prefix: 'foo/', + }, }); console.log(names); assert(names.length > 0); diff --git a/sdk/js-sdk/test/unit/client/Invoker.test.ts b/sdk/js-sdk/test/unit/client/Invoker.test.ts index bc9d6d296b..79f9d893c0 100644 --- a/sdk/js-sdk/test/unit/client/Invoker.test.ts +++ b/sdk/js-sdk/test/unit/client/Invoker.test.ts @@ -44,6 +44,23 @@ describe.skip('client/Invoker.test.ts', () => { }); assert.equal(state, null); }); + + it.skip('should invoke rpc success', async () => { + const res = await client.invoker.invoke({ + id: 'com.alipay.rpc.common.service.facade.SampleService:1.0', + method: 'echoStr', + // contentType: 'json', + data: { + signatures: ['java.lang.String'], + arguments: ['abc'], + }, + requestMeta: { + content_type: 'json', + upstream_content_type: 'hessian', + }, + }); + console.log(res); + }); }); }); diff --git a/sdk/js-sdk/test/unit/client/State.test.ts b/sdk/js-sdk/test/unit/client/State.test.ts index d69c0953c4..b5524db598 100644 --- a/sdk/js-sdk/test/unit/client/State.test.ts +++ b/sdk/js-sdk/test/unit/client/State.test.ts @@ -66,7 +66,7 @@ describe('client/State.test.ts', () => { const value = `hello js-sdk, with 中文, 😄, at ${Date()}`; await client.state.save({ storeName, - states: { key, value }, + states: { key, value }, requestMeta: { traceid: `mock-traceid-unittest-${Date.now()}` }, }); const state = await client.state.get({ storeName, key }); From ef81bcfa5c7e948a65ce94c78af605ff365ad0cf Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sun, 7 Nov 2021 19:53:38 +0800 Subject: [PATCH 13/13] test(js-sdk): skip unstable cases --- sdk/js-sdk/test/unit/client/Configuration.test.ts | 7 ++++--- sdk/js-sdk/test/unit/client/File.test.ts | 2 +- sdk/js-sdk/test/unit/client/Sequencer.test.ts | 4 ++-- sdk/js-sdk/test/unit/server/PubSub.test.ts | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/sdk/js-sdk/test/unit/client/Configuration.test.ts b/sdk/js-sdk/test/unit/client/Configuration.test.ts index dd24e4a912..f4f31cc847 100644 --- a/sdk/js-sdk/test/unit/client/Configuration.test.ts +++ b/sdk/js-sdk/test/unit/client/Configuration.test.ts @@ -103,16 +103,17 @@ describe('client/Configuration.test.ts', () => { appId, keys: [key1, key2], onData(items) { - console.log('get items', items); + // console.log('get items', items); for (const item of items) { lastConfig[item.key] = item.content; } }, onClose(err) { - console.log('close, error: %s', err); + assert(!err); + // console.log('close, error: %s', err); }, }); - console.log('call send', call.destroyed); + // console.log('call send', call.destroyed); await utils.sleep(500); await client.configuration.save({ storeName, diff --git a/sdk/js-sdk/test/unit/client/File.test.ts b/sdk/js-sdk/test/unit/client/File.test.ts index a1a84ae54b..472d6e6e65 100644 --- a/sdk/js-sdk/test/unit/client/File.test.ts +++ b/sdk/js-sdk/test/unit/client/File.test.ts @@ -20,7 +20,7 @@ import { pipeline } from 'stream/promises'; import { join } from 'path'; import { Client, utils } from '../../../src'; -describe('client/File.test.ts', () => { +describe.skip('client/File.test.ts', () => { let client: Client; let tmpfileDir: string; const storeName = 'aliOSS'; diff --git a/sdk/js-sdk/test/unit/client/Sequencer.test.ts b/sdk/js-sdk/test/unit/client/Sequencer.test.ts index d8942289e0..273858f1b4 100644 --- a/sdk/js-sdk/test/unit/client/Sequencer.test.ts +++ b/sdk/js-sdk/test/unit/client/Sequencer.test.ts @@ -37,7 +37,7 @@ describe('client/Sequencer.test.ts', () => { ids.push(currentId); } assert.equal(ids.length, 20); - console.log('ids: %j', ids); + // console.log('ids: %j', ids); }); it('should get next id with options increment:WEAK success', async () => { @@ -57,6 +57,6 @@ describe('client/Sequencer.test.ts', () => { ids.push(currentId); } assert.equal(ids.length, 20); - console.log('ids: %j', ids); + // console.log('ids: %j', ids); }); }); diff --git a/sdk/js-sdk/test/unit/server/PubSub.test.ts b/sdk/js-sdk/test/unit/server/PubSub.test.ts index e9626d002c..1ef43c2ad3 100644 --- a/sdk/js-sdk/test/unit/server/PubSub.test.ts +++ b/sdk/js-sdk/test/unit/server/PubSub.test.ts @@ -16,7 +16,7 @@ import { strict as assert } from 'assert'; import { execSync } from 'child_process'; import { Server, Client, utils } from '../../../src'; -describe('server/PubSub.test.ts', () => { +describe.skip('server/PubSub.test.ts', () => { let server: Server; let client: Client; const topic1 = 'topic1';