本文整理汇总了Golang中code/cloudfoundry/org/lager.Logger.Fatal方法的典型用法代码示例。如果您正苦于以下问题:Golang Logger.Fatal方法的具体用法?Golang Logger.Fatal怎么用?Golang Logger.Fatal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类code/cloudfoundry/org/lager.Logger
的用法示例。
在下文中一共展示了Logger.Fatal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewPresence
func NewPresence(
logger lager.Logger,
consulClient consuladapter.Client,
lockKey string,
lockValue []byte,
clock clock.Clock,
retryInterval time.Duration,
lockTTL time.Duration,
) Presence {
uuid, err := uuid.NewV4()
if err != nil {
logger.Fatal("create-uuid-failed", err)
}
session, err := NewSessionNoChecks(uuid.String(), lockTTL, consulClient)
if err != nil {
logger.Fatal("consul-session-failed", err)
}
return Presence{
consul: session,
key: lockKey,
value: lockValue,
clock: clock,
retryInterval: retryInterval,
logger: logger,
}
}
示例2: NewLock
func NewLock(
logger lager.Logger,
consulClient consuladapter.Client,
lockKey string,
lockValue []byte,
clock clock.Clock,
retryInterval time.Duration,
lockTTL time.Duration,
) Lock {
lockMetricName := strings.Replace(lockKey, "/", "-", -1)
uuid, err := uuid.NewV4()
if err != nil {
logger.Fatal("create-uuid-failed", err)
}
session, err := NewSessionNoChecks(uuid.String(), lockTTL, consulClient)
if err != nil {
logger.Fatal("consul-session-failed", err)
}
return Lock{
consul: session,
key: lockKey,
value: lockValue,
clock: clock,
retryInterval: retryInterval,
logger: logger,
lockAcquiredMetric: metric.Metric("LockHeld." + lockMetricName),
lockUptimeMetric: metric.Duration("LockHeldDuration." + lockMetricName),
}
}
示例3: connectToNatsServer
func connectToNatsServer(logger lager.Logger, c *config.Config, startMsg chan<- struct{}) *nats.Conn {
var natsClient *nats.Conn
var natsHost atomic.Value
var err error
options := natsOptions(logger, c, &natsHost, startMsg)
attempts := 3
for attempts > 0 {
natsClient, err = options.Connect()
if err == nil {
break
} else {
attempts--
time.Sleep(100 * time.Millisecond)
}
}
if err != nil {
logger.Fatal("nats-connection-error", err)
}
var natsHostStr string
natsUrl, err := url.Parse(natsClient.ConnectedUrl())
if err == nil {
natsHostStr = natsUrl.Host
}
logger.Info("Successfully-connected-to-nats", lager.Data{"host": natsHostStr})
natsHost.Store(natsHostStr)
return natsClient
}
示例4: newUaaClient
func newUaaClient(logger lager.Logger, clock clock.Clock, c *config.Config) uaa_client.Client {
if c.RoutingApi.AuthDisabled {
logger.Info("using-noop-token-fetcher")
return uaa_client.NewNoOpUaaClient()
}
if c.OAuth.Port == -1 {
logger.Fatal("tls-not-enabled", errors.New("GoRouter requires TLS enabled to get OAuth token"), lager.Data{"token-endpoint": c.OAuth.TokenEndpoint, "port": c.OAuth.Port})
}
tokenURL := fmt.Sprintf("https://%s:%d", c.OAuth.TokenEndpoint, c.OAuth.Port)
cfg := &uaa_config.Config{
UaaEndpoint: tokenURL,
SkipVerification: c.OAuth.SkipSSLValidation,
ClientName: c.OAuth.ClientName,
ClientSecret: c.OAuth.ClientSecret,
CACerts: c.OAuth.CACerts,
MaxNumberOfRetries: c.TokenFetcherMaxRetries,
RetryInterval: c.TokenFetcherRetryInterval,
ExpirationBufferInSec: c.TokenFetcherExpirationBufferTimeInSeconds,
}
uaaClient, err := uaa_client.NewClient(logger, cfg, clock)
if err != nil {
logger.Fatal("initialize-token-fetcher-error", err)
}
return uaaClient
}
示例5: appendSSLConnectionStringParam
func appendSSLConnectionStringParam(logger lager.Logger, driverName, databaseConnectionString, sqlCACertFile string) string {
switch driverName {
case "mysql":
if sqlCACertFile != "" {
certBytes, err := ioutil.ReadFile(sqlCACertFile)
if err != nil {
logger.Fatal("failed-to-read-sql-ca-file", err)
}
caCertPool := x509.NewCertPool()
if ok := caCertPool.AppendCertsFromPEM(certBytes); !ok {
logger.Fatal("failed-to-parse-sql-ca", err)
}
tlsConfig := &tls.Config{
InsecureSkipVerify: false,
RootCAs: caCertPool,
}
mysql.RegisterTLSConfig("bbs-tls", tlsConfig)
databaseConnectionString = fmt.Sprintf("%s?tls=bbs-tls", databaseConnectionString)
}
case "postgres":
if sqlCACertFile == "" {
databaseConnectionString = fmt.Sprintf("%s?sslmode=disable", databaseConnectionString)
} else {
databaseConnectionString = fmt.Sprintf("%s?sslmode=verify-ca&sslrootcert=%s", databaseConnectionString, sqlCACertFile)
}
}
return databaseConnectionString
}
示例6: createCrypto
func createCrypto(logger lager.Logger, secret string) *secure.AesGCM {
// generate secure encryption key using key derivation function (pbkdf2)
secretPbkdf2 := secure.NewPbkdf2([]byte(secret), 16)
crypto, err := secure.NewAesGCM(secretPbkdf2)
if err != nil {
logger.Fatal("error-creating-route-service-crypto", err)
}
return crypto
}
示例7: initializeETCDDB
func initializeETCDDB(logger lager.Logger, etcdClient *etcd.Client) *etcddb.ETCDDB {
key, keys, err := encryptionFlags.Parse()
if err != nil {
logger.Fatal("cannot-setup-encryption", err)
}
keyManager, err := encryption.NewKeyManager(key, keys)
if err != nil {
logger.Fatal("cannot-setup-encryption", err)
}
cryptor := encryption.NewCryptor(keyManager, rand.Reader)
return etcddb.NewETCD(format.ENCRYPTED_PROTO, 1000, 1000, 1*time.Minute, cryptor, etcddb.NewStoreClient(etcdClient), clock.NewClock())
}
示例8: initializeSQLDB
func initializeSQLDB(logger lager.Logger, sqlConn *sql.DB) *sqldb.SQLDB {
key, keys, err := encryptionFlags.Parse()
if err != nil {
logger.Fatal("cannot-setup-encryption", err)
}
keyManager, err := encryption.NewKeyManager(key, keys)
if err != nil {
logger.Fatal("cannot-setup-encryption", err)
}
cryptor := encryption.NewCryptor(keyManager, rand.Reader)
return sqldb.NewSQLDB(sqlConn, 1000, 1000, format.ENCODED_PROTO, cryptor, guidprovider.DefaultGuidProvider, clock.NewClock(), databaseDriver)
}
示例9: initializeAuctioneerClient
func initializeAuctioneerClient(logger lager.Logger) auctioneer.Client {
if *auctioneerAddress == "" {
logger.Fatal("auctioneer-address-validation-failed", errors.New("auctioneerAddress is required"))
}
if *auctioneerCACert != "" || *auctioneerClientCert != "" || *auctioneerClientKey != "" {
client, err := auctioneer.NewSecureClient(*auctioneerAddress, *auctioneerCACert, *auctioneerClientCert, *auctioneerClientKey, *auctioneerRequireTLS)
if err != nil {
logger.Fatal("failed-to-construct-auctioneer-client", err)
}
return client
}
return auctioneer.NewClient(*auctioneerAddress)
}
示例10: setupRouteFetcher
func setupRouteFetcher(logger lager.Logger, c *config.Config, registry rregistry.RegistryInterface) *route_fetcher.RouteFetcher {
clock := clock.NewClock()
uaaClient := newUaaClient(logger, clock, c)
_, err := uaaClient.FetchToken(true)
if err != nil {
logger.Fatal("unable-to-fetch-token", err)
}
routingApiUri := fmt.Sprintf("%s:%d", c.RoutingApi.Uri, c.RoutingApi.Port)
routingApiClient := routing_api.NewClient(routingApiUri, false)
routeFetcher := route_fetcher.NewRouteFetcher(logger, uaaClient, registry, c, routingApiClient, 1, clock)
return routeFetcher
}
示例11: initializeBBSClient
func initializeBBSClient(logger lager.Logger, bbsClientHTTPTimeout time.Duration) bbs.InternalClient {
bbsURL, err := url.Parse(bbsAddress)
if err != nil {
logger.Fatal("Invalid BBS URL", err)
}
if bbsURL.Scheme != "https" {
return bbs.NewClient(bbsAddress)
}
cfhttp.Initialize(bbsClientHTTPTimeout)
bbsClient, err := bbs.NewSecureSkipVerifyClient(bbsAddress, bbsClientCert, bbsClientKey, 1, 25000)
if err != nil {
logger.Fatal("Failed to configure secure BBS client", err)
}
return bbsClient
}
示例12: initializeRegistrationRunner
func initializeRegistrationRunner(logger lager.Logger, consulClient consuladapter.Client, listenAddress string, clock clock.Clock) ifrit.Runner {
_, portString, err := net.SplitHostPort(listenAddress)
if err != nil {
logger.Fatal("failed-invalid-listen-address", err)
}
portNum, err := net.LookupPort("tcp", portString)
if err != nil {
logger.Fatal("failed-invalid-listen-port", err)
}
registration := &api.AgentServiceRegistration{
Name: "cc-uploader",
Port: portNum,
Check: &api.AgentServiceCheck{
TTL: "3s",
},
}
return locket.NewRegistrationRunner(logger, registration, consulClient, locket.RetryInterval, clock)
}
示例13: createSubscriber
func createSubscriber(
logger lager.Logger,
c *config.Config,
natsClient *nats.Conn,
registry rregistry.RegistryInterface,
startMsgChan chan struct{},
) ifrit.Runner {
guid, err := uuid.GenerateUUID()
if err != nil {
logger.Fatal("failed-to-generate-uuid", err)
}
opts := &mbus.SubscriberOpts{
ID: fmt.Sprintf("%d-%s", c.Index, guid),
MinimumRegisterIntervalInSeconds: int(c.StartResponseDelayInterval.Seconds()),
PruneThresholdInSeconds: int(c.DropletStaleThreshold.Seconds()),
}
return mbus.NewSubscriber(logger.Session("subscriber"), natsClient, registry, startMsgChan, opts)
}
示例14: natsOptions
func natsOptions(logger lager.Logger, c *config.Config, natsHost *atomic.Value, startMsg chan<- struct{}) nats.Options {
natsServers := c.NatsServers()
options := nats.DefaultOptions
options.Servers = natsServers
options.PingInterval = c.NatsClientPingInterval
options.ClosedCB = func(conn *nats.Conn) {
logger.Fatal("nats-connection-closed", errors.New("unexpected close"), lager.Data{"last_error": conn.LastError()})
}
options.DisconnectedCB = func(conn *nats.Conn) {
hostStr := natsHost.Load().(string)
logger.Info("nats-connection-disconnected", lager.Data{"nats-host": hostStr})
}
options.ReconnectedCB = func(conn *nats.Conn) {
natsURL, err := url.Parse(conn.ConnectedUrl())
natsHostStr := ""
if err != nil {
logger.Error("nats-url-parse-error", err)
} else {
natsHostStr = natsURL.Host
}
natsHost.Store(natsHostStr)
data := lager.Data{"nats-host": natsHostStr}
logger.Info("nats-connection-reconnected", data)
startMsg <- struct{}{}
}
// in the case of suspending pruning, we need to ensure we retry reconnects indefinitely
if c.SuspendPruningIfNatsUnavailable {
options.MaxReconnect = -1
}
return options
}
示例15: initializeLockMaintainer
func initializeLockMaintainer(logger lager.Logger, serviceClient bbs.ServiceClient) ifrit.Runner {
uuid, err := uuid.NewV4()
if err != nil {
logger.Fatal("Couldn't generate uuid", err)
}
if *advertiseURL == "" {
logger.Fatal("Advertise URL must be specified", nil)
}
bbsPresence := models.NewBBSPresence(uuid.String(), *advertiseURL)
lockMaintainer, err := serviceClient.NewBBSLockRunner(logger, &bbsPresence, *lockRetryInterval, *lockTTL)
if err != nil {
logger.Fatal("Couldn't create lock maintainer", err)
}
return lockMaintainer
}