datafetcher

package
v3.8.1-rc.20 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataFetcher

type DataFetcher[T any] struct {
	TableName string
	EntityID  string
	Key       func(T) string

	FetchFromLocal FetchDataFunc[T]
	// contains filtered or unexported fields
}

DataFetcher is a struct that handles data synchronization

func NewDataFetcher

func NewDataFetcher[T any](db db_interface.VersionSyncModel, tableName string, entityID string, key func(T) string,
	batchInsert func(ctx context.Context, servers []T) error, fetchFromLocal FetchDataFunc[T], fetchFromServer FetchFromServerFunc[T]) *DataFetcher[T]

NewDataFetcher creates a new NewDataFetcher

func (*DataFetcher[T]) FetchMissingAndCombineLocal

func (ds *DataFetcher[T]) FetchMissingAndCombineLocal(ctx context.Context, uids []string) ([]T, error)

FetchMissingAndCombineLocal fetches missing data from the server and combines it with local data without inserting it into the local database

func (*DataFetcher[T]) FetchMissingAndFillLocal

func (ds *DataFetcher[T]) FetchMissingAndFillLocal(ctx context.Context, uids []string) ([]T, error)

FetchMissingAndFillLocal fetches missing data from server and fills local database

func (*DataFetcher[T]) FetchMissingAndFillLocalV2

func (ds *DataFetcher[T]) FetchMissingAndFillLocalV2(ctx context.Context, uids []string, isEnd bool) ([]T, bool, error)

func (*DataFetcher[T]) FetchWithPagination

func (ds *DataFetcher[T]) FetchWithPagination(ctx context.Context, offset, limit int) ([]T, error)

FetchWithPagination fetches data with pagination and fills missing data from server

func (*DataFetcher[T]) FetchWithPaginationV2

func (ds *DataFetcher[T]) FetchWithPaginationV2(ctx context.Context, offset, limit int) ([]T, bool, error)

type FetchDataFunc

type FetchDataFunc[T any] func(ctx context.Context, uids []string) ([]T, bool, error)

FetchDataFunc is a function type for fetching data

type FetchFromServerFunc

type FetchFromServerFunc[T any] func(ctx context.Context, uids []string) ([]T, error)

FetchFromServerFunc is a function type for fetching data from server

Jump to

Keyboard shortcuts

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