github.com/annwntech/go-micro/v2@v2.9.5/router/service/proto/router.proto (about)

     1  syntax = "proto3";
     2  
     3  package go.micro.router;
     4  
     5  option go_package = "github.com/annwntech/go-micro/v2/router/service/proto;router";
     6  // Router service is used by the proxy to lookup routes
     7  service Router {
     8    rpc Lookup(LookupRequest) returns (LookupResponse) {};
     9    rpc Watch(WatchRequest) returns (stream Event) {};
    10    rpc Advertise(Request) returns (stream Advert) {};
    11    rpc Process(Advert) returns (ProcessResponse) {};
    12  }
    13  
    14  service Table {
    15    rpc Create(Route) returns (CreateResponse) {};
    16    rpc Delete(Route) returns (DeleteResponse) {};
    17    rpc Update(Route) returns (UpdateResponse) {};
    18    rpc List(Request) returns (ListResponse) {};
    19    rpc Query(QueryRequest) returns (QueryResponse) {};
    20  }
    21  
    22  // Empty request
    23  message Request {}
    24  
    25  // Empty response
    26  message Response {}
    27  
    28  // ListResponse is returned by List
    29  message ListResponse {
    30    repeated Route routes = 1;
    31  }
    32  
    33  // LookupRequest is made to Lookup
    34  message LookupRequest {
    35    Query query = 1;
    36  }
    37  
    38  // LookupResponse is returned by Lookup
    39  message LookupResponse {
    40    repeated Route routes = 1;
    41  }
    42  
    43  // QueryRequest queries Table for Routes
    44  message QueryRequest{
    45    Query query = 1;
    46  }
    47  
    48  // QueryResponse is returned by Query
    49  message QueryResponse {
    50    repeated Route routes = 1;
    51  }
    52  
    53  // WatchRequest is made to Watch Router
    54  message WatchRequest {}
    55  
    56  // AdvertType defines the type of advert
    57  enum AdvertType {
    58    AdvertAnnounce = 0;
    59    AdvertUpdate = 1;
    60  }
    61  
    62  // Advert is router advertsement streamed by Watch
    63  message Advert {
    64    // id of the advertising router
    65    string id = 1;
    66    // type of advertisement
    67    AdvertType type = 2;
    68    // unix timestamp of the advertisement
    69    int64 timestamp = 3;
    70    // TTL of the Advert
    71    int64 ttl = 4;
    72    // events is a list of advertised events
    73    repeated Event events = 5;
    74  }
    75  
    76  // ProcessResponse is returned by Process
    77  message ProcessResponse {}
    78  
    79  // CreateResponse is returned by Create
    80  message CreateResponse {}
    81  
    82  // DeleteResponse is returned by Delete
    83  message DeleteResponse {}
    84  
    85  // UpdateResponse is returned by Update
    86  message UpdateResponse {}
    87  
    88  // EventType defines the type of event
    89  enum EventType {
    90    Create = 0;
    91    Delete = 1;
    92    Update = 2;
    93  }
    94  
    95  // Event is routing table event
    96  message Event {
    97    // the unique event id
    98    string id = 1;
    99    // type of event
   100    EventType type = 2;
   101    // unix timestamp of event
   102    int64 timestamp = 3;
   103    // service route
   104    Route route = 4;
   105  }
   106  
   107  // Query is passed in a LookupRequest
   108  message Query {
   109    // service to lookup
   110    string service = 1;
   111    // gateway to lookup
   112    string gateway = 2;
   113    // network to lookup
   114    string network = 3;
   115  }
   116  
   117  // Route is a service route
   118  message Route {
   119    // service for the route
   120    string service = 1;
   121    // the address that advertise this route
   122    string address = 2;
   123    // gateway as the next hop
   124    string gateway = 3;
   125    // the network for this destination
   126    string network = 4;
   127    // router if the router id
   128    string router = 5;
   129    // the network link
   130    string link = 6;
   131    // the metric / score of this route
   132    int64 metric = 7;
   133  }