typescript, go are added

This commit is contained in:
병준 박 2019-05-01 22:23:18 +09:00
parent 9bc12a7a90
commit 747705e28f
11 changed files with 3777 additions and 11 deletions

View File

@ -1,9 +0,0 @@
/target
/classes
/checkouts
pom.xml
pom.xml.asc
*.jar
*.class
/.lein-*
/.nrepl-port

46
.gitignore vendored Normal file
View File

@ -0,0 +1,46 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out
# dependencies
/node_modules
# profiling files
chrome-profiler-events.json
speed-measure-plugin.json
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# System Files
.DS_Store
Thumbs.db

View File

@ -22,5 +22,3 @@ service Networker {
// Sends a greeting
rpc SayHello (NetworkRequest) returns (NetworkReply) {}
}
// protoc -I network/ network/network.proto --go_out=plugins=grpc:network

40
network/network_grpc_pb.d.ts vendored Normal file
View File

@ -0,0 +1,40 @@
// package: oddscrawler
// file: network.proto
/* tslint:disable */
import * as grpc from "grpc";
import * as network_pb from "./network_pb";
interface INetworkerService extends grpc.ServiceDefinition<grpc.UntypedServiceImplementation> {
sayHello: INetworkerService_ISayHello;
}
interface INetworkerService_ISayHello extends grpc.MethodDefinition<network_pb.NetworkRequest, network_pb.NetworkReply> {
path: string; // "/oddscrawler.Networker/SayHello"
requestStream: boolean; // false
responseStream: boolean; // false
requestSerialize: grpc.serialize<network_pb.NetworkRequest>;
requestDeserialize: grpc.deserialize<network_pb.NetworkRequest>;
responseSerialize: grpc.serialize<network_pb.NetworkReply>;
responseDeserialize: grpc.deserialize<network_pb.NetworkReply>;
}
export const NetworkerService: INetworkerService;
export interface INetworkerServer {
sayHello: grpc.handleUnaryCall<network_pb.NetworkRequest, network_pb.NetworkReply>;
}
export interface INetworkerClient {
sayHello(request: network_pb.NetworkRequest, callback: (error: grpc.ServiceError | null, response: network_pb.NetworkReply) => void): grpc.ClientUnaryCall;
sayHello(request: network_pb.NetworkRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: network_pb.NetworkReply) => void): grpc.ClientUnaryCall;
sayHello(request: network_pb.NetworkRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: network_pb.NetworkReply) => void): grpc.ClientUnaryCall;
}
export class NetworkerClient extends grpc.Client implements INetworkerClient {
constructor(address: string, credentials: grpc.ChannelCredentials, options?: object);
public sayHello(request: network_pb.NetworkRequest, callback: (error: grpc.ServiceError | null, response: network_pb.NetworkReply) => void): grpc.ClientUnaryCall;
public sayHello(request: network_pb.NetworkRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: network_pb.NetworkReply) => void): grpc.ClientUnaryCall;
public sayHello(request: network_pb.NetworkRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: network_pb.NetworkReply) => void): grpc.ClientUnaryCall;
}

View File

