Documentation ¶
Overview ¶
Copyright © 2020 A. Jensen <jensen.aaro@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Package gke implements wrappers sets up other useful behaviors for running applications in GKE.
Copyright © 2020 A. Jensen <jensen.aaro@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2020 A. Jensen <jensen.aaro@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- Variables
- func AfterAliveContext(timeout time.Duration) context.Context
- func AliveContext() (context.Context, context.CancelFunc)
- func Do(f func(context.Context) error)
- func Metadata() *metadata.MetadataType
- func NewServer(ctx context.Context, handler http.Handler, lg Logger) (*http.Server, error)
- type LogClient
- type Logger
- func (l Logger) Alert(args ...interface{})
- func (l Logger) AlertErr(err error) error
- func (l Logger) Alertf(format string, args ...interface{}) string
- func (l Logger) Critical(args ...interface{})
- func (l Logger) CriticalErr(err error) error
- func (l Logger) Criticalf(format string, args ...interface{}) string
- func (l Logger) Debug(args ...interface{})
- func (l Logger) DebugErr(err error) error
- func (l Logger) Debugf(format string, args ...interface{}) string
- func (l Logger) Default(args ...interface{})
- func (l Logger) DefaultErr(err error) error
- func (l Logger) Defaultf(format string, args ...interface{}) string
- func (l Logger) Emergency(args ...interface{})
- func (l Logger) EmergencyErr(err error) error
- func (l Logger) Emergencyf(format string, args ...interface{}) string
- func (l Logger) Error(args ...interface{})
- func (l Logger) ErrorErr(err error) error
- func (l Logger) Errorf(format string, args ...interface{}) string
- func (l Logger) Info(args ...interface{})
- func (l Logger) InfoErr(err error) error
- func (l Logger) Infof(format string, args ...interface{}) string
- func (l Logger) Notice(args ...interface{})
- func (l Logger) NoticeErr(err error) error
- func (l Logger) Noticef(format string, args ...interface{}) string
- func (l Logger) StandardLogger(severity logging.Severity) *stdlog.Logger
- func (l Logger) Warning(args ...interface{})
- func (l Logger) WarningErr(err error) error
- func (l Logger) Warningf(format string, args ...interface{}) string
- type StorageClient
Constants ¶
const RequestContextKey = requestContextKey(`gkeRequestContextKey`)
Variables ¶
var ( // True to log to GKE. This will default to true if OnGCE() returns true LogGke bool // True to log to the standard logger. This will default to true if OnGCE() returns false LogStd bool )
Functions ¶
func AfterAliveContext ¶ added in v0.0.26
AfterAliveContext returns a context that completes when the alive context has been cancelled and all functions that were started by calling Do() have returned.
func AliveContext ¶ added in v0.0.24
func AliveContext() (context.Context, context.CancelFunc)
AliveContext returns a context that is used to communicate a shutdown to various parts of an application.
func Do ¶ added in v0.0.24
Do kicks off a function that will run while the application is alive. It is passed the AliveContext() context as a parameter. It should shutdown once the alive context has been cancelled.
func Metadata ¶ added in v0.0.24
func Metadata() *metadata.MetadataType
Types ¶
type LogClient ¶
func NewLogClient ¶
NewLogClient returns a log client. The context should remain open for the life of the log client.
type Logger ¶ added in v0.0.3
func (Logger) Alert ¶ added in v0.0.24
func (l Logger) Alert(args ...interface{})
Default creates a log entry with an Alert severity and the args as the payload ([]interface{}).
Note: Alert means a person must take an action immediately.
func (Logger) AlertErr ¶ added in v0.0.24
AlertErr creates a log entry with an Alert severity with an error as its payload. The error is converted into a string via fmt.Sprintf("%v", err) before sending to avoid possible serialization errors. The return value is err.
Note: Alert means a person must take an action immediately.
func (Logger) Alertf ¶ added in v0.0.24
Alertf creates a log entry with an Alert severity with a formatted string payload. The return is the formatted string as created by fmt.Sprintf(format, args...)
Note: Alert means a person must take an action immediately.
func (Logger) Critical ¶ added in v0.0.24
func (l Logger) Critical(args ...interface{})
Default creates a log entry with a Critical severity and the args as the payload ([]interface{}).
Note: Critical means events that cause more severe problems or brief outages.
func (Logger) CriticalErr ¶ added in v0.0.24
CriticalErr creates a log entry with a Critical severity with an error as its payload. The error is converted into a string via fmt.Sprintf("%v", err) before sending to avoid possible serialization errors. The return value is err.
Note: Critical means events that cause more severe problems or brief outages.
func (Logger) Criticalf ¶ added in v0.0.24
Criticalf creates a log entry with a Critical severity with a formatted string payload. The return is the formatted string as created by fmt.Sprintf(format, args...)
Note: Critical means events that cause more severe problems or brief outages.
func (Logger) Debug ¶ added in v0.0.24
func (l Logger) Debug(args ...interface{})
Default creates a log entry with a Debug severity and the args as the payload ([]interface{}).
Note: Debug means debug or trace information.
func (Logger) DebugErr ¶ added in v0.0.24
DebugErr creates a log entry with a Debug severity with an error as its payload. The error is converted into a string via fmt.Sprintf("%v", err) before sending to avoid possible serialization errors. The return value is err.
Note: Debug means debug or trace information.
func (Logger) Debugf ¶ added in v0.0.24
Debugf creates a log entry with a Debug severity with a formatted string payload. The return is the formatted string as created by fmt.Sprintf(format, args...)
Note: Debug means debug or trace information.
func (Logger) Default ¶ added in v0.0.24
func (l Logger) Default(args ...interface{})
Default creates a log entry with a Default severity and the args as the payload ([]interface{}).
Note: Default means the log entry has no assigned severity level.
func (Logger) DefaultErr ¶ added in v0.0.24
DefaultErr creates a log entry with a Default severity with an error as its payload. The error is converted into a string via fmt.Sprintf("%v", err) before sending to avoid possible serialization errors. The return value is err.
Note: Default means the log entry has no assigned severity level.
func (Logger) Defaultf ¶ added in v0.0.24
Defaultf creates a log entry with a Default severity with a formatted string payload. The return is the formatted string as created by fmt.Sprintf(format, args...)
Note: Default means the log entry has no assigned severity level.
func (Logger) Emergency ¶ added in v0.0.24
func (l Logger) Emergency(args ...interface{})
Default creates a log entry with an Emergency severity and the args as the payload ([]interface{}).
Note: Emergency means one or more systems are unusable.
func (Logger) EmergencyErr ¶ added in v0.0.24
EmergencyErr creates a log entry with an Emergency severity with an error as its payload. The error is converted into a string via fmt.Sprintf("%v", err) before sending to avoid possible serialization errors. The return value is err.
Note: Emergency means one or more systems are unusable.
func (Logger) Emergencyf ¶ added in v0.0.24
Emergencyf creates a log entry with an Emergency severity with a formatted string payload. The return is the formatted string as created by fmt.Sprintf(format, args...)
Note: Emergency means one or more systems are unusable.
func (Logger) Error ¶ added in v0.0.3
func (l Logger) Error(args ...interface{})
Default creates a log entry with an Error severity and the args as the payload ([]interface{}).
Note: Error means events that are likely to cause problems.
func (Logger) ErrorErr ¶ added in v0.0.7
ErrorErr creates a log entry with an Error severity with an error as its payload. The error is converted into a string via fmt.Sprintf("%v", err) before sending to avoid possible serialization errors. The return value is err.
Note: Error means events that are likely to cause problems.
func (Logger) Errorf ¶ added in v0.0.3
Errorf creates a log entry with an Error severity with a formatted string payload. The return is the formatted string as created by fmt.Sprintf(format, args...)
Note: Error means events that are likely to cause problems.
func (Logger) Info ¶ added in v0.0.24
func (l Logger) Info(args ...interface{})
Default creates a log entry with a Info severity and the args as the payload ([]interface{}).
Note: Info means routine information, such as ongoing status or performance.
func (Logger) InfoErr ¶ added in v0.0.7
InfoErr creates a log entry with a Info severity with an error as its payload. The error is converted into a string via fmt.Sprintf("%v", err) before sending to avoid possible serialization errors. The return value is err.
Note: Info means routine information, such as ongoing status or performance.
func (Logger) Infof ¶ added in v0.0.3
Infof creates a log entry with a Info severity with a formatted string payload. The return is the formatted string as created by fmt.Sprintf(format, args...)
Note: Info means routine information, such as ongoing status or performance.
func (Logger) Notice ¶ added in v0.0.24
func (l Logger) Notice(args ...interface{})
Default creates a log entry with a Notice severity and the args as the payload ([]interface{}).
Note: Notice means normal but significant events, such as start up, shut down, or configuration.
func (Logger) NoticeErr ¶ added in v0.0.7
NoticeErr creates a log entry with a Notice severity with an error as its payload. The error is converted into a string via fmt.Sprintf("%v", err) before sending to avoid possible serialization errors. The return value is err.
Note: Notice means normal but significant events, such as start up, shut down, or configuration.
func (Logger) Noticef ¶ added in v0.0.3
Noticef creates a log entry with a Notice severity with a formatted string payload. The return is the formatted string as created by fmt.Sprintf(format, args...)
Note: Notice means normal but significant events, such as start up, shut down, or configuration.
func (Logger) StandardLogger ¶ added in v0.0.12
func (Logger) Warning ¶ added in v0.0.24
func (l Logger) Warning(args ...interface{})
Default creates a log entry with a Warning severity and the args as the payload ([]interface{}).
Note: Warning means events that might cause problems.
func (Logger) WarningErr ¶ added in v0.0.24
WarningErr creates a log entry with a Warning severity with an error as its payload. The error is converted into a string via fmt.Sprintf("%v", err) before sending to avoid possible serialization errors. The return value is err.
Note: Warning means events that might cause problems.
type StorageClient ¶ added in v0.0.12
type StorageClient interface { HMACKeyHandle(projectID, accessID string) *storage.HMACKeyHandle CreateHMACKey(ctx context.Context, projectID, serviceAccountEmail string, opts ...storage.HMACKeyOption) (*storage.HMACKey, error) ListHMACKeys(ctx context.Context, projectID string, opts ...storage.HMACKeyOption) *storage.HMACKeysIterator ServiceAccount(ctx context.Context, projectID string) (string, error) Bucket(name string) *storage.BucketHandle Buckets(ctx context.Context, projectID string) *storage.BucketIterator }
func NewStorageClient ¶ added in v0.0.12
func NewStorageClient(ctx context.Context) (StorageClient, func(), error)