Documentation ¶
Overview ¶
Package gocosi is a Container Object Storage Interface (COSI) library that simplifies process of writing your own Object Storage Plugin (OSP).
## Quick Start
The following example illustrates using `gocosi` Object Storage Plugin bootstrapper to create a new COSI Object Storage Plugin from scratch:
go run \ github.com/doomshrine/gocosi/cmd/bootstrap@main \ -module example.com/your/cosi-osp \ -dir cosi-osp
You will obtain the following file structure in the `cosi-osp` folder:
cosi-osp ├── go.mod ├── go.sum ├── main.go └── servers ├── identity │ └── identity.go └── provisioner └── provisioner.go 4 directories, 5 files
Index ¶
- Constants
- Variables
- func HealthcheckFunc(ctx context.Context, addr string) error
- func SetLogger(l logr.Logger)
- type COSIIdentityServer
- type COSIProvisionerServer
- type Driver
- type Endpoint
- type ErrHealthCheckFailure
- type ExporterKind
- type Option
- func WithCOSIEndpoint(url *url.URL) Option
- func WithDefaultGRPCOptions() Option
- func WithDefaultMetricExporter(kind ExporterKind) Option
- func WithDefaultTraceExporter(kind ExporterKind) Option
- func WithGRPCMetricExporter(opt ...otlpmetricgrpc.Option) Option
- func WithGRPCOptions(opts ...grpc.ServerOption) Option
- func WithGRPCTraceExporter(opt ...otlptracegrpc.Option) Option
- func WithHTTPMetricExporter(opt ...otlpmetrichttp.Option) Option
- func WithHTTPTraceExporter(opt ...otlptracehttp.Option) Option
- func WithHealthcheck(options ...health.Option) Option
- func WithSocketGroup(group *user.Group) Option
- func WithSocketPermissions(perm os.FileMode) Option
- func WithSocketUser(user *user.User) Option
Constants ¶
const ( SchemeUNIX = "unix" SchemeTCP = "tcp" )
Schemes supported by COSI.
const ( // CosiEndpoint is the name of the environment variable used to // specify the COSI endpoint. EnvCOSIEndpoint = "COSI_ENDPOINT" // EnvVarEndpointPerms is the name of the environment variable used // to specify the file permissions for the COSI endpoint when it is // a UNIX socket file. This setting has no effect if COSI_ENDPOINT // specifies a TCP socket. The default value is 0755. EnvCOSIEndpointPerms = "X_COSI_ENDPOINT_PERMS" // EnvVarEndpointUser is the name of the environment variable used // to specify the UID or name of the user that owns the endpoint's // UNIX socket file. This setting has no effect if COSI_ENDPOINT // specifies a TCP socket. The default value is the user that starts // the process. EnvCOSIEndpointUser = "X_COSI_ENDPOINT_USER" // EnvVarEndpointGroup is the name of the environment variable used // to specify the GID or name of the group that owns the endpoint's // UNIX socket file. This setting has no effect if COSI_ENDPOINT // specifies a TCP socket. The default value is the group that starts // the process. EnvCOSIEndpointGroup = "X_COSI_ENDPOINT_GROUP" )
const ( // HealthcheckEndpoint is the HTTP endpoint path for the healthcheck service. HealthcheckEndpoint = "/healthz" // HealthcheckAddr. HealthcheckAddr = "http://localhost:8080" + HealthcheckEndpoint )
Variables ¶
var ( ErrNilMux = errors.New("nil mux") ErrHealthcheckStatusUnknown = errors.New("healthcheck status unknown") )
var ( DefaultMeter = otel.Meter("github.com/doomshrine/gocosi") PanicsTotal = must.Do(DefaultMeter.Int64Counter("grpc_req_panics_recovered_total")) )
Functions ¶
func HealthcheckFunc ¶ added in v0.3.0
HealthcheckFunc.
Types ¶
type COSIIdentityServer ¶
type COSIIdentityServer interface { cosi.IdentityServer }
COSIIdentityServer is a wrapper around cosi.IdentityServer so the mock can be generated.
type COSIProvisionerServer ¶
type COSIProvisionerServer interface { cosi.ProvisionerServer }
COSIProvisionerServer is a wrapper around cosi.ProvisionerServer so the mock can be generated.
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver represents a COSI driver implementation.
type Endpoint ¶
type Endpoint struct {
// contains filtered or unexported fields
}
Endpoint represents COSI Endpoint.
type ErrHealthCheckFailure ¶ added in v0.3.0
type ErrHealthCheckFailure struct {
// contains filtered or unexported fields
}
func (*ErrHealthCheckFailure) Error ¶ added in v0.3.0
func (err *ErrHealthCheckFailure) Error() string
type ExporterKind ¶ added in v0.2.0
type ExporterKind int
ExporterKind is an enumeration representing different exporter types.
const ( // HTTPExporter represents an HTTP telemetry exporter. HTTPExporter ExporterKind = iota // GRPCExporter represents a gRPC telemetry exporter. GRPCExporter ExporterKind = iota )
type Option ¶
Option represents a functional option to configure the Driver.
func WithCOSIEndpoint ¶
WithCOSIEndpoint overrides the default COSI endpoint.
func WithDefaultGRPCOptions ¶
func WithDefaultGRPCOptions() Option
WithGRPCOptions overrides all previously applied gRPC ServerOptions by a default options.
Default gRPC SeverOptions are: - ChainUnaryInterceptor - consists of:
- grpc.UnaryServerInterceptor() - starts and configures tracer for each request, records events for request and response (error is recorded as normal event);
- logging.UnaryServerInterceptor() - records and logs according to the global logger (wrapped around grpc/log.Logger);
- recovery.UnaryServerInterceptor() - records metric for panics, and recovers (a log is created for each panic);
func WithDefaultMetricExporter ¶ added in v0.2.0
func WithDefaultMetricExporter(kind ExporterKind) Option
WithDefaultMetricExporter returns an Option function to set the default metric exporter based on the provided kind.
func WithDefaultTraceExporter ¶ added in v0.2.0
func WithDefaultTraceExporter(kind ExporterKind) Option
WithDefaultTraceExporter returns an Option function to set the default trace exporter based on the provided kind.
func WithGRPCMetricExporter ¶ added in v0.2.0
func WithGRPCMetricExporter(opt ...otlpmetricgrpc.Option) Option
WithGRPCMetricExporter returns an Option function to configure a gRPC metric exporter.
func WithGRPCOptions ¶
func WithGRPCOptions(opts ...grpc.ServerOption) Option
WithGRPCOptions overrides all previously applied gRPC ServerOptions by a set provided as argument to this call.
func WithGRPCTraceExporter ¶ added in v0.2.0
func WithGRPCTraceExporter(opt ...otlptracegrpc.Option) Option
WithGRPCTraceExporter returns an Option function to configure a gRPC trace exporter.
func WithHTTPMetricExporter ¶ added in v0.2.0
func WithHTTPMetricExporter(opt ...otlpmetrichttp.Option) Option
WithHTTPMetricExporter returns an Option function to configure an HTTP metric exporter.
func WithHTTPTraceExporter ¶ added in v0.2.0
func WithHTTPTraceExporter(opt ...otlptracehttp.Option) Option
WithHTTPTraceExporter returns an Option function to configure an HTTP trace exporter.
func WithHealthcheck ¶ added in v0.3.0
func WithHealthcheck(options ...health.Option) Option
WithHealthcheck returns an Option function that sets up a healthcheck service for the driver. It accepts options for configuring the healthcheck service.
func WithSocketGroup ¶
WithSocketGroup is used to override default group owning the socket (current user's group).
func WithSocketPermissions ¶
WithSocketPermissions is used to override default permissions (0o660). Permissions that are being set must be between:
- 0o600 - the minimum permissions
- 0o766 - the maximum permissions
func WithSocketUser ¶
WithSocketUser is used to override default user owning the socket (current user).