api.proto 3.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
syntax = 'proto3';

package v1alpha1;

// Cache represents the metadata of a cache managed by cache pool manager.
message Cache {
    // Type represents the type of cache pool manager
    string type = 1;
    // ID represents the id of the cache and the id is unique in the same type of cache
    string ID = 2;
    // SavePath represents the absolute path to store the cache
    string savePath = 3;
    // Parent represents the parent cache of the current cache, if do not have a parent the value is nil
    Cache parent = 4;
    // Size represents the size in bytes of the cache
    int64 size = 5;
    // Created represents the creation time of the cache which is the number of seconds elapsed since January 1, 1970 UTC
    int64 created = 6;
}

// CachePoolManager represents a cache pool manager.
service CachePoolManager {
    // GetCache represents get the specified cache metadata
    rpc GetCache(GetCacheRequest) returns (GetCacheResponse) {}
    // SaveCache represents save the data to a cache directory and record the cache metadata
    rpc SaveCache(SaveCacheRequest) returns (SaveCacheResponse) {}
    // ListCache represents list part of or all of the cache metadata
    rpc ListCache(ListCacheRequest) returns (ListCacheResponse) {}
    // DeleteCache represents delete the specified cached data and remove the corresponding cache metadata
    rpc DeleteCache(DeleteCacheRequest) returns (DeleteCacheResponse) {}
    // LoadCache represents load the specified cache data to work directory
    rpc LoadCache(LoadCacheRequest) returns (LoadCacheResponse) {}
}

// GetCacheRequest
message GetCacheRequest {
    // Type represents the type of cache pool manager
    string type = 1;
    // ID represents the id of the cache
    string ID = 2;
}

message GetCacheResponse {
    // Cache represents the response cache metadata
    Cache cache = 1;
}

message SaveCacheRequest {
    // Cache represents the cache metadata needs to be saved
    Cache cache = 1;
    // SourcePath represents the absolute path of source cache data
    string sourcePath = 2;
}

message SaveCacheResponse {
    // Ok represents whether the cache is saved successfully
    bool ok = 1;
}

message ListCacheRequest {
    // Type represents the type of cache pool manager
    string type = 1;
    // LastCacheID represents the id of the last cache metadata in the most recent query list,
    // if the value is "", query the cache metadata from the starting point of DB,
    // otherwise query the cache metadata starting from the next id of `lastCacheID` in alphabetical order
    string lastCacheID = 2;
    // Limit represents the maximum number of queried entries
    int32 limit = 3;
}
message ListCacheResponse {
    // Caches represents the list of response caches
    repeated Cache caches = 1;
}

message DeleteCacheRequest {
    // Type represents the type of cache pool manager
    string type = 1;
    // ID represents the id of the cache
    string ID = 2;
}
message DeleteCacheResponse {
    // Ok represents whether the cache is deleted successfully
    bool ok = 1;
}

message LoadCacheRequest {
    // Type represents the type of cache pool manager
    string type = 1;
    // ID represents the id of the cache
    string ID = 3;
    // TargetPath represents the work directory for loading the cache data
    string targetPath = 4;
}
message LoadCacheResponse {
    // Ok represents whether the cache is loaded successfully
    bool ok = 1;
}