harbor run -t openthoughts/tasktrove-exp-rpt-stack-go-v4-stack-go-0219harbor download openthoughts/tasktrove-exp-rpt-stack-go-v4-stack-go-0219Implement the snowflakeChunkDownloader struct and its associated functionality in the /app/ directory based on the provided test cases. This struct should manage the downloading of chunks of data from a Snowflake database and handle various scenarios, including successful downloads, retry logic on errors, and appropriate error handling.
Struct Definition:
snowflakeChunkDownloader with the following fields:
sc: A pointer to a Snowflake connection struct.ctx: A context.Context for request cancellation.Total: An int64 representing the total number of rows to download.ChunkMetas: A slice of execResponseChunk structs describing the metadata of each chunk.TotalRowIndex: An int64 initialized to -1 that tracks the total number of rows indexed.Qrmk: A string used for request marking.Chunks: A map where each entry has an int key (chunk index) associated with a slice of chunkRowType.ChunksMutex: A pointer to a sync.Mutex for thread-safe access to the Chunks map.DoneDownloadCond: A synchronization condition variable.ChunksError: A channel to send errors encountered during downloading.FuncDownload: A function type responsible for downloading each chunk of data.Method Implementation:
start() method for snowflakeChunkDownloader that initializes concurrent downloading of chunks.maxChunkDownloaderErrorCounter).Error Handling:
ChunksError channel).Testing:
gosnowflake package. These include tests for successful downloads, handling of error responses, and retry mechanisms.Documentation:
The completed implementation should reside in the /app/ directory and fully comply with the structure and behavior expected as per the provided test cases.
Important: declare your solution in package gosnowflake (the test file uses package gosnowflake, so the implementation must use the matching package name).