Skip to content

Commit

Permalink
unexport client from client.go
Browse files Browse the repository at this point in the history
  • Loading branch information
armstrmi committed Feb 28, 2022
1 parent a4449c6 commit 1d48d5f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions operator/builtin/output/newrelic/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@ import (
)

// Client is an interface for sending a log payload to new relic
type Client interface {
type client interface {
SendPayload(context.Context, LogPayload) error
TestConnection(context.Context) error
}

// client is the standard implementation of the Client interface
type client struct {
type nroClient struct {
endpoint *url.URL
headers http.Header
httpClient *http.Client
}

// NewClient creates a standard client for sending logs to new relic
func NewClient(endpoint *url.URL, headers http.Header) Client {
return &client{
func newClient(endpoint *url.URL, headers http.Header) client {
return &nroClient{
endpoint: endpoint,
headers: headers,
httpClient: &http.Client{},
}
}

// SendPayload creates an http request from a log payload and sends it to new relic
func (c *client) SendPayload(ctx context.Context, payload LogPayload) error {
func (c *nroClient) SendPayload(ctx context.Context, payload LogPayload) error {
req, err := c.createRequest(ctx, payload)
if err != nil {
return fmt.Errorf("failed to create request: %w", err)
Expand All @@ -52,7 +52,7 @@ func (c *client) SendPayload(ctx context.Context, payload LogPayload) error {
}

// TestConnection tests the connection to the new relic api
func (c *client) TestConnection(ctx context.Context) error {
func (c *nroClient) TestConnection(ctx context.Context) error {
logs := make([]*LogMessage, 0, 0)
payload := LogPayload{{
Common: LogPayloadCommon{
Expand All @@ -75,7 +75,7 @@ func (c *client) TestConnection(ctx context.Context) error {
}

// createRequest creates a new http.Request with the given context and log payload
func (c *client) createRequest(ctx context.Context, payload LogPayload) (*http.Request, error) {
func (c *nroClient) createRequest(ctx context.Context, payload LogPayload) (*http.Request, error) {
var buf bytes.Buffer
wr := gzip.NewWriter(&buf)
enc := json.NewEncoder(wr)
Expand All @@ -96,7 +96,7 @@ func (c *client) createRequest(ctx context.Context, payload LogPayload) (*http.R
}

// checkResponse checks a response from the new relic api
func (c *client) checkResponse(res *http.Response) error {
func (c *nroClient) checkResponse(res *http.Response) error {
defer func() {
_ = res.Body.Close()
}()
Expand Down
4 changes: 2 additions & 2 deletions operator/builtin/output/newrelic/newrelic.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (c NewRelicOutputConfig) Build(bc operator.BuildContext) ([]operator.Operat
OutputOperator: outputOperator,
buffer: buffer,
flusher: flusher,
client: NewClient(url, headers),
client: newClient(url, headers),
timeout: c.Timeout.Raw(),
messageField: c.MessageField,
ctx: ctx,
Expand Down Expand Up @@ -109,7 +109,7 @@ type NewRelicOutput struct {
buffer buffer.Buffer
flusher *flusher.Flusher

client Client
client client
timeout time.Duration
messageField entry.Field

Expand Down

0 comments on commit 1d48d5f

Please sign in to comment.