github.com/freiheit-com/kuberpult@v1.24.2-0.20240328135542-315d5630abe6/pkg/setup/doc.go (about)

     1  /*This file is part of kuberpult.
     2  
     3  Kuberpult is free software: you can redistribute it and/or modify
     4  it under the terms of the Expat(MIT) License as published by
     5  the Free Software Foundation.
     6  
     7  Kuberpult is distributed in the hope that it will be useful,
     8  but WITHOUT ANY WARRANTY; without even the implied warranty of
     9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    10  MIT License for more details.
    11  
    12  You should have received a copy of the MIT License
    13  along with kuberpult. If not, see <https://directory.fsf.org/wiki/License:Expat>.
    14  
    15  Copyright 2023 freiheit.com*/
    16  
    17  /*
    18  Server infrastructure common for all microservices in the project.
    19  It contains the code that start and configures a HTTP and/or GRPC server
    20  correctly.
    21  */
    22  package setup
    23  
    24  /*
    25  Example:
    26  
    27  func main() {
    28  	Run(ServerConfig{
    29  		GRPCProxy: &GRPCProxyConfig{
    30  			Port: "8000",
    31  			Register: func(mux *runtime.ServeMux) {
    32  				// Register your GRPC Proxy with gw.RegisterYourServiceHandlerFromEndpoint(grpcSrv, handler)
    33  			},
    34  		},
    35  		GRPC: &GRPCConfig{
    36  			Port: "10080",
    37  			Register: func(grpcSrv *grpc.Server) {
    38  				// Register your GRPC service with pb.RegisterXYServiceServer(grpcSrv, handler)
    39  			},
    40  		},
    41  		HTTP: []HTTPConfig{
    42  			{
    43  				Port: "5000",
    44  				Register: // register prometheus endpoint,
    45  			},
    46  			{
    47  				Port: "8080",
    48  				Register: // register health/live probes,
    49  			},
    50  			{
    51  				Port: "80",
    52  				Register: // register admin endpoints,
    53  				BasicAuth: // use basic auth to secure your admin endpoint
    54  			},
    55  		},
    56  		Background: []BackgroundTaskConfig{
    57  			{
    58  				Run: func(ctx context.Context) error {
    59  					// start pubsub import
    60  					return nil
    61  				},
    62  				Name: "Import Stuff",
    63  				Shutdown: func(ctx context.Context) error {
    64  					// shutdown pub/sub connection
    65  				},
    66  			},
    67  		},
    68  		Shutdown: func(ctx context.Context) error {
    69  			// close overarching connections (e.g. db or other stuff)
    70  		},
    71  	})
    72  
    73  }
    74  */