appwrap

package module
v0.0.0-...-21dd264 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: Apache-2.0 Imports: 67 Imported by: 2

README

appwrap

Interfaces to abstract appengine datastore and memache for go, along with simple reimplementation for testing only. Enhancements are welcome.

This is designed to work with the new appengine interfaces available as "google.golang.org/appengine" but it should be easy to port to classic appengine.

Test with

gcloud --project pendo-io beta emulators datastore start --host-port 127.0.0.1:8090 --consistency=1 --no-store-on-disk

and set

export DATASTORE_PROJECT_ID=pendo-io```

Documentation

Index

Constants

View Source
const (
	LogLevelDebug = LogLevel(iota)
	LogLevelInfo
	LogLevelWarning
	LogLevelError
	LogLevelCritical
	LogLevelSilence
)
View Source
const (
	LogPendoJob       = LogName("pendo_job")
	LogPendoMapReduce = LogName("pendo_map_reduce")
)
View Source
const (
	ChildLogName = "pendo.io/child_log"
)
View Source
const IPListHeader = "X-Forwarded-For"

Variables

View Source
var (
	LocalDebug     = os.Getenv("LOCAL_DEBUG") == "true"
	IsDevAppServer = false
	IsFlex         = appengine.IsFlex
	IsSecondGen    = appengine.IsSecondGen
	IsStandard     = appengine.IsStandard
)
View Source
var CacheErrCASConflict = memcache.ErrCASConflict
View Source
var CacheErrNotStored = memcache.ErrNotStored
View Source
var CacheErrServerError = memcache.ErrServerError
View Source
var DatastoreDone = iterator.Done
View Source
var ErrCacheMiss = memcache.ErrCacheMiss
View Source
var ErrConcurrentTransaction = datastore.ErrConcurrentTransaction
View Source
var ErrDatastoreDoNotRetry = status.Error(codes.Canceled, "request context canceled")
View Source
var ErrInvalidEntityType = datastore.ErrInvalidEntityType
View Source
var ErrInvalidKey = datastore.ErrInvalidKey
View Source
var ErrNoSuchEntity = datastore.ErrNoSuchEntity
View Source
var GlobalService memorystoreService
View Source
var IsTimeoutError = appengine.IsTimeoutError
View Source
var NewAppengineInfoFromContext = InternalNewAppengineInfoFromContext
View Source
var NewDatastore = NewCloudDatastore

Functions

func AddSharedLogClientToBackgroundContext

func AddSharedLogClientToBackgroundContext(c context.Context, logName string) context.Context

func CloseGlobalLoggingClient

func CloseGlobalLoggingClient() error

CloseGlobalLoggingClient closes the global logging client. This should only be called once, only during a shutdown routine. Calling this while logging is still happening will produce panics

func Criticalf

func Criticalf(ctx context.Context, format string, args ...interface{})

func Debugf

func Debugf(ctx context.Context, format string, args ...interface{})

func DecodeKey

func DecodeKey(encoded string) (*datastore.Key, error)

func Errorf

func Errorf(ctx context.Context, format string, args ...interface{})

func GetOrCreateLoggingClient

func GetOrCreateLoggingClient() *logging.Client

func InKubernetes

func InKubernetes() bool

func Infof

func Infof(ctx context.Context, format string, args ...interface{})

func InitializeMemcacheDiscovery

func InitializeMemcacheDiscovery(endpoint string)

func InitializeRedisAddrs

func InitializeRedisAddrs(addrs []string)

func IsValidLoggingContext

func IsValidLoggingContext(ctx context.Context) bool

func KeyIntID

func KeyIntID(key *DatastoreKey) int64

func KeyKind

func KeyKind(key *DatastoreKey) string

func KeyNamespace

func KeyNamespace(key *DatastoreKey) string

func KeyStringID

func KeyStringID(key *DatastoreKey) string

func LoadStruct

func LoadStruct(dest interface{}, props DatastorePropertyList) error

func NewDatastoreAdminClient

func NewDatastoreAdminClient(ctx context.Context, opts ...option.ClientOption) datastoreAdminClient

func NewGoogleErrorReporter

func NewGoogleErrorReporter(info AppengineInfo, ctx context.Context, log Logging) (*googleErrorReporter, error)

*

  • These reporters are meant to be long-lived, ideally one per program instance; Not used liberally
  • for individual requests/threads

func NewRedisAPIService

func NewRedisAPIService(ctx context.Context) (redisAPIService, error)

func RunFuncWithDedicatedLogger

func RunFuncWithDedicatedLogger(c context.Context, simulatedUrl, traceId string, fn func(log Logging))

func StubContext

func StubContext() context.Context

func UrlfetchTransport

func UrlfetchTransport(c context.Context) *urlfetch.Transport

func Warningf

func Warningf(ctx context.Context, format string, args ...interface{})

func WrapBackgroundContextWithStackdriverLogger

func WrapBackgroundContextWithStackdriverLogger(c context.Context, logName string) context.Context

for use in flex services with long-running tasks that don't handle http requests

func WrapBackgroundContextWithStackdriverLoggerWithCloseFunc

func WrapBackgroundContextWithStackdriverLoggerWithCloseFunc(c context.Context, logName string) (context.Context, func())

func WrapHandlerWithStackdriverLogger

func WrapHandlerWithStackdriverLogger(h http.Handler, logName string, opts ...option.ClientOption) http.Handler

Types

type AppEngineTask

type AppEngineTask interface {
	CloudTask
	Path() string
	SetPath(path string)
	Service() string
	SetService(service string)
	Version() string
	SetVersion(version string)
}

func NewAppEngineTask

func NewAppEngineTask() AppEngineTask

type AppengineInfo

type AppengineInfo interface {
	DataProjectID() string
	NativeProjectID() string
	InstanceID() string
	ModuleHasTraffic(moduleName, moduleVersion string) (bool, error)
	// ModuleHostname returns the HTTP hostname to route to the given version, module, and app (project).
	// If version is "", the *live* version is used.
	// If module is "", the *caller's* module is used.
	// If app is "", the *caller's* project is used.
	// Example: ("", "", "") called on service = aggregations, project = pendo-io returns "aggregations-dot-pendo-io.appspot.com"
	ModuleHostname(version, module, app string) (string, error)
	ModuleName() string
	NumInstances(moduleName, version string) (int, error)
	VersionID() string
	Zone() string
}

func InternalNewAppengineInfoFromContext

func InternalNewAppengineInfoFromContext(c context.Context) AppengineInfo

Don't call this. It exists to make NewAppengineInfoFromContext mockable

type AppengineInfoFlex

type AppengineInfoFlex struct {
	// contains filtered or unexported fields
}

func (AppengineInfoFlex) DataProjectID

func (ai AppengineInfoFlex) DataProjectID() string

func (AppengineInfoFlex) InstanceID

func (ai AppengineInfoFlex) InstanceID() string

func (AppengineInfoFlex) ModuleHasTraffic

func (ai AppengineInfoFlex) ModuleHasTraffic(moduleName, moduleVersion string) (bool, error)

func (AppengineInfoFlex) ModuleHostname

func (ai AppengineInfoFlex) ModuleHostname(version, module, app string) (string, error)

func (AppengineInfoFlex) ModuleName

func (ai AppengineInfoFlex) ModuleName() string

func (AppengineInfoFlex) NativeProjectID

func (ai AppengineInfoFlex) NativeProjectID() string

func (AppengineInfoFlex) NumInstances

func (ai AppengineInfoFlex) NumInstances(moduleName, version string) (int, error)

func (AppengineInfoFlex) VersionID

func (ai AppengineInfoFlex) VersionID() string

func (AppengineInfoFlex) Zone

func (ai AppengineInfoFlex) Zone() string

type AppengineInfoK8s

type AppengineInfoK8s struct {
	// contains filtered or unexported fields
}

func (AppengineInfoK8s) DataProjectID

func (ai AppengineInfoK8s) DataProjectID() string

func (AppengineInfoK8s) InstanceID

func (ai AppengineInfoK8s) InstanceID() string

func (AppengineInfoK8s) ModuleHasTraffic

func (ai AppengineInfoK8s) ModuleHasTraffic(moduleName, moduleVersion string) (bool, error)

There is no one way to achieve traffic management in k8s. This implementation assumes using Istio.

This implementation will attempt to find a corresponding virtual service resource labeled app=<module_name>. We will attempt to find a destination rule will a subset named moduleVersion, and derive traffic weight from this

func (AppengineInfoK8s) ModuleHostname

func (ai AppengineInfoK8s) ModuleHostname(version, module, app string) (string, error)

ModuleHostname in K8s doesn't yet handle versions

func (AppengineInfoK8s) ModuleName

func (ai AppengineInfoK8s) ModuleName() string

func (AppengineInfoK8s) NativeProjectID

func (ai AppengineInfoK8s) NativeProjectID() string

func (AppengineInfoK8s) NumInstances

func (ai AppengineInfoK8s) NumInstances(moduleName, version string) (int, error)

func (AppengineInfoK8s) VersionID

func (ai AppengineInfoK8s) VersionID() string

func (AppengineInfoK8s) Zone

func (ai AppengineInfoK8s) Zone() string

type AppwrapProperty

type AppwrapProperty struct {
	Multiple bool
	Name     string
	NoIndex  bool
	Value    interface{}
}

func ToAppwrapPropertyList

func ToAppwrapPropertyList(l []DatastoreProperty) []AppwrapProperty

type CacheItem

type CacheItem struct {
	Key   string
	Value []byte

	Flags      uint32
	Expiration time.Duration
	// contains filtered or unexported fields
}

type CacheLocation

type CacheLocation string

type CacheName

type CacheName string

type CacheShards

type CacheShards int64

type CloudDatastore

type CloudDatastore struct {
	// contains filtered or unexported fields
}

func (CloudDatastore) AllocateIDSet

func (cds CloudDatastore) AllocateIDSet(incompleteKeys []*DatastoreKey) ([]*DatastoreKey, error)

func (CloudDatastore) Deadline

func (cds CloudDatastore) Deadline(t time.Time) Datastore

func (CloudDatastore) DeleteMulti

func (cds CloudDatastore) DeleteMulti(keys []*DatastoreKey) error

func (CloudDatastore) Get

func (cds CloudDatastore) Get(key *DatastoreKey, dst interface{}) error

func (CloudDatastore) GetMulti

func (cds CloudDatastore) GetMulti(keys []*DatastoreKey, dst interface{}) error

func (CloudDatastore) Kinds

func (cds CloudDatastore) Kinds() (kinds []string, err error)

func (CloudDatastore) Namespace

func (cds CloudDatastore) Namespace(ns string) Datastore

func (CloudDatastore) NewKey

func (cds CloudDatastore) NewKey(kind string, sId string, iId int64, parent *DatastoreKey) *DatastoreKey

func (CloudDatastore) NewQuery

func (cds CloudDatastore) NewQuery(kind string) DatastoreQuery

func (CloudDatastore) Put

func (cds CloudDatastore) Put(key *DatastoreKey, src interface{}) (*DatastoreKey, error)

func (CloudDatastore) PutMulti

func (cds CloudDatastore) PutMulti(keys []*DatastoreKey, src interface{}) ([]*DatastoreKey, error)

func (CloudDatastore) RunInTransaction

func (cds CloudDatastore) RunInTransaction(f func(coreds DatastoreTransaction) error, opts ...DatastoreTransactionOption) (Commit, error)

type CloudDatastoreCommit

type CloudDatastoreCommit struct {
	// contains filtered or unexported fields
}

func (CloudDatastoreCommit) Key

func (cdc CloudDatastoreCommit) Key(pending *PendingKey) *DatastoreKey

type CloudDatastoreQuery

type CloudDatastoreQuery struct {
	// contains filtered or unexported fields
}

func (CloudDatastoreQuery) Ancestor

func (cdq CloudDatastoreQuery) Ancestor(ancestor *DatastoreKey) DatastoreQuery

func (CloudDatastoreQuery) Distinct

func (cdq CloudDatastoreQuery) Distinct() DatastoreQuery

func (CloudDatastoreQuery) Filter

func (cdq CloudDatastoreQuery) Filter(how string, what interface{}) DatastoreQuery

func (CloudDatastoreQuery) GetAll

func (cdq CloudDatastoreQuery) GetAll(dst interface{}) ([]*DatastoreKey, error)

func (CloudDatastoreQuery) KeysOnly

func (cdq CloudDatastoreQuery) KeysOnly() DatastoreQuery

func (CloudDatastoreQuery) Limit

func (cdq CloudDatastoreQuery) Limit(i int) DatastoreQuery

func (CloudDatastoreQuery) Offset

func (cdq CloudDatastoreQuery) Offset(i int) DatastoreQuery

func (CloudDatastoreQuery) Order

func (cdq CloudDatastoreQuery) Order(how string) DatastoreQuery

func (CloudDatastoreQuery) Project

func (cdq CloudDatastoreQuery) Project(fieldName ...string) DatastoreQuery

func (CloudDatastoreQuery) Run

func (CloudDatastoreQuery) Start

type CloudTask

type CloudTask interface {
	Delay() time.Duration
	SetDelay(delay time.Duration)
	Name() string
	SetName(name string)
	RetryCount() int32
	SetRetryCount(count int32)
	Copy() CloudTask
	Header() http.Header
	SetHeader(header http.Header)
	Method() string
	SetMethod(method string)
	Payload() []byte
	SetPayload(payload []byte)
	// contains filtered or unexported methods
}

This is so the calling code cannot create task structs directly. This is important for cloud tasks, where the fields of the struct have to be populated properly with blank values for the various pointer fields.

type CloudTasksLocation

type CloudTasksLocation string

type CloudTransaction

type CloudTransaction struct {
	// contains filtered or unexported fields
}

func (CloudTransaction) DeleteMulti

func (ct CloudTransaction) DeleteMulti(keys []*DatastoreKey) error

func (CloudTransaction) Get

func (ct CloudTransaction) Get(key *DatastoreKey, dst interface{}) error

func (CloudTransaction) GetMulti

func (ct CloudTransaction) GetMulti(keys []*DatastoreKey, dst interface{}) error

func (CloudTransaction) NewKey

func (ct CloudTransaction) NewKey(kind string, sId string, iId int64, parent *DatastoreKey) *DatastoreKey

func (CloudTransaction) NewQuery

func (ct CloudTransaction) NewQuery(kind string) DatastoreQuery

func (CloudTransaction) Put

func (ct CloudTransaction) Put(key *DatastoreKey, src interface{}) (*PendingKey, error)

func (CloudTransaction) PutMulti

func (ct CloudTransaction) PutMulti(keys []*DatastoreKey, src interface{}) ([]*PendingKey, error)

type Commit

type Commit interface {
	Key(pending *PendingKey) *DatastoreKey
}

type DataLogging

type DataLogging interface {
	Logging
	Debug(data interface{})
	Info(data interface{})
	Warning(data interface{})
	Error(data interface{})
	Critical(data interface{})
	Close(http.ResponseWriter)
}

DataLogging for system logging that can accept json, strings, or structs

type Datastore

type Datastore interface {
	AllocateIDSet(incompleteKeys []*DatastoreKey) ([]*DatastoreKey, error)
	Deadline(t time.Time) Datastore
	DeleteMulti(keys []*DatastoreKey) error
	Get(keys *DatastoreKey, dst interface{}) error
	GetMulti(keys []*DatastoreKey, dst interface{}) error
	Kinds() ([]string, error)
	Namespace(ns string) Datastore
	NewKey(string, string, int64, *DatastoreKey) *DatastoreKey
	NewQuery(kind string) DatastoreQuery
	Put(key *DatastoreKey, src interface{}) (*DatastoreKey, error)
	PutMulti(keys []*DatastoreKey, src interface{}) ([]*DatastoreKey, error)
	RunInTransaction(f func(coreds DatastoreTransaction) error, opts ...DatastoreTransactionOption) (Commit, error)
}

func NewCloudDatastore

func NewCloudDatastore(c context.Context) (Datastore, error)

func NewLocalDatastore

func NewLocalDatastore(addField bool, index DatastoreIndex) Datastore

type DatastoreCursor

type DatastoreCursor interface{}

type DatastoreEntity

type DatastoreEntity = datastore.Entity

type DatastoreIndex

type DatastoreIndex map[string][]entityIndex

func IndexIntersection

func IndexIntersection(d1 DatastoreIndex, d2 DatastoreIndex) DatastoreIndex

func LoadIndexYaml

func LoadIndexYaml(data []byte) (DatastoreIndex, error)

type DatastoreIterator

type DatastoreIterator interface {
	Next(itemPtr interface{}) (*DatastoreKey, error)
	Cursor() (DatastoreCursor, error)
}

type DatastoreKey

type DatastoreKey = datastore.Key

func KeyParent

func KeyParent(key *DatastoreKey) *DatastoreKey

func SetKeyNamespace

func SetKeyNamespace(key *DatastoreKey, ns string) *DatastoreKey

SetKeyNamespace recursively sets the namespace for a key and its parents.

type DatastoreProperty

type DatastoreProperty = datastore.Property

func ToDatastorePropertyList

func ToDatastorePropertyList(l []AppwrapProperty) []DatastoreProperty

type DatastorePropertyList

type DatastorePropertyList = datastore.PropertyList

func SaveStruct

func SaveStruct(src interface{}) (DatastorePropertyList, error)

type DatastorePropertyLoadSaver

type DatastorePropertyLoadSaver = datastore.PropertyLoadSaver

type DatastoreQuery

type DatastoreQuery interface {
	Ancestor(ancestor *DatastoreKey) DatastoreQuery
	Distinct() DatastoreQuery
	Filter(how string, what interface{}) DatastoreQuery
	KeysOnly() DatastoreQuery
	Limit(i int) DatastoreQuery
	Offset(i int) DatastoreQuery
	Order(how string) DatastoreQuery
	Project(fieldName ...string) DatastoreQuery
	Start(c DatastoreCursor) DatastoreQuery
	Run() DatastoreIterator
	GetAll(dst interface{}) ([]*DatastoreKey, error)
}

type DatastoreTransaction

type DatastoreTransaction interface {
	DeleteMulti(keys []*DatastoreKey) error
	Get(keys *DatastoreKey, dst interface{}) error
	GetMulti(keys []*DatastoreKey, dst interface{}) error
	NewKey(string, string, int64, *DatastoreKey) *DatastoreKey
	NewQuery(kind string) DatastoreQuery
	Put(key *DatastoreKey, src interface{}) (*PendingKey, error)
	PutMulti(keys []*DatastoreKey, src interface{}) ([]*PendingKey, error)
}

type DatastoreTransactionOption

type DatastoreTransactionOption datastore.TransactionOption

func DatastoreMaxAttempts

func DatastoreMaxAttempts(attempts int) DatastoreTransactionOption

type ErrorReport

type ErrorReport struct {
	Err             error
	Req             *http.Request
	ErrorAffectsKey string
}

type ErrorReporter

type ErrorReporter interface {
	Close() error
	FlushReports()
	Report(errReport ErrorReport)
	WrapLogger(logging Logging, errorAffectsLabel string) Logging
}

type ErrorReporterMock

type ErrorReporterMock struct {
	mock.Mock
}

func (*ErrorReporterMock) Close

func (m *ErrorReporterMock) Close() error

func (*ErrorReporterMock) FlushReports

func (m *ErrorReporterMock) FlushReports()

func (*ErrorReporterMock) Report

func (m *ErrorReporterMock) Report(errReport ErrorReport)

func (*ErrorReporterMock) WrapLogger

func (m *ErrorReporterMock) WrapLogger(logging Logging, errorAffectsLabel string) Logging

type FormatLogger

type FormatLogger struct {
	Logf func(format string, args ...interface{})
}

func (FormatLogger) AddLabels

func (fl FormatLogger) AddLabels(labels map[string]string) error

func (FormatLogger) Criticalf

func (fl FormatLogger) Criticalf(format string, args ...interface{})

func (FormatLogger) Debugf

func (fl FormatLogger) Debugf(format string, args ...interface{})

func (FormatLogger) Errorf

func (fl FormatLogger) Errorf(format string, args ...interface{})

func (FormatLogger) Infof

func (fl FormatLogger) Infof(format string, args ...interface{})

func (FormatLogger) Request

func (fl FormatLogger) Request(request, url, format string, args ...interface{})

func (FormatLogger) TraceID

func (fl FormatLogger) TraceID() string

func (FormatLogger) Warningf

func (fl FormatLogger) Warningf(format string, args ...interface{})

type GeoPoint

type GeoPoint = datastore.GeoPoint

type HttpTask

type HttpTask interface {
	CloudTask
	Url() string
	SetUrl(url string)
}

func NewHttpCloudTask

func NewHttpCloudTask(serviceAccount string) HttpTask

type LegacyDatastore

type LegacyDatastore interface {
	AllocateIDs(kind string, parent *DatastoreKey, n int) (int64, int64, error)
	NewKey(string, string, int64, *DatastoreKey) *DatastoreKey
	Kinds() ([]string, error)
}

type LevelLogger

type LevelLogger struct {
	// contains filtered or unexported fields
}

LevelLogger is a wrapper for another Logging that will filter based on log level. It calls the inner Logging's Request once any log message passes the filter.

func NewLevelLogger

func NewLevelLogger(minlevel LogLevel, wrappedLogger Logging) *LevelLogger

func (*LevelLogger) AddLabels

func (ll *LevelLogger) AddLabels(labels map[string]string) error

func (*LevelLogger) Criticalf

func (ll *LevelLogger) Criticalf(format string, args ...interface{})

func (*LevelLogger) Debugf

func (ll *LevelLogger) Debugf(format string, args ...interface{})

func (*LevelLogger) Errorf

func (ll *LevelLogger) Errorf(format string, args ...interface{})

func (*LevelLogger) Infof

func (ll *LevelLogger) Infof(format string, args ...interface{})

func (*LevelLogger) Request

func (ll *LevelLogger) Request(request, url, format string, args ...interface{})

func (*LevelLogger) SetMinLevel

func (ll *LevelLogger) SetMinLevel(level LogLevel)

func (*LevelLogger) TraceID

func (ll *LevelLogger) TraceID() string

func (*LevelLogger) Warningf

func (ll *LevelLogger) Warningf(format string, args ...interface{})

type LocalDatastore

type LocalDatastore struct {
	// contains filtered or unexported fields
}

func (*LocalDatastore) AllocateIDSet

func (ds *LocalDatastore) AllocateIDSet(incompleteKeys []*DatastoreKey) ([]*DatastoreKey, error)

func (*LocalDatastore) AllocateIDs

func (ds *LocalDatastore) AllocateIDs(kind string, parent *DatastoreKey, n int) (int64, int64, error)

func (*LocalDatastore) Deadline

func (ds *LocalDatastore) Deadline(t time.Time) Datastore

func (*LocalDatastore) DeleteMulti

func (ds *LocalDatastore) DeleteMulti(keys []*DatastoreKey) (err error)

func (*LocalDatastore) Get

func (ds *LocalDatastore) Get(k *DatastoreKey, dst interface{}) error

func (*LocalDatastore) GetMulti

func (ds *LocalDatastore) GetMulti(keys []*DatastoreKey, dstIntf interface{}) error

func (*LocalDatastore) Kinds

func (ds *LocalDatastore) Kinds() (kinds []string, err error)

func (*LocalDatastore) Namespace

func (ds *LocalDatastore) Namespace(ns string) Datastore

func (*LocalDatastore) NewKey

func (ds *LocalDatastore) NewKey(kind string, sId string, iId int64, parent *DatastoreKey) *DatastoreKey

namespace handling for this is slightly different based on appengine datastore keys vs cloud datastore keys

func (*LocalDatastore) NewQuery

func (ds *LocalDatastore) NewQuery(kind string) DatastoreQuery

func (*LocalDatastore) Put

func (ds *LocalDatastore) Put(key *DatastoreKey, src interface{}) (*DatastoreKey, error)

func (*LocalDatastore) PutMulti

func (ds *LocalDatastore) PutMulti(keys []*DatastoreKey, src interface{}) ([]*DatastoreKey, error)

func (*LocalDatastore) RunInTransaction

func (ds *LocalDatastore) RunInTransaction(f func(coreds DatastoreTransaction) error, opts ...DatastoreTransactionOption) (Commit, error)

type LocalMemcache

type LocalMemcache struct {
	// contains filtered or unexported fields
}

func (*LocalMemcache) Add

func (mc *LocalMemcache) Add(item *CacheItem) error

func (*LocalMemcache) AddMulti

func (mc *LocalMemcache) AddMulti(items []*CacheItem) error

func (*LocalMemcache) CompareAndSwap

func (mc *LocalMemcache) CompareAndSwap(item *CacheItem) error

func (*LocalMemcache) Delete

func (mc *LocalMemcache) Delete(key string) error

func (*LocalMemcache) DeleteMulti

func (mc *LocalMemcache) DeleteMulti(keys []string) error

func (*LocalMemcache) Flush

func (mc *LocalMemcache) Flush() error

func (*LocalMemcache) FlushShard

func (mc *LocalMemcache) FlushShard(shard int) error

func (*LocalMemcache) Get

func (mc *LocalMemcache) Get(key string) (*CacheItem, error)

func (*LocalMemcache) GetMulti

func (mc *LocalMemcache) GetMulti(keys []string) (map[string]*CacheItem, error)

func (*LocalMemcache) Increment

func (mc *LocalMemcache) Increment(key string, amount int64, initialValue uint64, initialExpires time.Duration) (uint64, error)

func (*LocalMemcache) IncrementExisting

func (mc *LocalMemcache) IncrementExisting(key string, amount int64) (uint64, error)

func (*LocalMemcache) Namespace

func (mc *LocalMemcache) Namespace(ns string) Memcache

func (*LocalMemcache) Set

func (mc *LocalMemcache) Set(item *CacheItem) error

func (*LocalMemcache) SetMulti

func (mc *LocalMemcache) SetMulti(items []*CacheItem) error

type LogLevel

type LogLevel int

type LogName

type LogName string

type LogServiceMock

type LogServiceMock struct {
	mock.Mock
}

func (*LogServiceMock) Close

func (m *LogServiceMock) Close()

func (*LogServiceMock) CreateLog

func (m *LogServiceMock) CreateLog(labels map[string]string, logName LogName, r *http.Request, traceId string) Logging

type LoggerClientInterface

type LoggerClientInterface interface {
	Logger(logID string, opts ...logging.LoggerOption) LoggerInterface
	Close() error
	SetUpOnError()
	Ping(ctx context.Context) error
}

type LoggerInterface

type LoggerInterface interface {
	Log(logging.Entry)
	Flush() error
}

type Logging

type Logging interface {
	Debugf(format string, args ...interface{})                // Debug message
	Infof(format string, args ...interface{})                 // Information message
	Warningf(format string, args ...interface{})              // Warning message
	Errorf(format string, args ...interface{})                // Error message
	Criticalf(format string, args ...interface{})             // Critical message
	Request(request, url, format string, args ...interface{}) // This is conditionally implemented
	AddLabels(labels map[string]string) error                 // Adds labels to your log message
	TraceID() string                                          // Trace ID for current request, or "" if N/A
}

Interface for system logging using printf() style strings

func NewAppengineLogging

func NewAppengineLogging(c context.Context) Logging

func NewStackdriverLogging

func NewStackdriverLogging(c context.Context) Logging

func NewWriterLogger

func NewWriterLogger(writer io.Writer) Logging

type LoggingClient

type LoggingClient struct {
	// contains filtered or unexported fields
}

func (*LoggingClient) Close

func (lc *LoggingClient) Close() error

func (*LoggingClient) Logger

func (lc *LoggingClient) Logger(logID string, opts ...logging.LoggerOption) LoggerInterface

func (*LoggingClient) Ping

func (lc *LoggingClient) Ping(ctx context.Context) error

func (*LoggingClient) SetUpOnError

func (lc *LoggingClient) SetUpOnError()

type LoggingMock

type LoggingMock struct {
	mock.Mock
	Log Logging // all log calls are passed through to this logger (NullLogger may be used)
}

func (*LoggingMock) AddLabels

func (m *LoggingMock) AddLabels(labels map[string]string) error

func (*LoggingMock) Criticalf

func (m *LoggingMock) Criticalf(format string, args ...interface{})

func (*LoggingMock) Debugf

func (m *LoggingMock) Debugf(format string, args ...interface{})

func (*LoggingMock) Errorf

func (m *LoggingMock) Errorf(format string, args ...interface{})

func (*LoggingMock) Infof

func (m *LoggingMock) Infof(format string, args ...interface{})

func (*LoggingMock) Request

func (m *LoggingMock) Request(method, url, format string, args ...interface{})

func (*LoggingMock) ResetMock

func (m *LoggingMock) ResetMock()

func (*LoggingMock) TraceID

func (m *LoggingMock) TraceID() string

func (*LoggingMock) Warningf

func (m *LoggingMock) Warningf(format string, args ...interface{})

type LoggingServiceInterface

type LoggingServiceInterface interface {
	CreateLog(labels map[string]string, logName LogName, r *http.Request, traceId string) Logging
	Close()
}

func NewAppEngineLoggingService

func NewAppEngineLoggingService(c context.Context, aeInfo AppengineInfo) LoggingServiceInterface

type Memcache

type Memcache interface {
	Add(item *CacheItem) error
	AddMulti(item []*CacheItem) error
	CompareAndSwap(item *CacheItem) error
	Delete(key string) error
	DeleteMulti(keys []string) error
	Flush() error
	FlushShard(shard int) error
	Get(key string) (*CacheItem, error)
	GetMulti(keys []string) (map[string]*CacheItem, error)
	Increment(key string, amount int64, initialValue uint64, initialExpires time.Duration) (uint64, error)
	IncrementExisting(key string, amount int64) (uint64, error)
	Namespace(ns string) Memcache
	Set(item *CacheItem) error
	SetMulti(item []*CacheItem) error
}

func NewAppengineMemcache

func NewAppengineMemcache(c context.Context, appInfo AppengineInfo, loc CacheLocation, name CacheName) (Memcache, error)

func NewLocalMemcache

func NewLocalMemcache() Memcache

func NewMemorystore

func NewMemorystore(c context.Context, appInfo AppengineInfo, loc CacheLocation, name CacheName, shards CacheShards) (Memcache, error)

func NewRateLimitedMemorystore

func NewRateLimitedMemorystore(c context.Context, appInfo AppengineInfo, loc CacheLocation, name CacheName, shards CacheShards, log Logging, createLimiters func(shard int, log Logging) redis.Limiter) (Memcache, error)

type Memorystore

type Memorystore struct {
	// contains filtered or unexported fields
}

func (Memorystore) Add

func (ms Memorystore) Add(item *CacheItem) error

func (Memorystore) AddMulti

func (ms Memorystore) AddMulti(items []*CacheItem) error

func (Memorystore) CompareAndSwap

func (ms Memorystore) CompareAndSwap(item *CacheItem) error

func (Memorystore) Delete

func (ms Memorystore) Delete(key string) error

This (and DeleteMulti) doesn't return ErrCacheMiss if the key doesn't exist However, every caller of this never used that error for anything useful

func (Memorystore) DeleteMulti

func (ms Memorystore) DeleteMulti(keys []string) error

func (Memorystore) Flush

func (ms Memorystore) Flush() error

func (Memorystore) FlushShard

func (ms Memorystore) FlushShard(shard int) error

func (Memorystore) Get

func (ms Memorystore) Get(key string) (*CacheItem, error)

func (Memorystore) GetMulti

func (ms Memorystore) GetMulti(keys []string) (map[string]*CacheItem, error)

func (Memorystore) Increment

func (ms Memorystore) Increment(key string, amount int64, initialValue uint64, initialExpires time.Duration) (incr uint64, err error)

func (Memorystore) IncrementExisting

func (ms Memorystore) IncrementExisting(key string, amount int64) (uint64, error)

func (Memorystore) Namespace

func (ms Memorystore) Namespace(ns string) Memcache

func (Memorystore) Set

func (ms Memorystore) Set(item *CacheItem) error

func (Memorystore) SetMulti

func (ms Memorystore) SetMulti(items []*CacheItem) error

type MultiError

type MultiError = appengine.MultiError

type NullLogger

type NullLogger struct{}

Sometimes, you just need to satify the interface and do nothing.

func (NullLogger) AddLabels

func (nl NullLogger) AddLabels(labels map[string]string) error

func (NullLogger) Criticalf

func (nl NullLogger) Criticalf(format string, args ...interface{})

func (NullLogger) Debugf

func (nl NullLogger) Debugf(format string, args ...interface{})

func (NullLogger) Errorf

func (nl NullLogger) Errorf(format string, args ...interface{})

func (NullLogger) Infof

func (nl NullLogger) Infof(format string, args ...interface{})

func (NullLogger) Request

func (nl NullLogger) Request(request, url, format string, args ...interface{})

func (NullLogger) TraceID

func (nl NullLogger) TraceID() string

func (NullLogger) Warningf

func (nl NullLogger) Warningf(format string, args ...interface{})

type PendingKey

type PendingKey = datastore.PendingKey

type PrefixLogger

type PrefixLogger struct {
	Logging
	Prefix string
}

func (PrefixLogger) AddLabels

func (pl PrefixLogger) AddLabels(labels map[string]string) error

func (PrefixLogger) Criticalf

func (pl PrefixLogger) Criticalf(format string, args ...interface{})

func (PrefixLogger) Debugf

func (pl PrefixLogger) Debugf(format string, args ...interface{})

func (PrefixLogger) Errorf

func (pl PrefixLogger) Errorf(format string, args ...interface{})

func (PrefixLogger) Infof

func (pl PrefixLogger) Infof(format string, args ...interface{})

func (PrefixLogger) Request

func (pl PrefixLogger) Request(request, url, format string, args ...interface{})

func (PrefixLogger) TraceID

func (pl PrefixLogger) TraceID() string

func (PrefixLogger) Warningf

func (pl PrefixLogger) Warningf(format string, args ...interface{})

type Properties

type Properties struct {
	Name      string
	Direction string
}

type StackdriverLogging

type StackdriverLogging struct {
	// contains filtered or unexported fields
}

StackdriverLogging is a logger set up to work with an App Engine flexible environment

func (*StackdriverLogging) AddLabel

func (sl *StackdriverLogging) AddLabel(key, value string)

AddLabel will add a common label used to link relevant log entries together

func (*StackdriverLogging) AddLabels

func (sl *StackdriverLogging) AddLabels(labels map[string]string) error

func (StackdriverLogging) Close

Close will close the logger and log request and response information to the parent logger

func (*StackdriverLogging) Critical

func (sl *StackdriverLogging) Critical(data interface{})

Critical will log the specified data to the logging system with the critical log level

func (*StackdriverLogging) Criticalf

func (sl *StackdriverLogging) Criticalf(format string, args ...interface{})

Criticalf will log the data in the specified format with a severity level of critical

func (*StackdriverLogging) Debug

func (sl *StackdriverLogging) Debug(data interface{})

Debug will log the specified data to the logging system with the debug log level

func (*StackdriverLogging) Debugf

func (sl *StackdriverLogging) Debugf(format string, args ...interface{})

Debugf will log the data in the specified format with a severity level of debug

func (*StackdriverLogging) Error

func (sl *StackdriverLogging) Error(data interface{})

Error will log the specified data to the logging system with the error log level

func (*StackdriverLogging) Errorf

func (sl *StackdriverLogging) Errorf(format string, args ...interface{})

Errorf will log the data in the specified format with a severity level of error

func (*StackdriverLogging) Info

func (sl *StackdriverLogging) Info(data interface{})

Info will log the specified data to the logging system with the info log level

func (*StackdriverLogging) Infof

func (sl *StackdriverLogging) Infof(format string, args ...interface{})

Infof will log the data in the specified format with a severity level of info

func (*StackdriverLogging) RemoveLabel

func (sl *StackdriverLogging) RemoveLabel(key string)

RemoveLabel will remove a common label used to link relevant log entries together

func (*StackdriverLogging) Request

func (sl *StackdriverLogging) Request(method, url, format string, args ...interface{})

func (*StackdriverLogging) TraceID

func (sl *StackdriverLogging) TraceID() string

func (*StackdriverLogging) Warning

func (sl *StackdriverLogging) Warning(data interface{})

Warning will log the specified data to the logging system with the warning log level

func (*StackdriverLogging) Warningf

func (sl *StackdriverLogging) Warningf(format string, args ...interface{})

Warningf will log the data in the specified format with a severity level of warning

type StackdriverLoggingService

type StackdriverLoggingService struct {
	// contains filtered or unexported fields
}

StackdriverLogging is a logger set up to work with an App Engine flexible environment

func (*StackdriverLoggingService) Close

func (sl *StackdriverLoggingService) Close()

Close will close the logging service and flush the logs. This will close off the logging service from being able to receive logs

func (*StackdriverLoggingService) CreateLog

func (sl *StackdriverLoggingService) CreateLog(labels map[string]string, logName LogName, r *http.Request, traceId string) Logging

CreateLog will return a new logger to use throughout a single request

Every Request on AppEngine includes a header X-Cloud-Trace-Context which contains a traceId. This id can be used to correlate various logs together from a request. Stackdriver will leverage this field when producing a child/parent relationship in the Stackdriver UI. However, not all logs include a request object. In that instance we will fallback to the provided traceId

type StandardLoggingService

type StandardLoggingService struct {
	// contains filtered or unexported fields
}

func (StandardLoggingService) Close

func (sls StandardLoggingService) Close()

Close is not implemented since there is nothing to shut down on App Engine's standard logger

func (StandardLoggingService) CreateLog

func (sls StandardLoggingService) CreateLog(labels map[string]string, logName LogName, r *http.Request, traceId string) Logging

CreateLog simply returns the App Engine logger for legacy standard environments

type Taskqueue

type Taskqueue interface {
	Add(c context.Context, task CloudTask, queueName string) (CloudTask, error)
	AddMulti(c context.Context, tasks []CloudTask, queueName string) ([]CloudTask, error)
	NewAppEngineCloudTask(path string, params url.Values) AppEngineTask
	NewHttpCloudTask(serviceAccount string, url string, method string, data []byte, headers http.Header) HttpTask
}

func NewTaskqueue

func NewTaskqueue(c context.Context, loc CloudTasksLocation) Taskqueue

type TeeLogging

type TeeLogging struct {
	Logs []Logging
}

func (TeeLogging) AddLabels

func (tee TeeLogging) AddLabels(labels map[string]string) error

func (TeeLogging) Criticalf

func (tee TeeLogging) Criticalf(format string, args ...interface{})

func (TeeLogging) Debugf

func (tee TeeLogging) Debugf(format string, args ...interface{})

func (TeeLogging) Errorf

func (tee TeeLogging) Errorf(format string, args ...interface{})

func (TeeLogging) Infof

func (tee TeeLogging) Infof(format string, args ...interface{})

func (TeeLogging) Request

func (tee TeeLogging) Request(request, url, format string, args ...interface{})

func (TeeLogging) TraceID

func (tee TeeLogging) TraceID() string

func (TeeLogging) Warningf

func (tee TeeLogging) Warningf(format string, args ...interface{})

type WriterLogger

type WriterLogger struct {
	FormatLogger
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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