Operation means a single action that we can do on a storage service.
servicer is used to maintain the storage service.
Servicer to create/delete/get/list storages.
storager is the interface for storage service.
Storager to maintain objects.
We have connection string support.
The format of the connection string is (optional parts marked by squared brackets):
- name: storage name, e.g., bucket name. MUST NOT contain /
- work_dir: For object storage, it is prefix; for fs, it is directory path. MUST start with / for every storage services.
- For the
=valueis missing, we just ignore the pair. But
key=means a pair with a blank value.
keyis the pair name defined in
tomland the format SHOULD be exactly the same.
- If their are multiple pairs with the same key, the first one will be picked.
So a valid connection string could be:
For more details, take a look at GSP-90.
To use a service, do not forget to import the corresponding
go-service-* package so that the service can be registered in the
import ( _ "github.com/beyondstorage/go-service-fs/v3" "github.com/beyondstorage/go-storage/v4/services") store, err := services.NewStoragerFromString("fs:///tmp")
Alternatively, you can initialize directly with pairs, if you want to
- use a complex pair that connection string doesn't support yet or is not convenient to write by hand
- construct pairs from your config format without transforming into the connection string format
- reduce the overheads of parsing the connection string
import ( _ "github.com/beyondstorage/go-service-fs/v3" "github.com/beyondstorage/go-storage/v4/pairs" "github.com/beyondstorage/go-storage/v4/services") store, err := services.NewStorager("fs", pairs.WithWorkDir("/tmp"))