singleton

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2018 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clear

func Clear(key string)

Clear removes singleton for a given key.

func Get

func Get(key string, factory func() interface{}) interface{}

Get returns singleton for a given key, value does not exist if will be created by factory.

func SetScope

func SetScope(s Scope)

SetScope changes singletons scope, see scopes documentation.

Types

type Scope

type Scope uint8

Scope specifies bean scope, default scope is ScopeSingleton.

const (
	// ScopeSingleton is default Scope, with this setting there is a single
	// bean instance shared by all goroutines.
	ScopeSingleton Scope = iota
	// ScopeGLSSingleton is goroutine local storage singleton, with this setting
	// bean instance is shared by a goroutine tree, child goroutines
	// share bean instance with parent.
	ScopeGLSSingleton
)

Jump to

Keyboard shortcuts

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