Project: iSulad (Runtime / Container Runtime)
File: image_store_design.md

Author | | | | | | Date | 2020-03-27 | | Email | | Image module provides functions to store and obtain images information, including the following functions: Read operation: query whether the image exists obtain image information according to ID or name return image ID according to image name obtain all image information obtain image information according to Digest load and reload the stored content from disk read and have the specified ID Associated metadata read-only big-data related methods (get big-data content, size, digest, names) Write operation: create image set image name delete image records clear all image records set image pull time add image name, store image information to disk update metadata associated with specified ID store big-data ```mermaid classDiagram class ImageStore class ROImageStore <<interface>> ROImageStore class DataStructure <<member>> DataStructure ImageStore : +image_create ImageStore : +imagesetnames ImageStore : +image_delete ImageStore : +image_wipe ImageStore : +imagesetloaded_time ImageStore : +imageaddname ImageStore : +save ImageStore : +imagesetmetadata ImageStore : +imagesetbig_data ROImageStore : +image_exists ROImageStore : +image_get ROImageStore : +image_lookup ROImageStore : +images ROImageStore : +imagebydigest ROImageStore : +image_load ROImageStore : +image_metadata ROImageStore : +imagebigdata_size ROImageStore : +imagebigdata_digest ROImageStore : +imagebigdata_names DataStructure : mapt *imagelock DataStructure : pthreadmutext lock DataStructure : char *dir DataStructure : imagestoreimages images DataStructure : sizet imageslen DataStructure : map_t *idindex DataStructure : map_t *byid DataStructure : map_t *byname DataStructure : map_t *bydigest DataStructure : bool loaded ImageStore <|-- ROImageStore ImageStore <|-- DataStructure ``` | Function | int newimagestore(bool daemon, bool readonly, const char dir, image_store_t image_store) | | | | | Effect | traverse the json file in the image directory, load the metadata of the image and add it to image_store | | Input parameter | bool daemon, bool readonly, const char *dir | | Output parameter | imagestoret *image_store | | Return value | success: 0 failure: -1 | | Function | int (create)(const char id, const char names, sizet nameslen, const char layer, const char metadata, timestamp time, const char searchable_digest, image_store_t imagestore, imagestorage_images *image); | | :-: | | | Effect | generate image metadata based on input, add it to image_store and persist it to disk | | Input parameter | const char id, const char names, size_t names_len, const char layer, const char metadata, timestamp time, const char searchabledigest, imagestoret *imagestore | | Output parameter | imagestorageimages *image | | Return value | success: 0 failure: -1 | | Function | int (set_names)(const char id, const char names, sizet nameslen, imagestoret *image_store); | | :-: | | | Effect | set the name list of the image according to the input, add it to the image_store and persist it to disk | | Input parameter | const char id, const char names, size_t names_len, image_store_t image_store | | Output parameter | NA | | Return value | success: 0 failure: -1 | | Function | int (delete)(const char id, imagestoret *image_store); | | :-: | - | | Effect | remove image id from image_store memory and delete related files from disk | | Input parameter | const char id, image_store_t image_store | | Output parameter | NA | | Return value | success: 0 failure: -1 | | Function | int (wipe)(image_store_t image_store); | | :-: | | | Effect | delete all images from image_store memory and delete related files from disk | | Input parameter | imagestoret *image_store | | Output parameter | NA | | Return value | success: 0 failure: -1 | | Function | int (set_loaded_time)(const char id, timestamp loaded, imagestoret *image_store); | | :-: | | | Effect | set the load time