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 : 29 : /* fd_snapshot_src_t specifies the snapshot source. */ 30 : 31 : struct fd_snapshot_src { 32 : int type; 33 : union { 34 : 35 : struct { 36 : char const * path; 37 : } file; 38 : 39 : struct { 40 : char dest[128]; 41 : uint ip4; 42 : ushort port; 43 : char const * path; 44 : ulong path_len; 45 : } http; 46 : 47 : }; 48 : }; 49 : 50 : typedef struct fd_snapshot_src fd_snapshot_src_t; 51 : 52 : FD_PROTOTYPES_BEGIN 53 : 54 : /* Constructor API for fd_snapshot_loader_t. */ 55 : 56 : ulong 57 : fd_snapshot_loader_align( void ); 58 : 59 : ulong 60 : fd_snapshot_loader_footprint( ulong zstd_window_sz ); 61 : 62 : fd_snapshot_loader_t * 63 : fd_snapshot_loader_new( void * mem, 64 : ulong zstd_window_sz ); 65 : 66 : void * 67 : fd_snapshot_loader_delete( fd_snapshot_loader_t * loader ); 68 : 69 : /* fd_snapshot_loader methods *****************************************/ 70 : 71 : /* fd_snapshot_loader_init configures a local join to the loader object 72 : to send data into the given restore object. src describes the source 73 : of the snapshot (file system or HTTPS path). */ 74 : 75 : fd_snapshot_loader_t * 76 : fd_snapshot_loader_init( fd_snapshot_loader_t * loader, 77 : fd_snapshot_restore_t * restore, 78 : fd_snapshot_src_t const * src, 79 : ulong base_slot ); 80 : 81 : /* fd_snapshot_loader_advance polls the tar reader for data. This data 82 : is synchronously passed down the pipeline (ending in a manifest 83 : callback and new funk record insertions). This is the primary 84 : polling entrypoint into fd_snapshot_loader_t. Returns 0 if advance 85 : was successful. Returns -1 on successful EOF. On failure, returns 86 : errno-compatible code and logs error. */ 87 : 88 : int 89 : fd_snapshot_loader_advance( fd_snapshot_loader_t * loader ); 90 : 91 : FD_FN_CONST fd_snapshot_name_t const * /* nullable */ 92 : fd_snapshot_loader_get_name( fd_snapshot_loader_t const * loader ); 93 : 94 : /* fd_snapshot_src_parse determines the snapshot source from the given 95 : cstr. */ 96 : 97 : fd_snapshot_src_t * 98 : fd_snapshot_src_parse( fd_snapshot_src_t * src, 99 : char * cstr ); 100 : 101 : FD_PROTOTYPES_END 102 : 103 : #endif /* HEADER_fd_src_flamenco_snapshot_fd_snapshot_loader_h */