Source File
adapters.go
Belonging Package
github.com/redis/go-redis/v9
package redisimport ()// ErrInvalidCommand is returned when an invalid command is passed to ExecuteCommand.var ErrInvalidCommand = errors.New("invalid command type")// ErrInvalidPool is returned when the pool type is not supported.var ErrInvalidPool = errors.New("invalid pool type")// newClientAdapter creates a new client adapter for regular Redis clients.func newClientAdapter( *baseClient) interfaces.ClientInterface {return &clientAdapter{client: }}// clientAdapter adapts a Redis client to implement interfaces.ClientInterface.type clientAdapter struct {client *baseClient}// GetOptions returns the client options.func ( *clientAdapter) () interfaces.OptionsInterface {return &optionsAdapter{options: .client.opt}}// GetPushProcessor returns the client's push notification processor.func ( *clientAdapter) () interfaces.NotificationProcessor {return &pushProcessorAdapter{processor: .client.pushProcessor}}// optionsAdapter adapts Redis options to implement interfaces.OptionsInterface.type optionsAdapter struct {options *Options}// GetReadTimeout returns the read timeout.func ( *optionsAdapter) () time.Duration {return .options.ReadTimeout}// GetWriteTimeout returns the write timeout.func ( *optionsAdapter) () time.Duration {return .options.WriteTimeout}// GetNetwork returns the network type.func ( *optionsAdapter) () string {return .options.Network}// GetAddr returns the connection address.func ( *optionsAdapter) () string {return .options.Addr}// GetNodeAddress returns the address of the Redis node as reported by the server.// For cluster clients, this is the endpoint from CLUSTER SLOTS before any transformation.// For standalone clients, this defaults to Addr.func ( *optionsAdapter) () string {return .options.NodeAddress}// IsTLSEnabled returns true if TLS is enabled.func ( *optionsAdapter) () bool {return .options.TLSConfig != nil}// GetProtocol returns the protocol version.func ( *optionsAdapter) () int {return .options.Protocol}// GetPoolSize returns the connection pool size.func ( *optionsAdapter) () int {return .options.PoolSize}// NewDialer returns a new dialer function for the connection.func ( *optionsAdapter) () func(context.Context) (net.Conn, error) {:= .options.NewDialer()return func( context.Context) (net.Conn, error) {// Extract network and address from the options:= .options.Network:= .options.Addrreturn (, , )}}// pushProcessorAdapter adapts a push.NotificationProcessor to implement interfaces.NotificationProcessor.type pushProcessorAdapter struct {processor push.NotificationProcessor}// RegisterHandler registers a handler for a specific push notification name.func ( *pushProcessorAdapter) ( string, interface{}, bool) error {if , := .(push.NotificationHandler); {return .processor.RegisterHandler(, , )}return errors.New("handler must implement push.NotificationHandler")}// UnregisterHandler removes a handler for a specific push notification name.func ( *pushProcessorAdapter) ( string) error {return .processor.UnregisterHandler()}// GetHandler returns the handler for a specific push notification name.func ( *pushProcessorAdapter) ( string) interface{} {return .processor.GetHandler()}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |