// Send sends the given metrics to the collector service.
513535
func (s *HTTPSender) Send(metrics []*wireformat.MetricBatch) (*wireformat.Response, error) {
	b, err := json.Marshal(metrics)
	if err != nil {
		return nil, errors.Trace(err)
	}
	r := bytes.NewBuffer(b)
	client := &http.Client{}
	resp, err := client.Post(s.url, "application/json", r)
	if err != nil {
		return nil, errors.Trace(err)
	}
	if resp.StatusCode != http.StatusOK {
		return nil, errors.Errorf("failed to send metrics http %v", resp.StatusCode)
	}

	defer resp.Body.Close()
	respReader := json.NewDecoder(resp.Body)
	metricsResponse := wireformat.Response{}
	err = respReader.Decode(&metricsResponse)
	if err != nil {
		return nil, errors.Trace(err)
	}
	return &metricsResponse, nil
}
89484
func (c *Client) Send(b []byte) ([]byte, error) {
	c.Lock()
	defer c.Unlock()

	if err := c.w.Write(b); err != nil {
		return nil, err
	}
	return c.r.Read()
}
913212
func (c *Conn) Send(req Message) (*Message, error) {
	err := Transmit(c.conn, nil, req)
	if err != nil {
		return nil, err
	}

	if !req.IsConfirmable() {
		return nil, nil
	}

	rv, err := Receive(c.conn, c.buf)
	if err != nil {
		return nil, err
	}

	return &rv, nil
}
410367
func (c *HTTPClientMock) Send(req *http.Request) HTTPClientInterface {
	c.request = req
	return c
}
616460
func (n NopSender) Send(batches []*wireformat.MetricBatch) (*wireformat.Response, error) {
	var resp = make(wireformat.EnvironmentResponses)
	for _, batch := range batches {
		resp.Ack(batch.ModelUUID, batch.UUID)
	}
	uuid, err := utils.NewUUID()
	if err != nil {
		return nil, err
	}
	return &wireformat.Response{UUID: uuid.String(), EnvResponses: resp}, nil
}
951892
func (c *Client) Send(req *Request, res Response) error {
	// TODO: handle retry, timeouts, etc.
	return c.send(req, res)
}
863467
func (c *Client) Send(ctx context.Context, req *kv.Request, kv *kv.Variables) kv.Response {
	return c.MockResponse
}
768313
func (m *Monitor) send(pl *payload.Payload) {
	m.Lock()
	defer m.Unlock()
	for ml := range m.listeners {
		ml.Enqueue(pl)
	}
}
275505
func (sender httpSender) Send(data []byte, event *models.Event) bool {

	switch sender.method {
	case http.MethodPost:
		ctx := context.WithValue(context.Background(), clients.CorrelationHeader, event.CorrelationId)
		req, err := http.NewRequest(http.MethodPost, sender.url, bytes.NewReader(data))
		if err != nil {
			return false
		}
		req.Header.Set("Content-Type", mimeTypeJSON)

		c := clients.NewCorrelatedRequest(req, ctx)
		client := &http.Client{}
		begin := time.Now()
		response, err := client.Do(c.Request)
		if err != nil {
			LoggingClient.Error(err.Error(), clients.CorrelationHeader, event.CorrelationId, internal.LogDurationKey, time.Since(begin).String())
			return false
		}
		defer response.Body.Close()
		LoggingClient.Info(fmt.Sprintf("Response: %s", response.Status), clients.CorrelationHeader, event.CorrelationId, internal.LogDurationKey, time.Since(begin).String())
	default:
		LoggingClient.Info(fmt.Sprintf("Unsupported method: %s", sender.method))
		return false
	}

	LoggingClient.Info(fmt.Sprintf("Sent data: %X", data))
	return true
}
265591
func (sys *NotificationSys) Send(args eventArgs) []event.TargetIDErr {
	sys.RLock()
	targetIDSet := sys.bucketRulesMap[args.BucketName].Match(args.EventName, args.Object.Name)
	sys.RUnlock()

	if len(targetIDSet) == 0 {
		return nil
	}

	targetIDs := targetIDSet.ToSlice()
	return sys.send(args.BucketName, args.ToEvent(), targetIDs...)
}
746824
func (bc *broadcastClient) Send(msg *common.Envelope) error {
	_, err := bc.try(func() (interface{}, error) {
		if bc.shouldStop() {
			return nil, errors.New("closing")
		}
		return bc.trySend(msg)
	})
	return err
}
284389
func (kvmsg *Kvmsg) Send(socket *zmq.Socket) (err error) {
	//fmt.Printf("Send to %s: %q\n", socket, kvmsg.frame)
	kvmsg.encode_props()
	_, err = socket.SendMessage(kvmsg.frame)
	return
}
255059
func (c *Client) Send(ctx context.Context, req *Request, auth *discovery.AuthInfo) (Response, error) {
	reqToBeSent := *req.Request
	reqToBeSent.Authentication = auth
	payload, err := proto.Marshal(&reqToBeSent)
	if err != nil {
		return nil, errors.Wrap(err, "failed marshaling Request to bytes")
	}

	sig, err := c.signRequest(payload)
	if err != nil {
		return nil, errors.Wrap(err, "failed signing Request")
	}

	conn, err := c.createConnection()
	if err != nil {
		return nil, errors.Wrap(err, "failed connecting to discovery service")
	}

	cl := discovery.NewDiscoveryClient(conn)
	resp, err := cl.Discover(ctx, &discovery.SignedRequest{
		Payload:   payload,
		Signature: sig,
	})
	if err != nil {
		return nil, errors.Wrap(err, "discovery service refused our Request")
	}
	if n := len(resp.Results); n != req.lastIndex {
		return nil, errors.Errorf("Sent %d queries but received %d responses back", req.lastIndex, n)
	}
	return req.computeResponse(resp)
}
1028201
func (f SenderFunc) Send(ctx context.Context, r Request) (mesos.Response, error) {
	return f(ctx, r)
}
732477
func Send(w http.ResponseWriter, r *http.Request, payload Sendable) *Error {

	validationErr := payload.Validate(r, true)
	if validationErr != nil {

		// use the prepared error as the new response, unless something went horribly
		// wrong
		err := validationErr.Validate(r, true)
		if err != nil {
			http.Error(w, DefaultErrorTitle, http.StatusInternalServerError)
			return err
		}

		payload = validationErr
	}

	return SendDocument(w, r, Build(payload))
}
1217313
func (gs *GRPCClient) Send(uid string, d []byte) error {
	return constants.ErrNotImplemented
}
828545
func (t *SyncTransport) Send(body map[string]interface{}) error {
	return t.doSend(body, t.RetryAttempts)
}