func (t *OutputConfig) OutputEvent(ctx context.Context, event logevent.LogEvent) (err error) {
	i := rand.Intn(len(t.URLs))

	raw, err := event.MarshalJSON()
	if err != nil {
		return err
	}

	url := t.URLs[i]
	req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(raw))
	if err != nil {
		return err
	}
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("User-Agent", "gogstash/output"+ModuleName)

	resp, err := t.httpClient.Do(req)
	if err != nil {
		t.failedDelivery(ctx, event)
		return err
	}
	defer resp.Body.Close()

	_, err = ioutil.ReadAll(resp.Body)
	if err != nil {
		t.failedDelivery(ctx, event)
		return err
	}
	if _, isinlist := t.permanentHttpErrors[resp.StatusCode]; isinlist {
		return ErrPermanentError.New(nil, url, resp.StatusCode)
	}
	if _, ok := t.acceptedHttpResult[resp.StatusCode]; !ok {
		t.failedDelivery(ctx, event)
		return ErrSoftError.New(nil, url, resp.StatusCode)
	}
	// the event was sent correctly, we now have to resume inputs if we earlier has requested a pause.
	return t.queue.Resume(ctx)
}
// OutputEvent tries to send a message, requeueing if is has a temporary error
OutputEvent tries to send a message, requeueing if is has a temporary error
// OutputEvent tries to send a message requeueing if is has a temporary error
func (t *OutputConfig) OutputEvent(ctx context.Context, event logevent.LogEvent) (err error) {
	i := rand.Intn(len(t.URLs))
	raw, err := event.MarshalJSON()
	if err != nil {
		return err
	}
	url := t.URLs[i]
	req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(raw))
	if err != nil {
		return err
	}
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("User-Agent", "gogstash/output"+ModuleName)
	resp, err := t.httpClient.Do(req)
	if err != nil {
		t.failedDelivery(ctx, event)
		return err
	}
	defer resp.Body.Close()
	_, err = ioutil.ReadAll(resp.Body)
	if err != nil {
		t.failedDelivery(ctx, event)
		return err
	}
	if _, isinlist := t.permanentHttpErrors[resp.StatusCode]; isinlist {
		return ErrPermanentError.New(nil, url, resp.StatusCode)
	}
	if _, ok := t.acceptedHttpResult[resp.StatusCode]; !ok {
		t.failedDelivery(ctx, event)
		return ErrSoftError.New(nil, url, resp.StatusCode)
	}
	return t.queue.Resume(ctx)
}
func ( t * OutputConfig ) OutputEvent ( ctx context . Context , event logevent . LogEvent ) ( err error ) { i := rand . Intn ( len ( t . URLs ) ) raw , err := event . MarshalJSON ( ) if err != nil { return err } url := t . URLs [ i ] req , err := http . NewRequestWithContext ( ctx , http . MethodPost , url , bytes . NewReader ( raw ) ) if err != nil { return err } req . Header . Set ( " " , " " ) req . Header . Set ( " " , " " + ModuleName ) resp , err := t . httpClient . Do ( req ) if err != nil { t . failedDelivery ( ctx , event ) return err } defer resp . Body . Close ( ) _ , err = ioutil . ReadAll ( resp . Body ) if err != nil { t . failedDelivery ( ctx , event ) return err } if _ , isinlist := t . permanentHttpErrors [ resp . StatusCode ] ; isinlist { return ErrPermanentError . New ( nil , url , resp . StatusCode ) } if _ , ok := t . acceptedHttpResult [ resp . StatusCode ] ; ! ok { t . failedDelivery ( ctx , event ) return ErrSoftError . New ( nil , url , resp . StatusCode ) } return t . queue . Resume ( ctx ) }
OutputEvent tries to send a message, requeueing if is has a temporary error
OutputEvent tries to send a message requeueing if is has a temporary error
// the event was sent correctly, we now have to resume inputs if we earlier has requested a pause.