Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultOptions() badger.Options
- type Bucket
- func (b Bucket) BatchCreate(objs []*Object) error
- func (b Bucket) Create(obj *Object) error
- func (b Bucket) Delete(q *Query) error
- func (b Bucket) DeleteByID(id string) error
- func (b Bucket) DeleteByName(name, owner string) error
- func (b Bucket) Execute(q *Query) ([]*Object, error)
- func (b Bucket) Get(q *Query) ([]*Object, error)
- func (b Bucket) GetByID(id string) (*Object, error)
- func (b Bucket) GetByName(name, owner string) (*Object, error)
- func (b Bucket) GetMeta(id string) (*Metadata, error)
- func (b Bucket) Read(id string, w io.Writer) error
- func (b Bucket) Shutdown() error
- type BucketOptions
- type CtxKey
- type HTTPHandler
- func (h *HTTPHandler) Get(w http.ResponseWriter, r *http.Request)
- func (h *HTTPHandler) Read(w http.ResponseWriter, r *http.Request)
- func (h *HTTPHandler) Remove(w http.ResponseWriter, r *http.Request)
- func (h *HTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (h *HTTPHandler) Upload(w http.ResponseWriter, r *http.Request)
- type HTTPHandlerOptions
- type MetaKey
- type Metadata
- func (m *Metadata) Compare(md *Metadata, act action) bool
- func (m Metadata) Del(k MetaKey)
- func (m Metadata) Encode() string
- func (m Metadata) Get(k MetaKey) string
- func (m Metadata) Has(k MetaKey) bool
- func (m Metadata) Marshal() ([]byte, error)
- func (m Metadata) Merge(mp map[MetaKey]string)
- func (m Metadata) Set(k MetaKey, v string)
- func (m *Metadata) Unmarshal(data []byte) error
- func (m Metadata) UserDefinedPairs() map[MetaKey]string
- type Object
- func (o *Object) BinaryMarshaler() ([]byte, error)
- func (o *Object) BinaryUnmarshaler(data []byte) error
- func (o *Object) GetMetaKey(k MetaKey) string
- func (o *Object) HasMetaKey(k MetaKey) bool
- func (o Object) ID() string
- func (o *Object) Marshal() ([]byte, error)
- func (o Object) Name() string
- func (o Object) Owner() string
- func (o Object) Payload() []byte
- func (o *Object) Read(b []byte) (int, error)
- func (o *Object) ReadFrom(r io.Reader) (int64, error)
- func (o *Object) Reset()
- func (o *Object) SetMetaKey(k MetaKey, v string)
- func (o *Object) ToModel() *objectModel
- func (o *Object) Unmarshal(data []byte) error
- func (o *Object) Write(p []byte) (int, error)
- func (o *Object) WriteTo(w io.Writer) (int64, error)
- type Query
Constants ¶
const ( // logical `Or` relationship Or action = iota + 1 // logical `And` relationship And )
const ( OperationDelete = iota + 1 OperationGet )
Variables ¶
var ( ErrContentTypeNotExist = errors.New("missing content type metadata") ErrEmptyPayload = errors.New("object doesn't contain any payload") ErrObjectIsImmutable = errors.New("object is immutable. Create a new object") ErrMustIncludeOwnerAndName = errors.New("object is immutable. Create a new object") ErrInvalidNamePattern = fmt.Errorf("object name must match the following regex pattern: %s", objectNamePattern) )
Object errors
var ( ErrMissingOwner = errors.New("missing owner in the request context") ErrUknownContentType = errors.New("content type of the file is not an official mime-type and no contentType key could be found in the form") )
HTTP errors
var ( ErrEmptyQuery = errors.New("empty query") ErrNameOwnerCtxMissing = errors.New("name is set but missing owner") )
Query errors
var (
SystemOwner = uuid.NewString()
)
Functions ¶
func DefaultOptions ¶ added in v0.10.0
func DefaultOptions() badger.Options
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
func NewBucket ¶
func NewBucket(opts BucketOptions) (*Bucket, error)
NewBucket will create a new object storage with the provided options. The `Dir` option will be overwritten by the application to have a gurantee about the data path.
func (Bucket) BatchCreate ¶
BatchCreate inserts multiple objects in an efficient way.
func (Bucket) Create ¶
Create inserts the given object into the storage. If you have to create multiple objects use `BatchCreate` which is more performant than multiple calls to Create.
func (Bucket) DeleteByID ¶
func (Bucket) DeleteByName ¶
type BucketOptions ¶ added in v0.11.0
type BucketOptions badger.Options
func NewDefaultBucketOptions ¶ added in v0.11.0
func NewDefaultBucketOptions() BucketOptions
type HTTPHandler ¶ added in v0.10.0
type HTTPHandler struct {
// contains filtered or unexported fields
}
func NewHTTPHandler ¶ added in v0.10.0
func NewHTTPHandler(bucket *Bucket, opts HTTPHandlerOptions) *HTTPHandler
func (*HTTPHandler) Get ¶ added in v0.10.0
func (h *HTTPHandler) Get(w http.ResponseWriter, r *http.Request)
Get will return the object model witht he given payload iff any object is found.
func (*HTTPHandler) Read ¶ added in v0.10.0
func (h *HTTPHandler) Read(w http.ResponseWriter, r *http.Request)
func (*HTTPHandler) Remove ¶ added in v0.10.0
func (h *HTTPHandler) Remove(w http.ResponseWriter, r *http.Request)
func (*HTTPHandler) ServeHTTP ¶ added in v0.10.0
func (h *HTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler
func (*HTTPHandler) Upload ¶ added in v0.10.0
func (h *HTTPHandler) Upload(w http.ResponseWriter, r *http.Request)
type HTTPHandlerOptions ¶ added in v0.10.0
type HTTPHandlerOptions struct { // MaxUploadSize is limiting the size of a file // which can be uploaded using the /objst/upload // endpoint. Default: 32 MB. MaxUploadSize int64 // FormKey is the key to access the file // in the multipart form. Default: "file" FormKey string // IsAuthorized is the middleware used to validate // if the incoming request is considered authorized. // By default all request will be considered authorized. // This middleware is further usedj to inject the `CtxKeyOwner` // key into the request context to set the owner. IsAuthorized func(http.Handler) http.Handler // IsAuthenticated is the middleware used to validate // if the incoming request is considered authenticated. // By default all request will be considered authenticated. IsAuthenticated func(http.Handler) http.Handler // Handler is used to serve public http traffic. // By default if the handler is nil it will be replaced // by the default handler. Handler http.Handler // Logger is the default logger. By default slog.Logger // with the text handler will be used. Logger *slog.Logger }
func DefaultHTTPHandlerOptions ¶ added in v0.10.0
func DefaultHTTPHandlerOptions() HTTPHandlerOptions
type Metadata ¶ added in v0.10.0
type Metadata struct {
// contains filtered or unexported fields
}
func NewMetadata ¶ added in v0.10.0
func NewMetadata() *Metadata
func (Metadata) Set ¶ added in v0.10.0
Set will insert the given key value pair iff it isn't a systemKey like MetaKeyID or MetaKeyCreatedAt.
func (Metadata) UserDefinedPairs ¶ added in v0.10.0
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
func (*Object) BinaryMarshaler ¶
func (*Object) BinaryUnmarshaler ¶
func (*Object) GetMetaKey ¶ added in v0.10.0
GetMeta returns the corresponding value of the provided key. The bool is indicating if the value was retrieved successfully.
func (*Object) HasMetaKey ¶
HasMetaKey check if the meta data of the object contains the given key.
func (*Object) SetMetaKey ¶ added in v0.10.0
SetMeta will set the given key and value as a meta data key-pair, over- writing any key-pair which has been set before.