gke

package module
v0.0.34 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2020 License: GPL-3.0 Imports: 20 Imported by: 2

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

View Source
const RequestContextKey = requestContextKey(`gkeRequestContextKey`)

Variables

View Source
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

func AfterAliveContext(timeout time.Duration) context.Context

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

func Do(f func(context.Context) error)

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, bool)

func NewServer added in v0.0.10

func NewServer(ctx context.Context, handler http.Handler, lg Logger) (*http.Server, error)

Types

type LogClient

type LogClient struct {
	log.Client
}

func NewLogClient

func NewLogClient(ctx context.Context) (LogClient, func(), error)

NewLogClient returns a log client. The context should remain open for the life of the log client.

func (LogClient) Logger

func (lc LogClient) Logger(logId string, opts ...logging.LoggerOption) Logger

type Logger added in v0.0.3

type Logger struct {
	log.Logger
}

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

func (l Logger) AlertErr(err error) error

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

func (l Logger) Alertf(format string, args ...interface{}) string

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

func (l Logger) CriticalErr(err error) error

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

func (l Logger) Criticalf(format string, args ...interface{}) string

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

func (l Logger) DebugErr(err error) error

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

func (l Logger) Debugf(format string, args ...interface{}) string

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

func (l Logger) DefaultErr(err error) error

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

func (l Logger) Defaultf(format string, args ...interface{}) string

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

func (l Logger) EmergencyErr(err error) error

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

func (l Logger) Emergencyf(format string, args ...interface{}) string

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

func (l Logger) ErrorErr(err error) error

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

func (l Logger) Errorf(format string, args ...interface{}) string

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

func (l Logger) InfoErr(err error) error

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

func (l Logger) Infof(format string, args ...interface{}) string

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

func (l Logger) NoticeErr(err error) error

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

func (l Logger) Noticef(format string, args ...interface{}) string

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 (l Logger) StandardLogger(severity logging.Severity) *stdlog.Logger

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

func (l Logger) WarningErr(err error) error

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.

func (Logger) Warningf added in v0.0.24

func (l Logger) Warningf(format string, args ...interface{}) string

Warningf creates a log entry with a Warning severity with a formatted string payload. The return is the formatted string as created by fmt.Sprintf(format, args...)

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)

Directories

Path Synopsis
internal
log

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL