github.com/emcfarlane/larking@v0.0.0-20220605172417-1704b45ee6c3/README.md (about)

     1  # [larking.io](https://larking.io)
     2  
     3  [![Go Reference](https://pkg.go.dev/badge/github.com/emcfarlane/larking.svg)](https://pkg.go.dev/github.com/emcfarlane/larking)
     4  
     5  Reflective gRPC transcoding handler. Get started: [larking.io/docs](https://larking.io/docs)
     6  
     7  - [Transcoding protobuf descriptors REST/HTTP to gRPC](https://cloud.google.com/endpoints/docs/grpc/transcoding)
     8  - [Follows Google API Design principles](https://cloud.google.com/apis/design)
     9  - [Dynamically load descriptors via gRPC server reflection](https://github.com/grpc/grpc/blob/master/doc/server-reflection.md)
    10  
    11  <div align="center">
    12  <img src="docs/larking.svg" />
    13  </div>
    14  
    15  
    16  ## Install
    17  
    18  ```
    19  go get github.com/emcfarlane/larking@latest
    20  ```
    21  
    22  ### Install the REPL
    23  
    24  ```
    25  go install github.com/emcfarlane/larking/cmd/lark@latest
    26  ```
    27  
    28  ### Install the worker
    29  
    30  ```
    31  go install github.com/emcfarlane/larking/cmd/larking@latest
    32  ```
    33  
    34  ## Quickstart
    35  
    36  Compile protobuffers to Go:
    37  ```
    38  protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. apipb/*.proto
    39  ```
    40  
    41  Create a `larking.Mux`:
    42  ```
    43  mux, _ := larking.NewMux()
    44  ```
    45  
    46  Register services:
    47  ```
    48  mux.RegisterService(&apipb.MyService_ServiceDesc, s) // S is your implementation
    49  ```
    50  
    51  Create a server and serve gRPC and REST:
    52  ```
    53  svr, _ := larking.NewServer(mux, larking.InsecureServerOption())
    54  l, _ := net.Listen("tcp", fmt.Sprintf(":%s", *flagPort))
    55  log.Printf("listening on %s", l.Addr().String())
    56  svr.Serve(l)
    57  ```
    58  
    59  ## Debugging
    60  
    61  Checkout [protobuf](https://github.com/golang/protobuf) at the latest v2 relase.
    62  Go install each protoc generation bin.
    63  
    64  Regenerate protoc buffers:
    65  
    66  ```
    67  protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. testpb/test.proto
    68  ```
    69  
    70  ### Protoc
    71  
    72  Must have googleapis protos avaliable.
    73  Just link API to `/usr/local/include/google` so protoc can find it.
    74  ```
    75  ln -s ~/src/github.com/googleapis/googleapis/google/api/ /usr/local/include/google/
    76  ```