//Invoke Call a function using DI
776724
func (i *injector) Invoke(fn interface{}) ([]reflect.Value, error) {
	t := reflect.TypeOf(fn)

	if t.Kind() != reflect.Func {
		return nil, fmt.Errorf("Unable to Invoke: %v is not a Func", fn)
	}

	nArgs := t.NumIn()
	if cap(i.args) < nArgs {
		i.args = make([]reflect.Value, nArgs)
	} else {
		i.args = i.args[0:nArgs]
	}
	for j := 0; j < nArgs; j++ {
		argTyp := t.In(j)
		v := i.GetService(argTyp)
		if !v.IsValid() {
			return nil, fmt.Errorf("Unable to Invoke: value of args[%d] not found for type %v", j, argTyp)
		}
		i.args[j] = v
	}

	return reflect.ValueOf(fn).Call(i.args), nil
}
95694
func (rpc *EthRPC) Call(method string, params ...interface{}) (json.RawMessage, error) {
	request := ethRequest{
		ID:      1,
		JSONRPC: "2.0",
		Method:  method,
		Params:  params,
	}

	body, err := json.Marshal(request)
	if err != nil {
		return nil, err
	}

	response, err := rpc.client.Post(rpc.url, "application/json", bytes.NewBuffer(body))
	if response != nil {
		defer response.Body.Close()
	}
	if err != nil {
		return nil, err
	}

	data, err := ioutil.ReadAll(response.Body)
	if err != nil {
		return nil, err
	}

	if rpc.Debug {
		rpc.log.Println(fmt.Sprintf("%s\nRequest: %s\nResponse: %s\n", method, body, data))
	}

	resp := new(ethResponse)
	if err := json.Unmarshal(data, resp); err != nil {
		return nil, err
	}

	if resp.Error != nil {
		return nil, *resp.Error
	}

	return resp.Result, nil

}
52093
func (ie *InitEvent) call() {
	log.Debug("OnInit callbacks executing")
	defer log.Debug("OnInit callbacks finished")
	for _, ev := range *ie {
		ev()
	}
}
1032620
func (h *Handler) Invoke(
	ctx context.Context,
	payload []byte,
) (resp []byte, err error) {
	if len(h.finalizer) > 0 {
		defer func() {
			for _, f := range h.finalizer {
				f(ctx, resp, err)
			}
		}()
	}

	for _, f := range h.before {
		ctx = f(ctx, payload)
	}

	request, err := h.dec(ctx, payload)
	if err != nil {
		h.errorHandler.Handle(ctx, err)
		return h.errorEncoder(ctx, err)
	}

	response, err := h.e(ctx, request)
	if err != nil {
		h.errorHandler.Handle(ctx, err)
		return h.errorEncoder(ctx, err)
	}

	for _, f := range h.after {
		ctx = f(ctx, response)
	}

	if resp, err = h.enc(ctx, response); err != nil {
		h.errorHandler.Handle(ctx, err)
		return h.errorEncoder(ctx, err)
	}

	return resp, err
}
823474
func (f CallerFunc) Call(ctx context.Context, c *scheduler.Call) (mesos.Response, error) {
	return f(ctx, c)
}
791717
func CallMethod(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) {
	return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_METHOD, params)
}
247380
func InvokeOnewayHandler(
	i OnewayInvokeRequest,
) (err error) {
	defer func() {
		if r := recover(); r != nil {
			err = handlePanic(Oneway, i.Logger, r, i.Request.ToRequestMeta())
		}
	}()

	return i.Handler.HandleOneway(i.Context, i.Request)
}
774127
func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response {
	function, args := stub.GetFunctionAndParameters()
	fmt.Println("invoke is running " + function)

	// Handle different functions
	if function == "initMarble" { //create a new marble
		return t.initMarble(stub, args)
	} else if function == "transferMarble" { //change owner of a specific marble
		return t.transferMarble(stub, args)
	} else if function == "transferMarblesBasedOnColor" { //transfer all marbles of a certain color
		return t.transferMarblesBasedOnColor(stub, args)
	} else if function == "delete" { //delete a marble
		return t.delete(stub, args)
	} else if function == "readMarble" { //read a marble
		return t.readMarble(stub, args)
	} else if function == "queryMarblesByOwner" { //find marbles for owner X using rich query
		return t.queryMarblesByOwner(stub, args)
	} else if function == "queryMarbles" { //find marbles based on an ad hoc rich query
		return t.queryMarbles(stub, args)
	} else if function == "getHistoryForMarble" { //get history of values for a marble
		return t.getHistoryForMarble(stub, args)
	} else if function == "getMarblesByRange" { //get marbles based on range query
		return t.getMarblesByRange(stub, args)
	} else if function == "getMarblesByRangeWithPagination" {
		return t.getMarblesByRangeWithPagination(stub, args)
	} else if function == "queryMarblesWithPagination" {
		return t.queryMarblesWithPagination(stub, args)
	}

	fmt.Println("invoke did not find func: " + function) //error
	return shim.Error("Received unknown function invocation")
}
133150
func (d Dispatcher) Invoke(msg Message, exactMatch bool) error {
	for address, handler := range d {
		matched, err := msg.Match(address, exactMatch)
		if err != nil {
			return err
		}
		if matched {
			return handler.Handle(msg)
		}
	}
	return nil
}
932464
func (scc *SCC) Invoke(stub shim.ChaincodeStubInterface) pb.Response {
	args := stub.GetArgs()
	if len(args) == 0 {
		return shim.Error("lifecycle scc must be invoked with arguments")
	}

	if len(args) != 2 {
		return shim.Error(fmt.Sprintf("lifecycle scc operations require exactly two arguments but received %d", len(args)))
	}

	funcName := args[0]
	inputBytes := args[1]

	// TODO add ACLs

	switch string(funcName) {
	// Each lifecycle SCC function gets a case here
	case InstallChaincodeFuncName:
		input := &lb.InstallChaincodeArgs{}
		err := scc.Protobuf.Unmarshal(inputBytes, input)
		if err != nil {
			err = errors.WithMessage(err, "failed to decode input arg to InstallChaincode")
			return shim.Error(err.Error())
		}

		hash, err := scc.Functions.InstallChaincode(input.Name, input.Version, input.ChaincodeInstallPackage)
		if err != nil {
			err = errors.WithMessage(err, "failed to invoke backing InstallChaincode")
			return shim.Error(err.Error())
		}

		resultBytes, err := scc.Protobuf.Marshal(&lb.InstallChaincodeResult{
			Hash: hash,
		})
		if err != nil {
			err = errors.WithMessage(err, "failed to marshal result")
			return shim.Error(err.Error())
		}

		return shim.Success(resultBytes)
	case QueryInstalledChaincodeFuncName:
		input := &lb.QueryInstalledChaincodeArgs{}
		err := scc.Protobuf.Unmarshal(inputBytes, input)
		if err != nil {
			err = errors.WithMessage(err, "failed to decode input arg to QueryInstalledChaincode")
			return shim.Error(err.Error())
		}

		hash, err := scc.Functions.QueryInstalledChaincode(input.Name, input.Version)
		if err != nil {
			err = errors.WithMessage(err, "failed to invoke backing QueryInstalledChaincode")
			return shim.Error(err.Error())
		}

		resultBytes, err := scc.Protobuf.Marshal(&lb.QueryInstalledChaincodeResult{
			Hash: hash,
		})
		if err != nil {
			err = errors.WithMessage(err, "failed to marshal result")
			return shim.Error(err.Error())
		}

		return shim.Success(resultBytes)
	default:
		return shim.Error(fmt.Sprintf("unknown lifecycle function: %s", funcName))
	}
}
174651
func (t *SleeperChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response {
	function, args := stub.GetFunctionAndParameters()
	if function == "put" {
		if len(args) != 3 {
			return shim.Error("Incorrect number of arguments. Expecting 3")
		}

		// Make payment of X units from A to B
		return t.invoke(stub, args)
	} else if function == "get" {
		if len(args) != 2 {
			return shim.Error("Incorrect number of arguments. Expecting 2")
		}

		// the old "Query" is now implemtned in invoke
		return t.query(stub, args)
	}

	return shim.Error("Invalid invoke function name. Expecting \"put\" or \"get\"")
}
1072457
func (s *StructInjector) Inject(dest interface{}, ctx ...reflect.Value) {
	if dest == nil {
		return
	}

	v := IndirectValue(ValueOf(dest))
	s.InjectElem(v, ctx...)
}
650302
func (s *FuncInjector) Inject(in *[]reflect.Value, ctx ...reflect.Value) {
	args := *in
	for _, input := range s.inputs {
		input.Object.Assign(ctx, func(v reflect.Value) {
			// fmt.Printf("assign input index: %d for value: %v of type: %s\n",
			// 	input.InputIndex, v.String(), v.Type().Name())
			args[input.InputIndex] = v
		})

	}

	*in = args
}
647345
func (d *Dispatch) Call(method string, params ...interface{}) (result *VARIANT, err error) {
	id, err := d.GetId(method)
	if err != nil {
		return
	}

	result, err = d.Invoke(id, DISPATCH_METHOD, params)
	return
}
868687
func (c *Call) Do(f interface{}) *Call {
	// TODO: Check arity and types here, rather than dying badly elsewhere.
	v := reflect.ValueOf(f)

	c.addAction(func(args []interface{}) []interface{} {
		vargs := make([]reflect.Value, len(args))
		ft := v.Type()
		for i := 0; i < len(args); i++ {
			if args[i] != nil {
				vargs[i] = reflect.ValueOf(args[i])
			} else {
				// Use the zero value for the arg.
				vargs[i] = reflect.Zero(ft.In(i))
			}
		}
		v.Call(vargs)
		return nil
	})
	return c
}
733348
func (f *Function) Call(c context.Context, args ...interface{}) {
	t, err := f.Task(args...)
	if err != nil {
		log.Errorf(c, "%v", err)
		return
	}
	if _, err := taskqueueAdder(c, t, queue); err != nil {
		log.Errorf(c, "delay: taskqueue.Add failed: %v", err)
		return
	}
}
923631
func (h *gzipMiddleware) Invoke(c *Context, next HandlerFunc) {
	r := c.Request
	w := c.Writer
	// Skip compression if the client doesn't accept gzip encoding.
	if !strings.Contains(r.Header.Get(headerAcceptEncoding), encodingGzip) {
		next(c)
		return
	}

	// Skip compression if client attempt WebSocket connection
	if len(r.Header.Get(headerSecWebSocketKey)) > 0 {
		next(c)
		return
	}

	// Skip compression if already compressed
	if w.Header().Get(headerContentEncoding) == encodingGzip {
		next(c)
		return
	}

	// Retrieve gzip writer from the pool. Reset it to use the ResponseWriter.
	// This allows us to re-use an already allocated buffer rather than
	// allocating a new buffer for every request.
	// We defer g.pool.Put here so that the gz writer is returned to the
	// pool if any thing after here fails for some reason (functions in
	// next could potentially panic, etc)
	gz := h.pool.Get().(*gzip.Writer)
	defer h.pool.Put(gz)
	gz.Reset(w)

	// Set the appropriate gzip headers.
	headers := w.Header()
	headers.Set(headerContentEncoding, encodingGzip)
	headers.Set(headerVary, headerAcceptEncoding)

	// Wrap the original http.ResponseWriter
	// and create the gzipResponseWriter.
	grw := gzipResponseWriter{
		gz,
		w,
		w,
	}

	// Call the next handler supplying the gzipResponseWriter instead of
	// the original.
	c.Writer = grw
	next(c)

	gz.Close()
}