Documentation ¶
Index ¶
- func Logformat(out io.Writer, args *log.FormatterArgs) (n int, err error)
- type Client
- func (c *Client) ConfigureMetricsClient(url, token, org, bucket string)
- func (c *Client) Delete(endpoint string, queryParams map[string]string, result interface{}) *models.APIError
- func (c *Client) Get(endpoint string, queryParams map[string]string, result interface{}) *models.APIError
- func (c *Client) GetToken() string
- func (c *Client) MetricBuilder() *metrics.MetricBuilder
- func (c *Client) Patch(endpoint string, body interface{}, queryParams map[string]string, ...) *models.APIError
- func (c *Client) Post(endpoint string, body interface{}, queryParams map[string]string, ...) *models.APIError
- func (c *Client) Put(endpoint string, body interface{}, queryParams map[string]string, ...) *models.APIError
- func (c *Client) WriteMetric(metric metrics.Metric)
- type ClientOptions
- type Glog
- type Paginator
- type RateLimiter
- type RegisterRequest
- type RegisterResponse
- type TokenFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct { AgentSymbol string MetricsReporter metrics.MetricsReporter CacheClient *cache.Cache Logger *log.Logger RateLimiter *RateLimiter // contains filtered or unexported fields }
Client represents the SpaceTraders API client
func NewClient ¶
func NewClient(options ClientOptions) (*Client, error)
NewClient creates a new instance of the SpaceTraders API client
func (*Client) ConfigureMetricsClient ¶
func (*Client) Delete ¶
func (c *Client) Delete(endpoint string, queryParams map[string]string, result interface{}) *models.APIError
Delete sends a DELETE request to the specified endpoint with optional query parameters
func (*Client) Get ¶
func (c *Client) Get(endpoint string, queryParams map[string]string, result interface{}) *models.APIError
Get sends a GET request to the specified endpoint with optional query parameters
func (*Client) MetricBuilder ¶
func (c *Client) MetricBuilder() *metrics.MetricBuilder
func (*Client) Patch ¶
func (c *Client) Patch(endpoint string, body interface{}, queryParams map[string]string, result interface{}) *models.APIError
Patch sends a PATCH request to the specified endpoint with optional query parameters
func (*Client) Post ¶
func (c *Client) Post(endpoint string, body interface{}, queryParams map[string]string, result interface{}) *models.APIError
Post sends a POST request to the specified endpoint with optional query parameters
func (*Client) Put ¶
func (c *Client) Put(endpoint string, body interface{}, queryParams map[string]string, result interface{}) *models.APIError
Put sends a PUT request to the specified endpoint with optional query parameters
func (*Client) WriteMetric ¶
type ClientOptions ¶
type ClientOptions struct { BaseURL string Symbol string Faction string Email string RequestsPerSecond float32 LogLevel log.Level RetryDelay time.Duration }
ClientOptions represents the configuration options for the SpaceTraders API client
func DefaultClientOptions ¶
func DefaultClientOptions() ClientOptions
DefaultClientOptions returns the default configuration options for the SpaceTraders API client
type Paginator ¶
type Paginator[T any] struct { Data []T Meta models.Meta // Use value instead of pointer to simplify usage Error error // contains filtered or unexported fields }
Paginator is a generic struct for pagination, where T is the type of data being paginated. It abstracts away the pagination logic, allowing users to fetch pages of data seamlessly.
func NewPaginator ¶
NewPaginator creates a new Paginator instance with default pagination parameters. fetchFunc is a function that knows how to fetch a page of data given pagination metadata.
func (*Paginator[T]) FetchAllPages ¶
FetchAllPages fetches all data at once without needing to loop over paginators.
type RateLimiter ¶ added in v0.1.17
type RateLimiter struct {
// contains filtered or unexported fields
}
func NewRateLimiter ¶ added in v0.1.17
func NewRateLimiter(staticRate, burstRate float64) *RateLimiter
type RegisterRequest ¶
type RegisterRequest struct { Faction string `json:"faction"` Symbol string `json:"symbol"` Email string `json:"email,omitempty"` }
RegisterRequest represents the request payload for registering a new agent
type RegisterResponse ¶
type RegisterResponse struct { Data struct { Agent models.Agent `json:"agent"` Contract models.Contract `json:"contract"` Faction models.Faction `json:"faction"` Ship models.Ship `json:"ship"` Token string `json:"token"` } `json:"data"` }
RegisterResponse represents the response payload for registering a new agent