Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Evans: more expressive gRPC client

ktr
February 20, 2018

Evans: more expressive gRPC client

ktr

February 20, 2018
Tweet

More Decks by ktr

Other Decks in Programming

Transcript

  1. grpc-ecosystem / polyglot 1 $ echo <json-request> | java -jar

    polyglot.jar \ 2 --command=call \ 3 --endpoint=<host>:<port> \ 4 --full_method=<some.package.Service/doSomething> \ 5 --proto_discovery_root=<path>
  2. εΩʔϚͷϩʔυ 1 func runProtoc(args []string) ([]byte, error) { 2 buf,

    errBuf := new(bytes.Buffer), new(bytes.Buffer) 3 4 // with "--descriptor_set_out=/dev/stdout" 5 cmd := exec.Command("protoc", args...) 6 cmd.Stdout = buf 7 cmd.Stderr = errBuf 8 if err := cmd.Run(); err != nil { 9 if errBuf.Len() != 0 { 10 return nil, errors.New(errBuf.String()) 11 } 12 return nil, err 13 } 14 return buf.Bytes(), nil 15 }
  3. 1 message User { 2 string first_name = 1; 3

    string last_name = 2; 4 Gender gender = 3; 5 } 6 7 message RegisterUsersRequest { 8 repeated User users = 1; 9 } type = "double" | "float" | "int32" | "int64" | "uint32" | "uint64" | "sint32" | "sint64" | "fixed32" | "fixed64" | "sfixed32" | "sfixed64" | "bool" | "string" | "bytes" | messageType | enumType
  4. 1 message User { 2 string first_name = 1; 3

    string last_name = 2; 4 Gender gender = 3; 5 } 6 7 message RegisterUsersRequest { 8 repeated User users = 1; 9 } type = "double" | "float" | "int32" | "int64" | "uint32" | "uint64" | "sint32" | "sint64" | "fixed32" | "fixed64" | "sfixed32" | "sfixed64" | "bool" | "string" | "bytes" | messageType | enumType
  5. type = "double" | "float" | "int32" | "int64" |

    "uint32" | "uint64" | "sint32" | "sint64" | "fixed32" | "fixed64" | "sfixed32" | "sfixed64" | "bool" | "string" | "bytes" | messageType | enumType 1 message User { 2 string first_name = 1; 3 string last_name = 2; 4 Gender gender = 3; 5 } 6 7 message RegisterUsersRequest { 8 repeated User users = 1; 9 }
  6. JOQVUUFS*' 3&1- 1SPNQU*OQVUUFS DCBUBHPQSPNQU $-* +40/JOQVUUFS FODPEJOHKTPO Entity layer Adapter

    layer UseCase layer EFTDSJQUPST KIVNQQSPUPSFqFDU pFMET NFTTBHF  TFSWJDF*'