Line data Source code
1 : #ifndef HEADER_fd_src_flamenco_snapshot_fd_snapshot_loader_h 2 : #define HEADER_fd_src_flamenco_snapshot_fd_snapshot_loader_h 3 : 4 : /* fd_snapshot_loader.h provides APIs for constructing the upstream 5 : parts of the snapshot loading pipeline. 6 : 7 : read => unzstd => untar => restore 8 : ^^^^^^^^^^^^^^^^^^^^^^^ 9 : 10 : This header provides high-level APIs for streaming loading of a 11 : snapshot from the local file system or over HTTP (regular sockets). 12 : The loader is currently a single-threaded streaming pipeline. This 13 : is subject to change to the tile architecture in the future. */ 14 : 15 : #include "../snapshot/fd_snapshot.h" 16 : #include "../snapshot/fd_snapshot_restore.h" 17 : 18 : /* fd_snapshot_loader_t manages file descriptors and buffers used during 19 : snapshot load. */ 20 : 21 : struct fd_snapshot_loader; 22 : typedef struct fd_snapshot_loader fd_snapshot_loader_t; 23 : 24 : /* FD_SNAPSHOT_SRC_{...} specifies the type of snapshot source. */ 25 : 26 0 : #define FD_SNAPSHOT_SRC_FILE (1) 27 0 : #define FD_SNAPSHOT_SRC_HTTP (2) 28 0 : #define FD_SNAPSHOT_SRC_ARCHIVE (3) 29 : 30 : /* fd_snapshot_src_t specifies the snapshot source. */ 31 : 32 : struct fd_snapshot_src { 33 : int type; 34 : union { 35 : 36 : struct { 37 : char const * path; 38 : } file; 39 : 40 : struct { 41 : char dest[128]; 42 : uint ip4; 43 : ushort port; 44 : char const * path; 45 : ulong path_len; 46 : } http; 47 : 48 : }; 49 : }; 50 : 51 : typedef struct fd_snapshot_src fd_snapshot_src_t; 52 : 53 : FD_PROTOTYPES_BEGIN 54 : 55 : /* Constructor API for fd_snapshot_loader_t. */ 56 : 57 : ulong 58 : fd_snapshot_loader_align( void ); 59 : 60 : ulong 61 : fd_snapshot_loader_footprint( ulong zstd_window_sz ); 62 : 63 : fd_snapshot_loader_t * 64 : fd_snapshot_loader_new( void * mem, 65 : ulong zstd_window_sz ); 66 : 67 : void * 68 : fd_snapshot_loader_delete( fd_snapshot_loader_t * loader ); 69 : 70 : /* fd_snapshot_loader methods *****************************************/ 71 : 72 : /* fd_snapshot_loader_init configures a local join to the loader object 73 : to send data into the given restore object. src describes the source 74 : of the snapshot (file system or HTTPS path). */ 75 : 76 : fd_snapshot_loader_t * 77 : fd_snapshot_loader_init( fd_snapshot_loader_t * loader, 78 : fd_snapshot_restore_t * restore, 79 : fd_snapshot_src_t const * src, 80 : ulong base_slot ); 81 : 82 : /* fd_snapshot_loader_advance polls the tar reader for data. This data 83 : is synchronously passed down the pipeline (ending in a manifest 84 : callback and new funk record insertions). This is the primary 85 : polling entrypoint into fd_snapshot_loader_t. Returns 0 if advance 86 : was successful. Returns -1 on successful EOF. On failure, returns 87 : errno-compatible code and logs error. */ 88 : 89 : int 90 : fd_snapshot_loader_advance( fd_snapshot_loader_t * loader ); 91 : 92 : FD_FN_CONST fd_snapshot_name_t const * /* nullable */ 93 : fd_snapshot_loader_get_name( fd_snapshot_loader_t const * loader ); 94 : 95 : /* fd_snapshot_src_parse determines the snapshot source from the given 96 : cstr. */ 97 : 98 : fd_snapshot_src_t * 99 : fd_snapshot_src_parse( fd_snapshot_src_t * src, 100 : char * cstr ); 101 : 102 : FD_PROTOTYPES_END 103 : 104 : #endif /* HEADER_fd_src_flamenco_snapshot_fd_snapshot_loader_h */