Documentation ¶
Index ¶
- type DataFetcher
- func (ds *DataFetcher[T]) FetchMissingAndCombineLocal(ctx context.Context, uids []string) ([]T, error)
- func (ds *DataFetcher[T]) FetchMissingAndFillLocal(ctx context.Context, uids []string) ([]T, error)
- func (ds *DataFetcher[T]) FetchMissingAndFillLocalV2(ctx context.Context, uids []string, isEnd bool) ([]T, bool, error)
- func (ds *DataFetcher[T]) FetchWithPagination(ctx context.Context, offset, limit int) ([]T, error)
- func (ds *DataFetcher[T]) FetchWithPaginationV2(ctx context.Context, offset, limit int) ([]T, bool, error)
- type FetchDataFunc
- type FetchFromServerFunc
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 (*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 ¶
type FetchDataFunc ¶
FetchDataFunc is a function type for fetching data
Click to show internal directories.
Click to hide internal directories.