proto

package module
v0.0.0-...-57051e5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2020 License: Zlib Imports: 12 Imported by: 0

README

proto-to-serializable-msg

proto file compile simple message struct and MessagePack serializer

概要

protoファイルからメッセージ定義(クラス定義)とMessagePackの静的なシリアライザーを出力します。
C#とJavaScript/TypeScript(NodeJs)とgolangで利用できます。 protocを利用しないためシングルバイナリで動作します。

なにに使うの?

主にゲーム等のリアルタイム通信系でHTTPではなくUDP等を併用するケースで使用する目的で作成しました。
後、protocの吐き出す定義ファイルが少し読みにくいので、シンプルにしたかったのも目的の一つです。
(シリアライザー部分をつけたせいであんまり変わってないかも)

ProtocolBufferでよくない?

はい。ほぼ全てのケースで、そのままProtocolBufferを使う方がいいです。
protoファイルを使うのであれば、gRPCを避ける必要がない気がするのでそのまま使いましょう。

How To Use
# get
go get github.com/yazawa-ichio/proto-to-serializable-msg
# gen message
proto-to-serializable-msg -lang cs -input ./input/proto -output ./out/proto
# use Config
proto-to-serializable-msg -c ./proto-config.yml
Option
Short Long
-l -lang generate language
-i -input input dir or *.proto file
-o -output output dir
-d -dryrun output dryrun
-c -config generate use config.yml
Lang
short long
cs csharp
js javascript
ts typescript
go golang
Config

sample config

input: "../proto"
lang:
  go:
    output: "./out/go/proto"
  csharp:
    output: "./out/cs/proto"
    property: false
    serializable: true
  js:
    output: "./out/ts/proto"
    use_ts: true
    disable_package_to_dir: false

CREDITS

Thanks to the developers of the packages used to create this software.

LICENSE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindProtoFiles

func FindProtoFiles(path string) ([]string, error)

func GenerateAndOutput

func GenerateAndOutput(lang string, files []string, outputRoot string) error

Types

type CSGenerator

type CSGenerator struct {
	SkipSerializer bool
	Property       bool
	Serializable   bool
	// contains filtered or unexported fields
}

func NewCSGenerator

func NewCSGenerator() *CSGenerator

func (*CSGenerator) Generate

func (g *CSGenerator) Generate(files []string) ([]*GenerateFile, error)

func (*CSGenerator) GenerateAndOutput

func (g *CSGenerator) GenerateAndOutput(files []string, outputRoot string) error

type GOGenerator

type GOGenerator struct {
	PackageRoot    string
	SkipSerializer bool
	// contains filtered or unexported fields
}

func NewGoGenerator

func NewGoGenerator() *GOGenerator

func (*GOGenerator) Generate

func (g *GOGenerator) Generate(files []string) ([]*GenerateFile, error)

func (*GOGenerator) GenerateAndOutput

func (g *GOGenerator) GenerateAndOutput(files []string, outputRoot string) error

type GenerateFile

type GenerateFile struct {
	Name    string
	Content string
}

type GenerateTask

type GenerateTask struct {
	Files     []string
	Output    string
	Generator Generator
}

func ParseConfig

func ParseConfig(buf []byte, basePath string) ([]*GenerateTask, error)

func (*GenerateTask) Run

func (g *GenerateTask) Run() error

type Generator

type Generator interface {
	Generate(files []string) ([]*GenerateFile, error)
	GenerateAndOutput(files []string, outputRoot string) error
}

func GetGenerator

func GetGenerator(prm string) (Generator, error)

type JSGenerator

type JSGenerator struct {
	SkipSerializer         bool
	PackageNameToDirectory bool
	// contains filtered or unexported fields
}

func NewJSGenerator

func NewJSGenerator() *JSGenerator

func (*JSGenerator) Generate

func (g *JSGenerator) Generate(files []string) ([]*GenerateFile, error)

func (*JSGenerator) GenerateAndOutput

func (g *JSGenerator) GenerateAndOutput(files []string, outputRoot string) error

type TSGenerator

type TSGenerator struct {
	SkipSerializer         bool
	PackageNameToDirectory bool
	// contains filtered or unexported fields
}

func NewTSGenerator

func NewTSGenerator() *TSGenerator

func (*TSGenerator) Generate

func (g *TSGenerator) Generate(files []string) ([]*GenerateFile, error)

func (*TSGenerator) GenerateAndOutput

func (g *TSGenerator) GenerateAndOutput(files []string, outputRoot string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL