// PushGlobalProxy like PushProxy but pushed to the global object
499368
func (ctx *Context) PushGlobalProxy(name string, v interface{}) int {
	ctx.PushGlobalObject()
	obj := ctx.PushProxy(v)
	ctx.PutPropString(-2, name)
	ctx.Pop()

	return obj
}
1098050
func (s *Stack) PushObject(value interface{}) (*Item, error) {
	var buffer bytes.Buffer
	enc := gob.NewEncoder(&buffer)
	if err := enc.Encode(value); err != nil {
		return nil, err
	}
	return s.Push(buffer.Bytes())
}
913833
func (client *Client) Proxies() (map[string]*Proxy, error) {
	resp, err := http.Get(client.endpoint + "/proxies")
	if err != nil {
		return nil, err
	}

	err = checkError(resp, http.StatusOK, "Proxies")
	if err != nil {
		return nil, err
	}

	proxies := make(map[string]*Proxy)
	err = json.NewDecoder(resp.Body).Decode(&proxies)
	if err != nil {
		return nil, err
	}
	for _, proxy := range proxies {
		proxy.client = client
		proxy.created = true
	}

	return proxies, nil
}
222347
func (s *State) RunGlobalCallbacks(ctx context.Context) {
	for _, cb := range s.GlobalCallbacks() {
		cb.Callback(ctx)
	}
}
1312872
func NewProxy(target *querypb.Target, qs queryservice.QueryService, normalize bool) *Proxy {
	return &Proxy{
		target:    target,
		qs:        qs,
		normalize: normalize,
	}
}
13463
func (ow *opWrapper) pushObject(vm *duktape.Context) {
	obj := vm.PushObject()

	vm.PushGoFunction(func(ctx *duktape.Context) int { ctx.PushInt(int(ow.op)); return 1 })
	vm.PutPropString(obj, "toNumber")

	vm.PushGoFunction(func(ctx *duktape.Context) int { ctx.PushString(ow.op.String()); return 1 })
	vm.PutPropString(obj, "toString")

	vm.PushGoFunction(func(ctx *duktape.Context) int { ctx.PushBoolean(ow.op.IsPush()); return 1 })
	vm.PutPropString(obj, "isPush")
}
478318
func (s *State) InvokeGlobalCallbacksOnFlush() {
	s.mu.Lock()
	defer s.mu.Unlock()

	s.invokeGlobalCallbacksOnFlush = true
}
924527
func SetProxy(proxy func(*http.Request) (*url.URL, error)) error {
	return std.SetProxy(proxy)
}
455508
func httpInspectGlobal(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
	var obj GlobalInspect
	log.Debugf("Received httpInspectGlobal: %+v", vars)

	key := vars["key"]

	collections.globalMutex.Lock()
	defer collections.globalMutex.Unlock()
	objConfig := collections.globals[key]
	if objConfig == nil {
		log.Errorf("global %s not found", key)
		return nil, errors.New("global not found")
	}
	obj.Config = *objConfig

	if err := GetOperGlobal(&obj); err != nil {
		log.Errorf("GetGlobal error for: %+v. Err: %v", obj, err)
		return nil, err
	}

	// Return the obj
	return &obj, nil
}
1320204
func newProxy(addr string, tlsConfig *tls.Config) (*Proxy, error) {
	p := &Proxy{
		addr: addr,
	}

	if tlsConfig != nil {
		p.dialOpts = append(p.dialOpts, grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig)))
	} else {
		p.dialOpts = append(p.dialOpts, grpc.WithInsecure())
	}

	conn, err := grpc.Dial(p.addr, p.dialOpts...)
	if err != nil {
		return nil, err
	}
	p.client = pb.NewDnsServiceClient(conn)

	return p, nil
}
799596
func (sdn *OpenShiftSDN) initProxy() error {
	var err error
	sdn.OsdnProxy, err = sdnproxy.New(
		sdn.NodeConfig.NetworkConfig.NetworkPluginName,
		sdn.informers.NetworkClient,
		sdn.informers.KubeClient,
		sdn.informers.NetworkInformers)
	return err
}
770018
func (s *Server) handlerWithGlobalMiddlewares(handler httputils.APIFunc) httputils.APIFunc {
	next := handler

	for _, m := range s.middlewares {
		next = m.WrapHandler(next)
	}

	if s.cfg.Logging && logrus.GetLevel() == logrus.DebugLevel {
		next = middleware.DebugRequestMiddleware(next)
	}

	return next
}
775001
func (s *Aloja) AddGlobal(m ...mw.Middleware) {
	s.globalMiddleware.Add(m...)
}
525413
func NewGlobal(Vars []node.Node) *Global {
	return &Global{
		FreeFloating: nil,
		Vars:         Vars,
	}
}
1178099
func CreateGlobal(obj *Global) error {
	// Validate parameters
	err := ValidateGlobal(obj)
	if err != nil {
		log.Errorf("ValidateGlobal retruned error for: %+v. Err: %v", obj, err)
		return err
	}

	// Check if we handle this object
	if objCallbackHandler.GlobalCb == nil {
		log.Errorf("No callback registered for global object")
		return errors.New("Invalid object type")
	}

	saveObj := obj

	collections.globalMutex.Lock()
	key := collections.globals[obj.Key]
	collections.globalMutex.Unlock()

	// Check if object already exists
	if key != nil {
		// Perform Update callback
		err = objCallbackHandler.GlobalCb.GlobalUpdate(collections.globals[obj.Key], obj)
		if err != nil {
			log.Errorf("GlobalUpdate retruned error for: %+v. Err: %v", obj, err)
			return err
		}

		// save the original object after update
		collections.globalMutex.Lock()
		saveObj = collections.globals[obj.Key]
		collections.globalMutex.Unlock()
	} else {
		// save it in cache
		collections.globalMutex.Lock()
		collections.globals[obj.Key] = obj
		collections.globalMutex.Unlock()

		// Perform Create callback
		err = objCallbackHandler.GlobalCb.GlobalCreate(obj)
		if err != nil {
			log.Errorf("GlobalCreate retruned error for: %+v. Err: %v", obj, err)
			collections.globalMutex.Lock()
			delete(collections.globals, obj.Key)
			collections.globalMutex.Unlock()
			return err
		}
	}

	// Write it to modeldb
	collections.globalMutex.Lock()
	err = saveObj.Write()
	collections.globalMutex.Unlock()
	if err != nil {
		log.Errorf("Error saving global %s to db. Err: %v", saveObj.Key, err)
		return err
	}

	return nil
}
1374169
func (pmc *proxyMetricsCollector) ManifestPush(bytesPushed uint64) {
	atomic.AddUint64(&pmc.manifestMetrics.Requests, 1)
	atomic.AddUint64(&pmc.manifestMetrics.Hits, 1)
	atomic.AddUint64(&pmc.manifestMetrics.BytesPushed, bytesPushed)
}
1152069
func (a Aggregations) Global(name string) (*AggregationSingleBucket, bool) {
	if raw, found := a[name]; found {
		agg := new(AggregationSingleBucket)
		if raw == nil {
			return agg, true
		}
		if err := json.Unmarshal(raw, agg); err == nil {
			return agg, true
		}
	}
	return nil, false
}