Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrorReqUnsuccessful = errors.New("request was not successful")
View Source
var ErrorRetriesExhausted = errors.New("retries have been exhausted")
Functions ¶
func NewDuneClient ¶
NewDuneClient instantiates a new stateless DuneAPI client. Env contains information about the API key and target host (which shouldn't be changed, unless you want to run it through a custom proxy).
func NewExecution ¶
func NewExecution(client DuneClient, ID string) *execution
NewExecution is used to instantiate a new execution object given an Dune client object and existing execution ID. It is used to run further interactions with the execution, e.g. retrieve its status, get results, cancel, etc.
Types ¶
type DuneClient ¶
type DuneClient interface {
// New APIs to read results in a more flexible way
// returns the results or status of an execution, depending on whether it has completed
QueryResultsV2(executionID string, options models.ResultOptions) (*models.ResultsResponse, error)
// returns the results of a QueryID, depending on whether it has completed
ResultsByQueryID(queryID string, options models.ResultOptions) (*models.ResultsResponse, error)
// RunQueryGetRows submits a query for execution and returns an Execution object
RunQuery(queryID int, queryParameters map[string]any) (Execution, error)
// RunQueryGetRows submits a query for execution, blocks until execution is finished, and returns just the result rows
RunQueryGetRows(queryID int, queryParameters map[string]any) ([]map[string]any, error)
// QueryCancel cancels the execution of an execution in the pending or executing state
QueryCancel(executionID string) error
// QueryExecute submits a query to execute with the provided parameters
QueryExecute(queryID int, queryParameters map[string]any) (*models.ExecuteResponse, error)
// QueryStatus returns the current execution status
QueryStatus(executionID string) (*models.StatusResponse, error)
// QueryResults returns the results or status of an execution, depending on whether it has completed
// DEPRECATED, use QueryResultsV2 instead
QueryResults(executionID string) (*models.ResultsResponse, error)
// QueryResultsCSV returns the results of an execution, as CSV text stream if the execution has completed
QueryResultsCSV(executionID string) (io.Reader, error)
// QueryResultsByQueryID returns the results of the lastest execution for a given query ID
// DEPRECATED, use ResultsByQueryID instead
QueryResultsByQueryID(queryID string) (*models.ResultsResponse, error)
// QueryResultsCSVByQueryID returns the results of the lastest execution for a given query ID
// as CSV text stream if the execution has completed
QueryResultsCSVByQueryID(queryID string) (io.Reader, error)
}
DuneClient represents all operations available to call externally
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
type Execution ¶
type Execution interface {
// QueryCancel cancels the execution
Cancel() error
// GetResults returns the results or status of the execution, depending on whether it has completed
GetResults() (*models.ResultsResponse, error)
// GetResultsCSV returns the results in CSV format
GetResultsCSV() (io.Reader, error)
// QueryStatus returns the current execution status
GetStatus() (*models.StatusResponse, error)
// GetResultsV2 returns the results or status of the execution, depending on whether it has completed
// it uses options to refine futher what results to get
GetResultsV2(options models.ResultOptions) (*models.ResultsResponse, error)
// RunQueryGetResults blocks until the execution is finished and returns the result
// maxRetries is used when using the RunQueryToCompletion method, to limit the number of times the method
// will tolerate API errors before giving up. A value of zero will disable the retry limit.
// It is recommended to set this to something non-zero, as there is a risk that this will block indefinitely
// if the Dune API is unreachable or returns an error. The pollInterval determines how long to wait between
// GetResult requests. It is recommended to set to at least 5 seconds to prevent rate-limiting.
WaitGetResults(pollInterval time.Duration, maxRetries int) (*models.ResultsResponse, error)
// GetID returns the execution ID
GetID() string
}
Click to show internal directories.
Click to hide internal directories.