client

package
v0.0.0-...-1622575 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JSONSchema string

Functions

func MockTestHelper

func MockTestHelper(t *testing.T, table *schema.Table, builder func(*testing.T, *gomock.Controller) services.HackernewsClient, opts TestOptions)

func New

func New(logger zerolog.Logger, spec Spec, hnClient *hackernews.Client, backend state.Client) (schema.ClientMeta, error)

func UnixTimeResolver

func UnixTimeResolver(fieldName string) schema.ColumnResolver

Types

type Backend

type Backend struct {
	Table      string `json:"table"`
	Connection string `json:"connection"`
}

type Client

type Client struct {
	Spec       Spec
	HackerNews services.HackernewsClient
	Backend    state.Client
	// contains filtered or unexported fields
}

func (*Client) ID

func (*Client) ID() string

func (*Client) Logger

func (c *Client) Logger() *zerolog.Logger

func (*Client) RetryOnError

func (c *Client) RetryOnError(ctx context.Context, tableName string, f func() error) error

RetryOnError will run the given resolver function and retry on rate limit exceeded errors or other retryable errors (like internal server errors) after waiting some amount of time.

type NopBackend

type NopBackend struct{}

func (*NopBackend) Close

func (*NopBackend) Close(ctx context.Context) error

func (*NopBackend) Get

func (*NopBackend) Get(ctx context.Context, table, clientID string) (string, error)

func (*NopBackend) Set

func (*NopBackend) Set(ctx context.Context, table, clientID, value string) error

type Spec

type Spec struct {
	// The number of items to fetch concurrently
	ItemConcurrency int `json:"item_concurrency" jsonschema:"minimum=1,default=100"`
	// RFC3339 formatted timestamp. Syncing will begin with posts after this date. If not specified, the plugin will fetch all items.
	StartTime string `json:"start_time" jsonschema:"format=date-time"`
}

func (*Spec) SetDefaults

func (s *Spec) SetDefaults()

func (*Spec) Validate

func (s *Spec) Validate() error

type TestOptions

type TestOptions struct {
	StartTime time.Time
	Backend   state.Client
}

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
spec
gen

Jump to

Keyboard shortcuts

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