...

Source file src/golang.conradwood.net/go-easyops/server/pkg.go

Documentation: golang.conradwood.net/go-easyops/server

     1  /*
     2  implements the server-side of gRPC.
     3  
     4  As part of the https://www.yacloud.eu cloud the server registers itself upon startup and thus becomes accessible
     5  for other servers and clients.
     6  
     7  # Registration
     8  
     9  Typically, servers register at the yacloud registry (registry.yacloud.eu).
    10  It is also possible (albeit discouraged) to run a private cloud with the yacloud software.
    11  
    12  The server needs at least a registry and authentication service(s).
    13  
    14  Servers can also be run in standalone mode (see -ge_standalone option). If so, they need no external services, but are limited to local clients and no load-balancing, failover or authentication.
    15  
    16  Multiple instances of the same server may register at the registry. Which server is chosen for any one rpc is handled in the client (see client package).
    17  
    18  # Types
    19  
    20  The Server supports 3 types of services:
    21  
    22    - gRPC (default), see NewServerDef()
    23  
    24    - TCP, see NewTCPServerDef(name)
    25  
    26    - HTML, deprecated.
    27  
    28    - Status, information about the status of this instance. Automatically added.
    29  
    30  # gRPC server
    31  
    32  this is the default and most commonly used service type. The server registers with the registry and claims to support the gRPC protocol. This implementation also automatically adds 'Status' to any gRPC servers.
    33  gRPC calls are authenticated, that is, all calls require either a user or a service in the context. Calls with neither of the two will be rejected. Whilst this behaviour can be changed, it should only be required for low-level services. For example, the registry must accept rpc calls without authentication, because the first calls to the registry will be a lookup for the auth-service, which is required to create user objects in contexts. (chicken and egg...)
    34  
    35  a server is typically started like this:
    36  
    37  	sd := server.NewServerDef()
    38  	sd.SetPort(4100)
    39  	sd.SetRegister(server.Register(
    40  	func(g *grpc.Server) error {
    41  	  pb.RegisterEchoServiceServer(g, &echoServer{})
    42  	  return nil
    43  	},
    44  	))
    45  	err := server.ServerStartup(sd)
    46  
    47  the "echoServer" is required to implement the service definition as defined by the .proto file.
    48  
    49  # TCP server
    50  
    51  this is a server that exposes a proprietary TCP connection on a port. The server instance registers the port at the registry, so that edge proxies (like h2gproxy) may proxy tcp connections to instances.
    52  
    53  # Status server
    54  
    55  this exposes an http api. Help can be found at [instance:port]/internal/help, for example https://10.1.1.1:4100/internal/help. Status is a bit of a misnomer. With the status api, one can:
    56    - shutdown the service
    57    - query the instance health
    58    - query the build information, including instance version
    59    - retrieve metrics (compatible with prometheus)
    60    - clear cache(s) of the instances
    61    - change commandline flags on-the-fly
    62    - view current outbound grpc Connections of this instance
    63    - view registered (as supposed to current) grpc connetions
    64    - download go debug information of this instance
    65  */
    66  package server
    67  

View as plain text