github.com/tickoalcantara12/micro/v3@v3.0.0-20221007104245-9d75b9bcbab9/docs/v2/design/clients/README.md (about)

     1  # Clients
     2  
     3  Micro has mainly focused on the Go programming language via the [Go Micro](https://github.com/micro/go-micro) framework. We're 
     4  now going to move into multi-language via clients built against the Micro itself. This will involve code generating 
     5  via a gRPC api and then building the clients on top. 
     6  
     7  Languages we want to support from day 1 include {go, py, js, rb, java}
     8  
     9  ## API
    10  
    11  The API for each service will live in [github.com/micro/clients](https://github.com/micro/clients). We'll have a proto dir 
    12  which provides a proto per service that micro provides.
    13  
    14  ```
    15  clients/
    16  	proto/
    17  		registry/registry.proto
    18  		broker/broker.proto
    19  		store/store.proto
    20  		client/client.proto
    21  		...
    22  		
    23  ```
    24  
    25  Alternatively can potentially introduce a consolidated API for ease of use like so:
    26  
    27  ```
    28  syntax = "proto3";
    29  
    30  package server;
    31  
    32  service Client {
    33  	rpc Call(Request) returns (Response) {};
    34  	rpc Stream(stream Request) returns (stream Response) {};
    35  	rpc Publish(Message) returns (Empty) {};
    36  	rpc Subscribe(Topic) returns (stream Message) {};
    37  	rpc Register(Service) returns (Empty) {};
    38  	rpc Deregister(Service) returns (Empty) {};
    39  }
    40  
    41  ```
    42  
    43  We'll then code generate via this api and have gRPC clients that can be used in any language. Although the goal then 
    44  is to level up and build idiomatic clients around this in every language to provide a truly beautiful developer experience. 
    45  It's clear that gRPC has its benefits but its clients are not great beyond Go. From a microservices perspective 
    46  enabling that via higher level clients makes the most sense.
    47  
    48  ## Serving
    49  
    50  Looking at the developer experience for adopting an api, cache, search, database or anything else it's clear the experience 
    51  needs to be a drop-in server and then providing client libraries in any language. This is sort of a frictionless thing 
    52  which augments the app development experience without having to totally buy into a framework.
    53  
    54  Micro can now be booted using a single command which provides a vastly superior developer experience.
    55  
    56  ```
    57  micro server
    58  ```
    59  
    60  This launches all the services which exist as interfaces in go-micro but will also have equivalent protos to call the services. 
    61  All requests can be routed through the fixed entry point of `localhost:8081` which is the micro proxy. This will forward 
    62  the request to the appropriate place.
    63  
    64  Services that are not micro native can use a single command to be registered in discovery
    65  
    66  ```
    67  # micro service --name [service name] --endpoint [address of service] [command to exec]
    68  micro service --name helloworld --endpoint localhost:9090 go run main.go
    69  ```
    70  
    71  Endpoint can include the protocol of the service e.g `http://localhost:9090` or `grpc://localhost:9090` otherwise we default to mucp/http
    72  
    73  ## Routing
    74  
    75  The protos will define a package name which is prefixed to the service method in grpc 
    76  
    77  ```
    78  package go.micro.registry;
    79  
    80  service Registry {
    81  	rpc GetService(...) returns (...) {};
    82  }
    83  ```
    84  
    85  The above would translate to `/go.micro.registry.Registry/GetService`. The proxy will use `go.micro.registry` as the service it calls.