queueapi

package
v0.0.0-...-9a2a36c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package queueapi provides a client for the queue-api ingest endpoint.

Index

Constants

View Source
const DefaultMaxRetries = 4

DefaultMaxRetries is the maximum number of retry attempts for ingest endpoint failures.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a client for the queue-api ingest endpoint.

func NewClient

func NewClient(baseURL, authToken string) *Client

NewClient creates a new queue-api client.

Parameters:

  • baseURL: The base URL of the queue-api (e.g., "http://queue-api:8080")
  • authToken: Optional bearer token for authentication (can be empty)

Returns:

  • A configured Client ready for use

func (*Client) PostResolution

func (c *Client) PostResolution(ctx context.Context, email, githubUsername string) error

PostResolution posts a resolution to the ingest endpoint with retry logic.

This method calls the queue-api's /email-resolution/resolve endpoint with the provided email and github username. The source is set to "live" and the resolved_at timestamp is set to the current time.

Retry logic:

  • Implements exponential backoff with: 100ms, 400ms, 900ms, 1600ms delays
  • Maximum retry attempts: 4 (total max delay: ~3 seconds)
  • Retries on transient network errors and timeout errors
  • Does not retry on client errors (4xx) except 408 Request Timeout
  • Logs all retry attempts with structured error context

The queue claim remains valid during retries since the total retry duration is short (~3 seconds max), which is well within the worker's processing window.

Parameters:

  • ctx: Context for the request (cancellation is respected during retries)
  • email: The email address to resolve
  • githubUsername: The resolved GitHub username

Returns:

  • nil on success
  • error if all retry attempts are exhausted or a non-retryable error occurs

func (*Client) SetLogger

func (c *Client) SetLogger(logger *ingestlog.Logger)

SetLogger sets a custom ingest logger for the client. If not set, a default logger writing to stderr is used.

type ResolutionRequest

type ResolutionRequest struct {
	Email       string `json:"email"`
	GithubLogin string `json:"github_login"`
	Source      string `json:"source"`
	ResolvedAt  string `json:"resolved_at"` // ISO 8601 timestamp
}

ResolutionRequest represents a request to the email resolution ingest endpoint.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL