Documentation
¶
Overview ¶
Copyright 2019 SpotHero
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Name string // Name of the application Environment string // Environment where the server is running Version string // Semantic Version of the application GitSHA string // GitSHA of the application when compiled Registry prometheus.Registerer // The Prometheus Registry to use. If nil, the global registry is used by default. CancelSignals []os.Signal // OS Signals to be used to cancel running servers. Defaults to SIGINT/`os.Interrupt`. }
Config defines service level configuration for HTTP servers
func (Config) CheckFlags ¶
CheckFlags ensures that the Service Config contains all necessary configuration for use at runtime. An error is returned describing any missing fields.
func (*Config) RegisterFlags ¶
RegisterFlags registers Service flags with pflags
type GRPCConfig ¶ added in v0.16.1
type GRPCConfig struct {
Config
}
GRPCConfig contains required configuration for starting a GRPC service
func (GRPCConfig) ServerCmd ¶ added in v0.16.1
func (gc GRPCConfig) ServerCmd( shortDescription, longDescription string, newService func(GRPCConfig) GRPCService, ) *cobra.Command
This method takes a function, newService, that instantiates the GRPCService by consuming the GRPCConfig object after all values are populated from the CLI and/or environment variables so that values configured by this package are accessible by newService.
Note that this function returns the Default GRPC server for use at SpotHero. Consumers of the tools libraries are free to define their own server entrypoints if desired. This function is provided as a convenience function that should satisfy most use cases.
Note that Version and GitSHA *must be specified* before calling this function.
type GRPCService ¶ added in v0.16.1
GRPCService implementors register GRPC APIs with the GRPC server
type HTTPConfig ¶
type HTTPConfig struct { Config PreStart func(ctx context.Context, router *mux.Router, server *http.Server) // A function to be called before starting the web server PostShutdown func(ctx context.Context) // A function to be called before stopping the web server }
HTTPConfig contains required configuration for starting an HTTP service
func (HTTPConfig) ServerCmd ¶
func (hc HTTPConfig) ServerCmd(shortDescript, longDescript string, newService func(HTTPConfig) HTTPService) *cobra.Command
This method takes a function, newService, that instantiates the HTTPService by consuming the HTTPConfig object after all values are populated from the CLI and/or environment variables so that values configured by this package are accessible by newService.
Note that this function returns the Default HTTP server for use at SpotHero. Consumers of the tools libraries are free to define their own server entrypoints if desired. This function is provided as a convenience function that should satisfy most use cases Note that Version and GitSHA *must be specified* before calling this function.
type HTTPService ¶ added in v0.6.0
HTTPService implementers register HTTP routes with a mux router.