ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
§¤§Ö§ß§ß§Ñ§Õ§Ú§Û §¬§Ñ§â§Ö§Ó
§£§Ö§Ò §â§Ñ§Ù§â§Ñ§Ò§à§ä§é§Ú§Ü
§¬§ä§à §ñ
§£§Ö§Ò §â§Ñ§Ù§â§Ñ§Ò§à§ä§é§Ú§Ü §Ó Mad Devs
¡ñ nambataxi.kg
¡ñ nambafood.kg
1 §Ô§à§Õ §ß§Ñ Golang
3 §Ô§à§Õ§Ñ §ß§Ñ Python
5 §Ý§Ö§ä §ã§Ú§ã. §Ñ§Õ§Þ§Ú§ß§Ú§ã§ä§â§Ú§â§à§Ó§Ñ§ß§Ú§ñ
§®§à§ß§à§Ý§Ú§ä§ß§Ñ§ñ §Ñ§â§ç§Ú§ä§Ö§Ü§ä§å§â§Ñ
getUserInfo()
getDirections()
renderMap()
reports()
§®§Ú§Ü§â§à§ã§Ö§â§Ó§Ú§ã§ß§Ñ§ñ §Ñ§â§ç§Ú§ä§Ö§Ü§ä§å§â§Ñ
getUserInfo()
Server
getDirections()
Server
Stub
renderMap()
Stub
reports()
Server
Stub
§³§Ý§à§Ø§ß§à§ã§ä§Ú
§Ó §Þ§Ú§Ü§â§à§ã§Ö§â§Ó§Ú§ã§ß§à§Û
§Ñ§â§ç§Ú§ä§Ö§Ü§ä§å§â§Ö
¡ñ §Ú §ä.§Õ.
¡ñ §¥§Ö§Ò§Ñ§Ô§Ô§Ú§ß§Ô
¡ñ §®§à§ß§Ú§ä§à§â§Ú§ß§Ô
¡ñ §³§ä§â§Ú§Þ§Ú§ß§Ô §Õ§Ñ§ß§ß§í§ç
¡ñ §£§Ù§Ñ§Ú§Þ§à§Õ§Ö§Û§ã§ä§Ó§Ú§Ö §Þ§Ö§Ø§Õ§å §ñ§Ù§í§Ü§Ñ§Þ§Ú
¡ñ §¢§Ö§Ù§à§á§Ñ§ã§ß§à§ã§ä§î / §¡§å§ä§Ö§ß§ä§Ú§æ§Ú§Ü§Ñ§è§Ú§ñ
¡ñ §³§Ö§â§Ú§Ñ§Ý§Ú§Ù§Ñ§è§Ú§ñ §Õ§Ñ§ß§ß§í§ç
¡ñ §³§Ü§à§â§à§ã§ä§î §à§Ò§ë§Ö§ß§Ú§ñ §á§à §ã§Ö§ä§Ú
gRPC §æ§â§Ö§Û§Þ§Ó§à§â§Ü §à§ä Google §Õ§Ý§ñ §å§Õ§Ñ§Ý§Ö§ß§ß§à§Ô§à §Ó§í§Ù§à§Ó§Ñ §á§â§à§è§Ö§Õ§å§â
§£§Ó§Ö§Õ§Ö§ß§Ú§Ö §Ó gRPC / Introduction to gRPC
Protocol Buffers
Protocol Buffers
IDL (§Á§Ù§í§Ü §à§á§Ú§ã§Ñ§ß§Ú§ñ
§Ú§ß§ä§Ö§â§æ§Ö§Û§ã§à§Ó)
§°§á§Ú§ã§í§Ó§Ñ§Ö§ä §Ú §Ô§Ö§ß§Ö§â§Ú§â§å§Ö§ä
§Ú§ß§ä§Ö§â§æ§Ö§Û§ã§í §Õ§Ý§ñ §â§Ñ§Ù§ß§í§ç
§ñ§Ù§í§Ü§à§Ó §á§â§à§Ô§â§Ñ§Þ§Þ§Ú§â§à§Ó§Ñ§ß§Ú§ñ.
§®§à§Õ§Ö§Ý§î §Õ§Ñ§ß§ß§í§ç
§³§ä§â§å§Ü§ä§å§â§í §Ù§Ñ§á§â§à§ã§à§Ó §Ú
§à§ä§Ó§Ö§ä§à§Ó.
§¢§Ú§ß§Ñ§â§ß§í§Û §æ§à§â§Þ§Ñ§ä
§¥§Ý§ñ §á§Ö§â§Ö§Õ§Ñ§é§Ú §Õ§Ñ§ß§ß§í§ç.
syntax = ¡°proto3¡±;
message Profile {
string name = 1;
int32 id = 2;
string email = 3;
enum PhoneType {
MOBILE = 0;
HOME = 1;
WORK = 2;
}
message PhoneNumber {
string number = 1;
PhoneType type = 2;
}
repeated PhoneNumber phone = 4;
}
§°§á§â§Ö§Õ§Ö§Ý§Ö§ß§Ú§Ö §³§Ö§â§Ó§Ú§ã§à§Ó
service RouteGuide {
rpc GetPlace(Point) returns (Place);
rpc RouteChat(stream RouteNote) returns (stream RouteNote);
}
message Point {
int32 Latitude = 1;
 int32 Longitude = 2;
}
message RouteNote {
Point location = 1;
string message = 2;
}
message Place {
string name = 1;
Point location = 2;
}
Protocol Buffers
HTTP/2
https://http2.golang.org/gophertiles
HTTP/2
HTTP/2HTTP/1.1
HTTP/2
§®§å§Ý§î§ä§Ú§á§Ý§Ö§Ü§ã§Ú§ß§Ô
HTTP/2
HTTP/1.x
HTTP/2
§¥§Ó§å§ß§Ñ§á§â§Ñ§Ó§Ý§Ö§ß§ß§í§Û
§ã§ä§â§Ú§Þ§Ú§ß§Ô
HTTP/2
HTTPS
Protocol Buffers
HTTP/2
§®§ß§à§Ø§Ö§ã§ä§Ó§à §Á§Ù§í§Ü§à§Ó
C/C++
Ruby Service
gRPC server
Go Service
gRPC server
gRPC
Stub
Java Service
gRPC
Stub
Python Service
gRPC server
gRPC
Stub
§±§à§Õ§Õ§Ö§â§Ø§Ü§Ñ §â§Ñ§Ù§ß§í§ç §ñ§Ù§í§Ü§à§Ó
§¬§ä§à §Ú§ã§á§à§Ý§î§Ù§å§Ö§ä gRPC
§µ§ã§ä§Ñ§ß§à§Ó§Ü§Ñ §å§ä§Ú§Ý§Ú§ä
$ brew install protobuf
# §¢§Ú§Ò§Ý§Ú§à§ä§Ö§Ü§Ú protoc-gen
$ go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
Helloworld.proto
syntax = ¡°proto3¡±;
package helloworld;
service Greeter {
rpc SayHello (HelloRequest) return (HelloReply);
}
message HelloRequest {
string name = 1;
}
message HelloReply {
string message = 1;
}
§¤§Ö§ß§Ö§â§Ú§â§å§Ö§Þ §Ü§à§Õ
$ protoc -I pb pb/helloworld.proto --go_out=plugins=grpc:helloworld
Greeter server
func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
return &pb.HelloReply{Message: "Hello " + in.Name}, nil
}
func main() {
lis, _ := net.Listen("tcp", port)
s := grpc.NewServer()
pb.RegisterGreeterServer(s, &server{})
reflection.Register(s)
_ := s.Serve(lis);
}
Greeter Client
func main() {
conn, _ := grpc.Dial(address, grpc.WithInsecure())
defer conn.Close()
c := pb.NewGreeterClient(conn)
name := defaultName
if len(os.Args) > 1 {
name = os.Args[1]
}
r, _ := c.SayHello(context.Background(), &pb.HelloRequest{Name: name})
log.Printf("Greeting: %s", r.Message)
}
§©§Ñ§á§å§ã§Ü
$ greeter_server &
$ greeter_client Gennady
$ 2017/04/14 21:58:44 Greeting: Hello Gennady
§·§à§é§Ö§ê§î §å§Ù§ß§Ñ§ä§î §Ò§à§Ý§î§ê§Ö?
§¥§à§Ü§å§Þ§Ö§ß§ä§Ñ§è§Ú§ñ §Ú §Ü§à§Õ
? http://www.grpc.io
? https://github.com/grpc
? https://github.com/grpc-ecosystem
§±§à§Þ§à§ë§î §Ú §á§à§Õ§Õ§Ö§â§Ø§Ü§Ñ
? https://gitter.im/grpc/grpc
? https://groups.google.com/forum/#!forum/grpc-io
§¬§à§ß§ä§Ñ§Ü§ä§í
¡ñ @maddevsio
¡ñ https://maddevs.io
¡ñ https://blog.maddevs.io

More Related Content

§£§Ó§Ö§Õ§Ö§ß§Ú§Ö §Ó gRPC / Introduction to gRPC