const (
COOKIE_NAME = "Auth-Token"
)
var (
BuiltinCert []byte // set on server startup
BuiltinKey []byte // set on server startup
BuiltinTLSCert tls.Certificate // set on server startup
)
func ActiveRPCs() int
func AddErrorDetail(st *status.Status, ct *ge.GRPCError) *status.Status
this will result status detail with grpcerrorlist, with a single GRPCErrorList.
func AddRegistry(sd *serverDef) (string, error)
func AddStatusDetail(st *status.Status, ct *fw.CallTrace) *status.Status
func Authenticate(ictx context.Context, cs *rpc.CallState) error
authenticate a user (and authorise access to this method/service)
func GetHealth() common.Health
func GetUsageInfo() *usage_info_tracker
func IsStopping() bool
func MethodNameFromStreamInfo(info *grpc.StreamServerInfo) string
func MethodNameFromUnaryInfo(info *grpc.UnaryServerInfo) string
func NewHTMLServerDef(name string) *serverDef
func NewTCPServerDef(name string) *serverDef
func ServerStartup(sd ServerDef) error
this is our typical gRPC server startup it sets ourselves up with our own certificates which is set for THIS SERVER, so installed/maintained together with the server (rather than as part of this software) it also configures the rpc server to expect a token to identify the user in the rpc metadata call
func ServiceNameFromStreamInfo(info *grpc.StreamServerInfo) string
func ServiceNameFromUnaryInfo(info *grpc.UnaryServerInfo) string
func SetHealth(h common.Health) error
Set the health of this service. This is useful for services which have periods where they are unavailable. Typically this is directly after starting, but sometimes also a period where they gather data.
For a service with a delayed startup, the pattern is as follows:
func main() {
server.SetHealth(common.Health_STARTING)
go do_initialisation()
}
func do_initialisation() {
doing_slow_things() // ...
server.SetHealth(common.Health_READY)
}
func SetQuietMode()
func StartFakeService(name string)
************************************************** * convenience function to register stuff with the registry * useful to register long-running clients, for example * this allows for metrics to be exposed and scraped automatically * uses a default RPC **************************************************
func UnregisterPortRegistry(port []int) error
mostly for autodeployer
type Register func(server *grpc.Server) error
server interface
type Server interface {
AddTag(key, value string)
}
type ServerDef interface {
//if something needs to be done to errors before they propagate up the stack, then this hook can be used to do so
SetErrorHandler(e func(ctx context.Context, fn string, err error))
/*
set to true if this server does NOT require authentication (default: it does need authentication).
This should normally not be necessary. Normally, a service needs to be called with EITHER a service account OR a user account OR both. There are very special circumstances where this is not possible, for example, the registry and the auth service cannot be called with a service or user account, because in order to get one, the service needs to lookup and call the auth service. Thus registry and auth both expose their RPCs as "NoAuth". In normal circumstances this is never necessary.
*/
SetNoAuth()
// the tcp port to listen on
SetPort(port int)
// register the implementation of the gRPC service
SetRegister(r Register)
DontRegister() // if this service should not register with the registry initially
// assume the service is directly accessible on a public ip. this disables functionalitity normally filtered out by proxies, such as /internal/ helpers and reflection. Normally not needed. Typically h2gproxy proxies requests.
SetPublic()
/*
set a callback that is called AFTER grpc server started successfully
*/
SetOnStartupCallback(f func())
AddTag(key, value string) // add a routing tag to a serverdef
}
func NewServerDef() ServerDef
deprecated - to be moved to global vars
type ServerMetrics struct {
// contains filtered or unexported fields
}
func NewServerMetrics() *ServerMetrics
deprecated - to be moved to global vars
type UserCache struct {
UserID string
// contains filtered or unexported fields
}