flex

package
v0.0.0-...-d60a78d Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package flex exposes gaemiddleware Environments for AppEngine's Flex environment.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ListeningAddr is a address to bind the listening socket to.
	ListeningAddr string
)
View Source
var ReadOnlyFlex = gaemiddleware.Environment{
	MemcacheAvailable: false,
	DSReadOnly:        true,
	DSReadOnlyPredicate: func(k *datastore.Key) (isRO bool) {

		return k.Namespace() != gaetsmon.DatastoreNamespace
	},
	Prepare: func(c context.Context) {
		globalFlex = &cloud.Flex{
			Cache: lru.New(65535),
		}
		var err error
		if globalFlexConfig, err = globalFlex.Configure(c); err != nil {
			panic(errors.Annotate(err, "could not create Flex config").Err())
		}
	},
	WithInitialRequest: func(c context.Context, req *http.Request) context.Context {

		if globalFlexConfig == nil {

			panic("global Flex config is not initialized")
		}
		return globalFlexConfig.Use(c, globalFlex.Request(c, req))
	},
	WithConfig: gaeconfig.UseFlex,
	WithAuth: func(c context.Context) context.Context {
		return auth.SetConfig(c, &globalAuthConfig)
	},
	ExtraMiddleware: router.NewMiddlewareChain(
		flexFoundationMiddleware,
		globalTsMonState.Middleware,
	),
	ExtraHandlers: func(r *router.Router, base router.MiddlewareChain) {
		gaeauth.InstallHandlers(r, base)
		pprof.InstallHandlers(r, base)

		r.GET("/_ah/health", router.MiddlewareChain{},
			func(c *router.Context) { c.Writer.WriteHeader(http.StatusOK) })
	},
}

ReadOnlyFlex is an Environment designed for cooperative Flex support environments.

Functions

func HTTPRequest

func HTTPRequest(c context.Context) *http.Request

HTTPRequest returns the inbound HTTP request associated with the current Context.

This value will always be available if the Context has been initialized by Use.

func WithGlobal

func WithGlobal(c context.Context) context.Context

WithGlobal returns a Context that is not attached to a specific request.

Types

This section is empty.

Jump to

Keyboard shortcuts

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