@ -0,0 +1,45 @@
// GENERATED CODE -- DO NOT EDIT!
'use strict';
var grpc = require('grpc');
var network_pb = require('./network_pb.js');
function serialize_oddscrawler_NetworkReply(arg) {
if (!(arg instanceof network_pb.NetworkReply)) {
throw new Error('Expected argument of type oddscrawler.NetworkReply');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_oddscrawler_NetworkReply(buffer_arg) {
return network_pb.NetworkReply.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_oddscrawler_NetworkRequest(arg) {
if (!(arg instanceof network_pb.NetworkRequest)) {
throw new Error('Expected argument of type oddscrawler.NetworkRequest');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_oddscrawler_NetworkRequest(buffer_arg) {
return network_pb.NetworkRequest.deserializeBinary(new Uint8Array(buffer_arg));
}
var NetworkerService = exports.NetworkerService = {
// Sends a greeting
sayHello: {
path: '/oddscrawler.Networker/SayHello',
requestStream: false,
responseStream: false,
requestType: network_pb.NetworkRequest,
responseType: network_pb.NetworkReply,
requestSerialize: serialize_oddscrawler_NetworkRequest,
requestDeserialize: deserialize_oddscrawler_NetworkRequest,
responseSerialize: serialize_oddscrawler_NetworkReply,
responseDeserialize: deserialize_oddscrawler_NetworkReply,
},
};
exports.NetworkerClient = grpc.makeGenericClientConstructor(NetworkerService);

48
network/network_pb.d.ts vendored Normal file
View File

@ -0,0 +1,48 @@
// package: oddscrawler
// file: network.proto
/* tslint:disable */
import * as jspb from "google-protobuf";
export class NetworkRequest extends jspb.Message {
getName(): string;
setName(value: string): void;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): NetworkRequest.AsObject;
static toObject(includeInstance: boolean, msg: NetworkRequest): NetworkRequest.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: NetworkRequest, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): NetworkRequest;
static deserializeBinaryFromReader(message: NetworkRequest, reader: jspb.BinaryReader): NetworkRequest;
}
export namespace NetworkRequest {
export type AsObject = {
name: string,
}
}
export class NetworkReply extends jspb.Message {
getMessage(): string;
setMessage(value: string): void;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): NetworkReply.AsObject;
static toObject(includeInstance: boolean, msg: NetworkReply): NetworkReply.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: NetworkReply, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): NetworkReply;
static deserializeBinaryFromReader(message: NetworkReply, reader: jspb.BinaryReader): NetworkReply;
}
export namespace NetworkReply {
export type AsObject = {
message: string,
}
}

300
network/network_pb.js Normal file
View File

@ -0,0 +1,300 @@
/**
* @fileoverview
* @enhanceable
* @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!
var jspb = require('google-protobuf');
var goog = jspb;
var global = Function('return this')();
goog.exportSymbol('proto.oddscrawler.NetworkReply', null, global);
goog.exportSymbol('proto.oddscrawler.NetworkRequest', 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.oddscrawler.NetworkRequest = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.oddscrawler.NetworkRequest, jspb.Message);
if (goog.DEBUG && !COMPILED) {
proto.oddscrawler.NetworkRequest.displayName = 'proto.oddscrawler.NetworkRequest';
}
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.oddscrawler.NetworkRequest.prototype.toObject = function(opt_includeInstance) {
return proto.oddscrawler.NetworkRequest.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.oddscrawler.NetworkRequest} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.oddscrawler.NetworkRequest.toObject = function(includeInstance, msg) {
var f, obj = {
name: 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.oddscrawler.NetworkRequest}
*/
proto.oddscrawler.NetworkRequest.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.oddscrawler.NetworkRequest;
return proto.oddscrawler.NetworkRequest.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.oddscrawler.NetworkRequest} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.oddscrawler.NetworkRequest}
*/
proto.oddscrawler.NetworkRequest.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;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.oddscrawler.NetworkRequest.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.oddscrawler.NetworkRequest.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.oddscrawler.NetworkRequest} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.oddscrawler.NetworkRequest.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getName();
if (f.length > 0) {
writer.writeString(
1,
f
);
}
};
/**
* optional string name = 1;
* @return {string}
*/
proto.oddscrawler.NetworkRequest.prototype.getName = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};
/** @param {string} value */
proto.oddscrawler.NetworkRequest.prototype.setName = function(value) {
jspb.Message.setProto3StringField(this, 1, value);
};
/**
* 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.oddscrawler.NetworkReply = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.oddscrawler.NetworkReply, jspb.Message);
if (goog.DEBUG && !COMPILED) {
proto.oddscrawler.NetworkReply.displayName = 'proto.oddscrawler.NetworkReply';
}
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.oddscrawler.NetworkReply.prototype.toObject = function(opt_includeInstance) {
return proto.oddscrawler.NetworkReply.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.oddscrawler.NetworkReply} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.oddscrawler.NetworkReply.toObject = function(includeInstance, msg) {
var f, obj = {
message: 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.oddscrawler.NetworkReply}
*/
proto.oddscrawler.NetworkReply.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.oddscrawler.NetworkReply;
return proto.oddscrawler.NetworkReply.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.oddscrawler.NetworkReply} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.oddscrawler.NetworkReply}
*/
proto.oddscrawler.NetworkReply.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.setMessage(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.oddscrawler.NetworkReply.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.oddscrawler.NetworkReply.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.oddscrawler.NetworkReply} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.oddscrawler.NetworkReply.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getMessage();
if (f.length > 0) {
writer.writeString(
1,
f
);
}
};
/**
* optional string message = 1;
* @return {string}
*/
proto.oddscrawler.NetworkReply.prototype.getMessage = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};
/** @param {string} value */
proto.oddscrawler.NetworkReply.prototype.setMessage = function(value) {
jspb.Message.setProto3StringField(this, 1, value);
};
goog.object.extend(exports, proto.oddscrawler);

3263
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

10
package.json Normal file
View File

@ -0,0 +1,10 @@
{
"name": "odds-crawler-proto",
"version": "0.0.1",
"repository": "https://git.loafle.net/odds_crawler/odds-crawler-proto.git",
"license": "MIT",
"devDependencies": {
"grpc-tools": "^1.7.3",
"grpc_tools_node_protoc_ts": "^2.5.0"
}
}

7
proto_go.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -eu
TARGET_DIR=$1
protoc -I ${TARGET_DIR}/ ${TARGET_DIR}/*.proto --go_out=plugins=grpc:${TARGET_DIR}

18
proto_typescript.sh Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -eu
TARGET_DIR=$1
./node_modules/.bin/grpc_tools_node_protoc \
--js_out=import_style=commonjs,binary:${TARGET_DIR} \
--grpc_out=${TARGET_DIR} \
--plugin=protoc-gen-grpc=./node_modules/.bin/grpc_tools_node_protoc_plugin \
-I ${TARGET_DIR} \
${TARGET_DIR}/*.proto
./node_modules/.bin/grpc_tools_node_protoc \
--plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts \
--ts_out=${TARGET_DIR} \
-I ${TARGET_DIR} \
${TARGET_DIR}/*.proto