http_fetcher

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HttpFetcher

type HttpFetcher struct {
	Endpoint   string
	Categories map[string]map[string]stored_requests.Category
	// contains filtered or unexported fields
}

func NewFetcher

func NewFetcher(client *http.Client, endpoint string) *HttpFetcher

NewFetcher returns a Fetcher which uses the Client to pull data from the endpoint.

This file expects the endpoint to satisfy the following API:

Stored requests GET {endpoint}?request-ids=["req1","req2"]&imp-ids=["imp1","imp2","imp3"]

Accounts GET {endpoint}?account-ids=["acc1","acc2"]

The above endpoints should return a payload like:

{
  "requests": {
    "req1": { ... stored data for req1 ... },
    "req2": { ... stored data for req2 ... },
  },
  "imps": {
    "imp1": { ... stored data for imp1 ... },
    "imp2": { ... stored data for imp2 ... },
    "imp3": null // If imp3 is not found
  }
}

or

{
  "accounts": {
    "acc1": { ... config data for acc1 ... },
    "acc2": { ... config data for acc2 ... },
  },
}

func (*HttpFetcher) FetchAccount

func (fetcher *HttpFetcher) FetchAccount(ctx context.Context, accountDefaultsJSON json.RawMessage, accountID string) (accountJSON json.RawMessage, errs []error)

FetchAccount fetchers a single accountID and returns its corresponding json

func (*HttpFetcher) FetchAccounts

func (fetcher *HttpFetcher) FetchAccounts(ctx context.Context, accountIDs []string) (map[string]json.RawMessage, []error)

FetchAccounts retrieves account configurations

Request format is similar to the one for requests: GET {endpoint}?account-ids=["account1","account2",...]

The endpoint is expected to respond with a JSON map with accountID -> json.RawMessage

{
  "account1": { ... account json ... }
}

The JSON contents of account config is returned as-is (NOT validated)

func (*HttpFetcher) FetchCategories

func (fetcher *HttpFetcher) FetchCategories(ctx context.Context, primaryAdServer, publisherId, iabCategory string) (string, error)

func (*HttpFetcher) FetchRequests

func (fetcher *HttpFetcher) FetchRequests(ctx context.Context, requestIDs []string, impIDs []string) (requestData map[string]json.RawMessage, impData map[string]json.RawMessage, errs []error)

func (*HttpFetcher) FetchResponses

func (fetcher *HttpFetcher) FetchResponses(ctx context.Context, ids []string) (data map[string]json.RawMessage, errs []error)

Jump to

Keyboard shortcuts

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