pub struct Ghac { /* private fields */ }
Expand description
Github Action Cache Services support.
Notes
This service is mainly provided by github actions.
Refer to Caching dependencies to speed up workflows for more informatio.
To make this service work as expected, please make sure the following environment has been setup correctly:
ACTIONS_CACHE_URL
ACTIONS_RUNTIME_TOKEN
They can be exposed by following action:
- name: Configure Cache Env
uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
To make delete
work as expected, GITHUB_TOKEN
should also be set via:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Limitations
Unlike other services, ghac doesn’t support create empty files.
We provide a enable_create_simulation()
to support this operation but may result unexpected side effects.
Also, ghac
is a cache service which means the data store inside could
be automatically evicted at any time.
Configuration
root
: Set the work dir for backend.
Refer to GhacBuilder
’s public API docs for more information.
Example
Via Builder
use std::sync::Arc;
use anyhow::Result;
use opendal::services::Ghac;
use opendal::Object;
use opendal::Operator;
#[tokio::main]
async fn main() -> Result<()> {
// Create ghac backend builder.
let mut builder = Ghac::default();
// Set the root for ghac, all operations will happen under this root.
//
// NOTE: the root must be absolute path.
builder.root("/path/to/dir");
let op: Operator = Operator::create(builder)?.finish();
// Create an object handle to start operation on object.
let _: Object = op.object("test_file");
Ok(())
}
Implementations§
source§impl GhacBuilder
impl GhacBuilder
sourcepub fn version(&mut self, version: &str) -> &mut Self
pub fn version(&mut self, version: &str) -> &mut Self
set the version that used by cache.
The version is the unique value that provides namespacing. It’s better to make sure this value is only used by this backend.
If not set, we will use opendal
as default.
sourcepub fn enable_create_simulation(&mut self) -> &mut Self
pub fn enable_create_simulation(&mut self) -> &mut Self
Enable create simulation for ghac service.
ghac service doesn’t support create empty files. By enabling create simulation, we will create a 1 byte file to represent empty file.
As a side effect, we can’t create file with only 1 byte anymore.
sourcepub fn http_client(&mut self, client: HttpClient) -> &mut Self
pub fn http_client(&mut self, client: HttpClient) -> &mut Self
Specify the http client that used by this service.
Notes
This API is part of OpenDAL’s Raw API. HttpClient
could be changed
during minor updates.