Documentation
¶
Index ¶
- Variables
- type FirebaseStorage
- func (s *FirebaseStorage) Capabilities() []storage.StorageCapability
- func (s *FirebaseStorage) Close(ctx context.Context) error
- func (s *FirebaseStorage) CreateWithVersion(ctx context.Context, lockId string, version storage.Version, ...) error
- func (s *FirebaseStorage) Delete(ctx context.Context, lockId string) error
- func (s *FirebaseStorage) DeleteWithVersion(ctx context.Context, lockId string, exceptedVersion storage.Version, ...) error
- func (s *FirebaseStorage) Get(ctx context.Context, lockId string) (string, error)
- func (s *FirebaseStorage) GetName() string
- func (s *FirebaseStorage) GetTime(ctx context.Context) (time.Time, error)
- func (s *FirebaseStorage) Init(ctx context.Context) error
- func (s *FirebaseStorage) List(ctx context.Context) (iterator.Iterator[*storage.LockInformation], error)
- func (s *FirebaseStorage) Set(ctx context.Context, lockId string, lockInformation *storage.LockInformation) error
- func (s *FirebaseStorage) UpdateWithVersion(ctx context.Context, lockId string, ...) error
- func (s *FirebaseStorage) Watch(ctx context.Context, lockId string) (<-chan *storage.LockInformation, error)
- type FirebaseStorageOptions
Constants ¶
This section is empty.
Variables ¶
var ( ErrFirebaseURLRequired = errors.New("firebase database URL is required") ErrLockNotFound = storage_lock.ErrLockNotFound )
Functions ¶
This section is empty.
Types ¶
type FirebaseStorage ¶
type FirebaseStorage struct {
// contains filtered or unexported fields
}
FirebaseStorage 基于 Firebase Realtime Database 的存储实现 使用 Firebase REST API,无需认证(适用于公开规则配置的数据库)
func NewFirebaseStorage ¶
func NewFirebaseStorage(ctx context.Context, options *FirebaseStorageOptions) (*FirebaseStorage, error)
func (*FirebaseStorage) Capabilities ¶
func (s *FirebaseStorage) Capabilities() []storage.StorageCapability
Capabilities 如实声明这个实现能提供什么。
Firebase Realtime Database 的 REST API 在这里没有用上 ETag/If-Match 条件 PUT, UpdateWithVersion 是"先 GET 再 PUT",中间存在竞态窗口,因此 **不声明 CapabilityCAS**。 GetTime 返回的是本机时间,不是可信的跨节点服务端时钟,因此 **不声明 CapabilityReliableTime**。
结果是 NewStorageLock 会拒绝在它上面创建锁,这正是期望行为:宁可不可用, 也不要拿一个会误判互斥的存储去承载分布式锁。
func (*FirebaseStorage) CreateWithVersion ¶
func (s *FirebaseStorage) CreateWithVersion(ctx context.Context, lockId string, version storage.Version, lockInformation *storage.LockInformation) error
func (*FirebaseStorage) Delete ¶
func (s *FirebaseStorage) Delete(ctx context.Context, lockId string) error
func (*FirebaseStorage) DeleteWithVersion ¶
func (s *FirebaseStorage) DeleteWithVersion(ctx context.Context, lockId string, exceptedVersion storage.Version, lockInformation *storage.LockInformation) error
func (*FirebaseStorage) GetName ¶
func (s *FirebaseStorage) GetName() string
func (*FirebaseStorage) List ¶
func (s *FirebaseStorage) List(ctx context.Context) (iterator.Iterator[*storage.LockInformation], error)
func (*FirebaseStorage) Set ¶
func (s *FirebaseStorage) Set(ctx context.Context, lockId string, lockInformation *storage.LockInformation) error
func (*FirebaseStorage) UpdateWithVersion ¶
func (s *FirebaseStorage) UpdateWithVersion(ctx context.Context, lockId string, exceptedVersion, newVersion storage.Version, lockInformation *storage.LockInformation) error
func (*FirebaseStorage) Watch ¶
func (s *FirebaseStorage) Watch(ctx context.Context, lockId string) (<-chan *storage.LockInformation, error)