Skip to content

Commit

Permalink
godoc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
calbera committed Aug 6, 2024
1 parent fb5fc84 commit 92929ec
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
2 changes: 1 addition & 1 deletion benchmarks/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewClient(cfg *Config, logger retryablehttp.LeveledLogger) (*Client, error)
}, nil
}

// Shutdown gracefully shuts down the Pythnet Hermes client.
// Shutdown gracefully shuts down the Pyth Benchmarks client.
func (c *Client) Shutdown() {
c.client.HTTPClient.CloseIdleConnections()
}
3 changes: 3 additions & 0 deletions benchmarks/price_updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import (
"github.com/calbera/go-pyth-client/feeds"
)

// GetHistoricalPriceUpdatesSync queries the `v1/updates/price/{timestamp}` endpoint for all price
// feed IDs together. Takes the price feed keys (uses corresponding Pyth feed ID). Returns the Pyth
// PriceFeed struct and the price feed update data for each pair.
func (c *Client) GetHistoricalPriceUpdatesSync(
_ context.Context, timestamp time.Time, priceFeeds ...string,
) (map[string]*apyth.PythStructsPriceFeed, error) {
Expand Down
31 changes: 26 additions & 5 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,50 @@ import (
"github.com/calbera/go-pyth-client/types"
)

// Benchmarks is the interface that wraps the methods of the benchmarks.Client.
// Benchmarks is the interface of the Benchmarks client.
type Benchmarks interface {
// Queries the `v1/updates/price/{timestamp}` endpoint for all price feed IDs together. Takes
// the price feed keys (uses corresponding Pyth feed ID). Returns the Pyth PriceFeed struct
// and the price feed update data for each pair.
GetHistoricalPriceUpdatesSync(
ctx context.Context, timestamp time.Time, priceFeeds ...string,
) (map[string]*apyth.PythStructsPriceFeed, error)

// Shutdown gracefully shuts down the Pyth Benchmarks client.
Shutdown()
}

// NewBenchmarks creates a new Pyth Benchmarks client.
var NewBenchmarks = benchmarks.NewClient

// Hermes is the interface that wraps the methods of the hermes.Client.
// Hermes is the interface of the Hermes client.
type Hermes interface {
GetCachedLatestPriceUpdates(
ctx context.Context, priceFeeds ...string,
) (map[string]*types.LatestPriceData, error)
// Queries the `v2/updates/price/latest` endpoint for each price feed individually, in
// parallel. Takes the price feed keys (uses corresponding Pyth feed ID). Returns the Pyth
// PriceFeed struct and the price feed update data for each pair.
GetLatestPriceUpdatesAsync(
ctx context.Context, priceFeeds ...string,
) (map[string]*types.LatestPriceData, error)

// Queries the `v2/updates/price/latest` endpoint for all price feed ID together. Takes the
// price feed keys (uses corresponding Pyth feed ID). Returns the Pyth PriceFeed struct and the
// price feed update data for each pair.
GetLatestPriceUpdatesSync(
ctx context.Context, priceFeeds ...string,
) (map[string]*types.LatestPriceData, error)

// Subscribe price feed from the streaming `v2/updates/price/stream` endpoint. Ensures this
// only happens once in the scope of runtime. Any further calls to this are unnecessary and
// no-ops.
SubscribePriceStreaming(ctx context.Context, priceFeeds ...string)

// Queries cached price feed update data, obtained from the SSE streaming endpoint.
// Returns the Pyth PriceFeed struct and the price feed update data for each pair.
GetCachedLatestPriceUpdates(
ctx context.Context, priceFeeds ...string,
) (map[string]*types.LatestPriceData, error)

// Gracefully shuts down the Pyth Hermes client.
Shutdown()
}

Expand Down
6 changes: 3 additions & 3 deletions hermes/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/calbera/go-pyth-client/types"
)

// Client is a client for the Pythnet Hermes API (https://hermes.pyth.network/docs)
// Client is a client for the Pyth Hermes API (https://hermes.pyth.network/docs)
type Client struct {
// Config for Pyth and HTTP calls.
cfg *Config
Expand All @@ -33,7 +33,7 @@ type Client struct {
subscribeOnce sync.Once
}

// NewClient creates a client for the Pythnet Hermes API.
// NewClient creates a client for the Pyth Hermes API.
func NewClient(cfg *Config, logger retryablehttp.LeveledLogger) (*Client, error) {
// Ensure the given configuration is valid.
if err := cfg.Validate(); err != nil {
Expand Down Expand Up @@ -67,7 +67,7 @@ func NewClient(cfg *Config, logger retryablehttp.LeveledLogger) (*Client, error)
}, nil
}

// Shutdown gracefully shuts down the Pythnet Hermes client.
// Shutdown gracefully shuts down the Pyth Hermes client.
func (c *Client) Shutdown() {
c.client.HTTPClient.CloseIdleConnections()
}
Expand Down

0 comments on commit 92929ec

Please sign in to comment.