-
Standardisation
• Good defaults
• Best practices
## HOW
• Code generation
• DTOs Integrated with Protobuf
• Full scaffolding
• Runnable by default
• DAO generated
• Middlewares
• Client Library
## go
./server/config/config.go
./server/handlers/handlers.go
./internal/*
./examples/*
## GK: Protobuf
Here is a Hello World example that is generated by default by our Grab-Kit to let engineers learn things with sample code.
syntax = "proto3";
package playmymusicpb;
import "google/protobuf/empty.proto";
import "google/api/annotations.proto";
import "protocol-gen-swagg
0 码力 |
47 页 |
8.58 MB
| 2 年前 3
-
cases
- Full library definition
- Runtime
- Conditionals
- Editable packages
- Protobuf modules and cross-building
- CPS files location
- Speeding adoption hints
- Conclusions cases
- Full library definition
- Runtime
- Conditionals
- Editable packages
- Protobuf modules and cross-building
- CPS files location
- Speeding adoption hints
- Conclusions cases
- Full library definition
- Runtime
- Conditionals
- Editable packages
- Protobuf modules and cross-building
- CPS files location
- Speeding adoption hints
- Conclusions
0 码力 |
94 页 |
1.58 MB
| 1 年前 3
-
--fuseutil
--fuseutil.go
--mount.go
--mount_darwin.go
--mount_freebsd.go
protobuf
AUTHOR'S
CONTRIBUTORS
LICENSE
Make.protobuf
Makefile
README.md
proto
Makefile
## 流利说 ♥ GopherChina2018
Black $(STATIC_OUTDIR) / , $(MEMENV_SOURCES: .cc=
## google/protobuf grpc/grpc-go
cd $(bazel info execution_root) && bazel-out/host/bin/external/com_google_protobuf/protoc \
--plugin=protoc-gen-go=bazel-out/ xternal/com_github_golang_protobuf/protoc-gen-go/protoc-gen-go \
--go_out=ignore_go_package,Mgoogle/protobuf/any.proto=github.com/golang/protobuf/otypes/any,Mgoogle/protobuf/compiler/plugin.proto=github
0 码力 |
85 页 |
3.46 MB
| 2 年前 3
-
specified. Defaults to 1.
// +optional
Replicas *int32 'json:"replicas,omitempty" protobuf:"varint,1,opt,name=repli
// Label selector for pods. Existing ReplicaSets whose pods are
// "json:" selector "protobuf:" bytes,2,opt,name=s
// Template describes the pods that will be created.
Template v1.PodTemplateSpec 'json:"template" protobuf:"bytes,3,opt,name=temp' it is ready)
// +optional
MinReadySeconds int32 "json:"minReadySeconds,omitempty" protobuf:"variant,5,0
// The number of old ReplicaSets to retain to allow rollback.
// This is a pointer
0 码力 |
31 页 |
6.38 MB
| 2 年前 3
-
google/protobuf
grpc/grpc-go
cd $(bazel info execution_root) && bazel-out/host/bin/external/com_google_protobuf/protoc \
–plugin=protoc-gen-go=bazel-out/host/bin/external/com_github_golang_protobuf/pro –go_out=ignore_go_package,Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any,Mgoogle/protobuf/ compiler/plugin.proto=github.com/golang/protobuf/protoc-gen-go/plugin,Mgoogle/protobuf/
descriptor.proto=github proto=github.com/golang/protobuf/protoc-gen-go/descriptor, Mgoogle/protobuf/duration.proto=github.com/golang/protobuf/ptypes/duration, Mgoogle/protobuf/empty.proto=github.com/golang/protobuf/ptypes/empty, Mg
0 码力 |
86 页 |
4.57 MB
| 1 月前 3
-
RouteSpecifier isXProxy_RouteSpecifier `protobuf_oneof:"route_specifier"`
DownstreamProtocol XProxy_Protocol
UpstreamProtocol XProxy_Protocol
`protobuf:"varint,5,opt,name=downstream_protocol ocol,json=downstreamProtocol,proto3,enum=envoy.config.fil`
`protobuf:"varint,6,opt,name=upstream_protocol,json=upstreamProtocol,proto3,enum=envoy.config.filter.`
// A list of individual HTTP filters are
// processed sequentially as request events happen.
StreamFilters []*StreamFilter `protobuf:"bytes,7,rep,name=stream_filters,json=streamFilters" json:"stream_filters,omitempty"\
0 码力 |
28 页 |
4.73 MB
| 1 年前 3
-
>
third_party/protobuf/src/google/protobuf/descriptor.cc | | 6 | 7.3% | 2.14Mi | 2.6% | 179Ki | third_party/protobuf/src/google/protobuf/ descriptor.pb.cc cc |
| 7 | 4.6% | 1.36Mi | 1.1% | 78.4Ki | third_party/protobuf/src/google/protobuf/text_format.cc |
| 8 | 3.7% | 1.10Mi | 4.5% | 31 3Ki | third_party/protobuf/src/google/protobuf/generated_message_reflection.cc |
| 11 | 3.2% | 965Ki | 0.6% | 40.7Ki | third_party/protobuf/src/google/protobuf/ descriptor_database 0 码力 |
85 页 |
11.66 MB
| 1 年前 3 -
Connections with handshakes can use full description of layout
○ That’s hard enough already without protobuf etc.
☐ Sending over a hash is reasonably size-efficient
## Setting the stage - Why is a type's ## ABI hashing - So what do we have now
- Compatibility of data layout across processes, without protobuf
https://godbolt.org/z/hjxfYb8d9
• Solves 80% of the common set of requirements
Can a python binding for cleaner APIs
We can do “new” syntactic things to avoid redundancy in code
## Sourcegen!
## • Protobuf
(in)famous library loved and hated by everyone at the same time
Lets you do some primitive “reflection-like” 0 码力 |
118 页 |
14.33 MB
| 1 年前 3 -
序列化目前主要考虑以下 2 种,一种是参考 chubaofs 顺序编码,一种是利用 protobuf 直接序列化
## 顺序编码:

利用 protobuf(SerializationString)进行序列化
// curvefs/proto/metaserver 万条随机生成 inode|耗时 (ms)|内存 (KB)|
|---|---|---|
|顺序编码|13|5079|
|protobuf 序列化|81|4996|
从对比结果来看,10 万条 inode 耗时相差不大(CPU 并不是瓶颈),内存 protobuf 消耗却更少,推介使用 protobuf 进行序列化
## 2、 KVStore
将当前实现中的 MemoryDentryStorage 和 MemoryInodeStorage 0 码力 |
12 页 |
384.47 KB
| 1 年前 3 -
提供了较多的扩展接口以及默认扩展实现,使用者也可以根据需要自行定制扩展,具体见下面的框架扩展。
多消息协议
RPC消息协议默认支持 Thrift、Kitex Protobuf、gRPC。Thrift支持Buffered和 Framed二进制协议;Kitex Protobuf是Kitex自定义的Protobuf消息协议,协议格式类似 Thrift;gRPC是对gRPC消息协议的支持,可以与gRPC互通。除此之外,使用者也可以扩展自己的消息协议。 传输协议封装消息协议进行RPC互通,传输协议可以额外透传元信息,用于服务治理, Kitex 支持的传输协议有 TTHeader、HTTP2。TTHeader 可以和 Thrift、Kitex Protobuf 结合使用;HTTP2 目前主要是结合 gRPC 协议使用,后续也会支持 Thrift。
多种消息类型
支持 PingPong、Oneway、双向 Streaming。其中 Oneway 目前只对 支持服务注册/发现、负载均衡、熔断、限流、重试、监控、链路跟踪、日志、诊断等服务治理模块,大部分均已提供默认扩展,使用者可选择集成。
代码生成
Kitex 内置代码生成工具,可支持生成 Thrift、Protobuf 以及脚手架代码。
生成代码结构说明 https://www.cloudwego.io/zh/docs/kitex/tutorials/code-gen/code_generation/#生成代码的结构 0 码力 |
37 页 |
89.14 MB
| 2 月前 3
|