Documentation
¶
Overview ¶
Package cacheservice is the legacy cache service-lifecycle adapter.
Deprecated: use github.com/faustbrian/go-cache/v2/adapters/service. This package remains supported for the longer of 180 days after successor availability and two subsequently published stable root-module minor releases.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidOptions identifies invalid adapter construction. ErrInvalidOptions = canonical.ErrInvalidOptions ErrUnavailable = canonical.ErrUnavailable )
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter[R any] struct { // contains filtered or unexported fields }
Adapter preserves the legacy service adapter type identity.
func New ¶
New validates and constructs an inert adapter.
Example ¶
value := &resource{}
adapter, err := cacheservice.New(cacheservice.Options[*resource]{
Name: "cache",
Resource: value,
Readiness: func(context.Context, *resource) error {
return nil
},
})
if err != nil {
fmt.Println("adapter setup failed")
return
}
component := adapter.Component()
_ = component.Start(context.Background())
check, _ := adapter.Readiness()
_ = check.Run(context.Background())
_ = component.Stop(context.Background())
fmt.Println(adapter.Resource() == value)
Output: true
type Options ¶
type Options[R any] struct { Name string Resource R Startup Startup[R] Readiness Check[R] Shutdown Shutdown[R] }
Options configure one cache lifecycle adapter.
type OptionsError ¶
OptionsError identifies one rejected option.
func (*OptionsError) Error ¶
func (err *OptionsError) Error() string
Error returns a secret-safe construction diagnostic.
func (*OptionsError) Unwrap ¶
func (err *OptionsError) Unwrap() error
Unwrap exposes the stable option classification.
type StartupError ¶
StartupError preserves validation and cleanup failures without formatting either potentially sensitive cause.
func (*StartupError) Error ¶
func (err *StartupError) Error() string
Error returns a secret-safe startup diagnostic.
func (*StartupError) Unwrap ¶
func (err *StartupError) Unwrap() []error
Unwrap preserves both causes for errors.Is and errors.As.