Documentation ¶
Overview ¶
Package context is the runtime context of GlusterD
This file implements the global runtime context for GlusterD. Any package that needs access to the GlusterD global runtime context just needs to import this package.
Index ¶
Constants ¶
const ( MaxOpVersion = 40000 APIVersion = 1 GlusterdVersion = "4.0-dev" )
Various version constants that will be used by GD2
Variables ¶
var ( MyUUID uuid.UUID Restart bool // Indicates if its a fresh install or not Rest *rest.GDRest OpVersion int EtcdProcessCtx *os.Process EtcdClient etcdclient.Client HostIP string )
Any object that is a part of the GlusterD context and needs to be available to other packages should be declared here as exported global variables
var (
Store *store.GDStore
)
If someone needs to use the GD2 store, all they need to do is just import context and use context.Store
Functions ¶
func AssignEtcdProcessCtx ¶
AssignEtcdProcessCtx is to assign the etcd ctx in context.EtcdCtx
func GetEtcdMemberAPI ¶
func GetEtcdMemberAPI() etcdclient.MembersAPI
GetEtcdMemberAPI returns the etcd MemberAPI
func Init ¶
func Init()
Init initializes the GlusterD context. This should be called once before doing anything else.
func InitMyUUID ¶
InitMyUUID initializes MyUUID by reading the `<config.LocalStateDir>/uuid` file. If the file is not present it generates a new UUID and saves it to the file. If the file is not accessible. initMyUUID panics.
func RegisterStorePrefix ¶
func RegisterStorePrefix(prefix string)
RegisterStorePrefix allows other packages to register prefixes to be initalized on the store. The prefixes will be created on the store during GD2 context intialization
Types ¶
type Context ¶
type Context struct { Log *log.Entry // Functions which are given this context must use this logger to log their data. // contains filtered or unexported fields }
Context is used to carry contextual information across the lifetime of a request or a transaction.
func NewEmptyContext ¶
func NewEmptyContext() *Context
NewEmptyContext returns a new empty Context with no parent, no associated data and the default logger.
func NewLoggingContext ¶
NewLoggingContext returns a new context with the logger set to log given fields
func (*Context) Delete ¶
Delete deletes the key and attached value Delete doesn't recurse to parents
func (*Context) Get ¶
Get gets the value for the given key if available. Get recursively searches all parent contexts for the key. Returns nil if not found.
func (*Context) NewContext ¶
NewContext returns a new empty context with given parent
func (*Context) NewLoggingContext ¶
NewLoggingContext returns a new context with the logger set to log given fields in addition to the parents logging fields