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`.
PreStartHTTP func(ctx context.Context, router *mux.Router, server *http.Server) // A function to be called before starting the HTTP web server
PostShutdownHTTP func(ctx context.Context) // A function to be called before stopping the HTTP web server
}
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
func (Config) ServerCmd ¶ added in v0.18.0
func (c Config) ServerCmd( shortDescription, longDescription string, newHTTPService func(Config) HTTPService, newGRPCService func(Config) GRPCService, ) *cobra.Command
ServerCmd takes functions, newHTTPService and newGRPCService, that instantiate the GRPCService and HTTPService by consuming the Config 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 creates the default server configuration (grpc and http) 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 HTTPService ¶ added in v0.6.0
HTTPService implementers register HTTP routes with a mux router.