58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
package store
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
type LayerOptions map[string]any
|
|
|
|
type LayerRepository interface {
|
|
CreateLayer(ctx context.Context, proxyName ProxyName, layerName LayerName, layerType LayerType, options LayerOptions) (*Layer, error)
|
|
UpdateLayer(ctx context.Context, proxyName ProxyName, layerName LayerName, options LayerOptions) error
|
|
DeleteLayer(ctx context.Context, proxyName ProxyName, layerName LayerName) error
|
|
GetLayer(ctx context.Context, proxyName ProxyName, layerName LayerName) (*Layer, error)
|
|
QueryLayers(ctx context.Context, funcs ...QueryLayerOptionFunc) ([]*LayerHeader, error)
|
|
}
|
|
|
|
type QueryLayerOptionFunc func(*QueryLayerOptions)
|
|
|
|
type QueryLayerOptions struct {
|
|
From []string
|
|
Offset *int
|
|
Limit *int
|
|
|
|
Type *LayerType
|
|
Name *LayerName
|
|
Proxy *ProxyName
|
|
}
|
|
|
|
func WithLayerQueryOffset(offset int) QueryLayerOptionFunc {
|
|
return func(o *QueryLayerOptions) {
|
|
o.Offset = &offset
|
|
}
|
|
}
|
|
|
|
func WithLayerQueryLimit(limit int) QueryLayerOptionFunc {
|
|
return func(o *QueryLayerOptions) {
|
|
o.Limit = &limit
|
|
}
|
|
}
|
|
|
|
func WithLayerQueryType(layerType LayerType) QueryLayerOptionFunc {
|
|
return func(o *QueryLayerOptions) {
|
|
o.Type = &layerType
|
|
}
|
|
}
|
|
|
|
func WithLayerQueryName(layerName LayerName) QueryLayerOptionFunc {
|
|
return func(o *QueryLayerOptions) {
|
|
o.Name = &layerName
|
|
}
|
|
}
|
|
|
|
func WithLayerQueryProxy(proxyName ProxyName) QueryLayerOptionFunc {
|
|
return func(o *QueryLayerOptions) {
|
|
o.Proxy = &proxyName
|
|
}
|
|
}
|