dataflare

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 13 Imported by: 0

README ΒΆ

Dataflare Go SDK Go Reference

Official Go client for the Dataflare API. High-concurrency, idiomatic, and performance-optimized with native channel-based streaming and gRPC.

Installation

go get github.com/dataflarelab/df-sdk/go

Quick Start (REST)

package main

import (
    "fmt"
    "github.com/dataflarelab/df-sdk/go"
)

func main() {
    client := dataflare.NewClient(&dataflare.ClientOptions{
        APIKey: "your_api_key",
    })

    // Stream a dataset using Go channels
    docChan, errChan := client.Datasets.Stream("legal", nil)

    for doc := range docChan {
        fmt.Println("Received doc:", doc.ID)
    }

    if err := <-errChan; err != nil {
        panic(err)
    }
}

gRPC Integration (High Performance)

client, _ := dataflare.NewGRPCClient("rpc.dataflare.com:443")
defer client.Close()

// Calls use gRPC reflection and binary protocol

Error Handling

The SDK provides specialized error types for robust pipeline integration:

  • dataflare.AuthenticationError: Invalid API key.
  • dataflare.RateLimitError: Request limit exceeded (automatic retries included in REST).
  • dataflare.APIError: Server-side faults.

Documentation

Full documentation is available at dataflare.com/developers.

πŸ›‘οΈ License

MIT β€” see the root LICENSE file for full terms.

Note: The SDK is free and open source. Dataflare API access requires a paid subscription. See dataflare.com/developers.

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

This section is empty.

Types ΒΆ

type APIError ΒΆ

type APIError struct {
	DFError
	StatusCode int
}

APIError is raised for general API failures (5xx).

func NewAPIError ΒΆ

func NewAPIError(msg string, code int) *APIError

type AuthenticationError ΒΆ

type AuthenticationError struct {
	DFError
}

AuthenticationError is raised when the API key is invalid or expired.

func NewAuthenticationError ΒΆ

func NewAuthenticationError(msg string) *AuthenticationError

type ClientOptions ΒΆ

type ClientOptions struct {
	APIKey  string
	BaseURL string
}

ClientOptions allows configuring the DFClient.

type DFClient ΒΆ

type DFClient struct {
	APIKey     string
	BaseURL    string
	HTTPClient *http.Client
	Datasets   *DatasetService
}

DFClient is the main REST client for the Dataflare API.

func NewClient ΒΆ

func NewClient(opts *ClientOptions) *DFClient

NewClient creates a new DFClient with the provided options.

type DFError ΒΆ

type DFError struct {
	Message string
}

DFError is the base error for all Dataflare SDK errors.

func (*DFError) Error ΒΆ

func (e *DFError) Error() string

type DFGRPCClient ΒΆ

type DFGRPCClient struct {
	APIKey string
	Target string
	Conn   *grpc.ClientConn
}

DFGRPCClient is a high-performance gRPC client for the Dataflare API.

func NewGRPCClient ΒΆ

func NewGRPCClient(target string) (*DFGRPCClient, error)

NewGRPCClient creates a new DFGRPCClient for high-performance binary streaming.

func (*DFGRPCClient) Call ΒΆ

func (c *DFGRPCClient) Call(ctx context.Context, method string, req interface{}, resp interface{}) error

Call performs a gRPC call with the API key injected into the request metadata.

func (*DFGRPCClient) Close ΒΆ

func (c *DFGRPCClient) Close() error

Close closes the gRPC connection.

type DatasetService ΒΆ

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

DatasetService handles dataset-related operations.

func (*DatasetService) Query ΒΆ

func (s *DatasetService) Query(dataset string, params map[string]interface{}) (*models.DatasetResponse, error)

Query performs a paginated query on a dataset.

func (*DatasetService) Stream ΒΆ

func (s *DatasetService) Stream(dataset string, params map[string]interface{}) (<-chan models.Document, <-chan error)

Stream performs a streaming paginated query on a dataset, returning a document channel and an error channel.

type RateLimitError ΒΆ

type RateLimitError struct {
	DFError
}

RateLimitError is raised when the request limit is exceeded.

func NewRateLimitError ΒΆ

func NewRateLimitError(msg string) *RateLimitError

Directories ΒΆ

Path Synopsis

Jump to

Keyboard shortcuts

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