# README
Storage Event
一、这是什么
把Storage和events结合,为Storage增加可观测性和安全执行功能。
二、安装依赖
go get -u github.com/storage-lock/go-storage-events
三、组件介绍
WithEventSafeExecutor
为Storage增加可观测性和安全执行功能
四、使用示例
package main
import (
"context"
"fmt"
"github.com/golang-infrastructure/go-iterator"
"github.com/storage-lock/go-events"
"github.com/storage-lock/go-storage"
storage_events "github.com/storage-lock/go-storage-events"
"time"
)
type FooStorage struct {
}
var _ storage.Storage = &FooStorage{}
func (x *FooStorage) GetName() string {
//TODO implement me
panic("implement me")
}
func (x *FooStorage) Init(ctx context.Context) error {
//TODO implement me
panic("implement me")
}
func (x *FooStorage) UpdateWithVersion(ctx context.Context, lockId string, exceptedVersion, newVersion storage.Version, lockInformation *storage.LockInformation) error {
//TODO implement me
panic("implement me")
}
func (x *FooStorage) CreateWithVersion(ctx context.Context, lockId string, version storage.Version, lockInformation *storage.LockInformation) error {
//TODO implement me
panic("implement me")
}
func (x *FooStorage) DeleteWithVersion(ctx context.Context, lockId string, exceptedVersion storage.Version, lockInformation *storage.LockInformation) error {
//TODO implement me
panic("implement me")
}
func (x *FooStorage) Get(ctx context.Context, lockId string) (string, error) {
//TODO implement me
panic("implement me")
}
func (x *FooStorage) GetTime(ctx context.Context) (time.Time, error) {
//TODO implement me
panic("implement me")
}
func (x *FooStorage) Close(ctx context.Context) error {
//TODO implement me
panic("implement me")
}
func (x *FooStorage) List(ctx context.Context) (iterator.Iterator[*storage.LockInformation], error) {
//TODO implement me
panic("implement me")
}
func main() {
storage := &FooStorage{}
executor := storage_events.NewWithEventSafeExecutor(storage)
event := events.NewEvent("foo").AddListeners(events.NewListenerWrapper("", func(ctx context.Context, e *events.Event) {
fmt.Print(e.ToJsonString())
}))
getTime, err := executor.GetTime(context.Background(), event)
if err != nil {
panic(err)
}
fmt.Println(getTime)
// Output:
// {"id":"storage-lock-event-eb8bffdcbf69414bb34719bfbda0147c","root_id":"storage-lock-event-eb8bffdcbf69414bb34719bfbda0147c","parent_id":"","lock_id":"foo","owner_id":"","storage_name":"","start_time":"2023-08-07T01:45:13.2932725+08:00","end_time":"2023-08-07T01:45:13.2932725+08:00","event_type":0,"actions":[{"start_time":"2023-08-07T01:45:13.293272 5+08:00","end_time":"2023-08-07T01:45:13.2932725+08:00","name":"Storage.GetTime","err":{},"payload_map":{"time":"0001-01-01T00:00:00Z"}}],"watch_dog_id":"","lock_information":null,"err":null}
//
// panic: implement me goroutine 1 [running]:
// main.main()
// D:/workspace/go-storage-events/examples/main.go:72 +0x1c8
}
# Packages
No description provided by the author
# Functions
NewWithEventSafeExecutor 从给定的Storage创建一个执行器,后面就拿着这个执行器操作而不直接操作Storage了.
# Constants
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
用于统计Storage上的方法调用行为.
action上的payload的名称,用于方便跟处理的时候统一.
action上的payload的名称,用于方便跟处理的时候统一.
action上的payload的名称,用于方便跟处理的时候统一.
action上的payload的名称,用于方便跟处理的时候统一.
action上的payload的名称,用于方便跟处理的时候统一.
action上的payload的名称,用于方便跟处理的时候统一.
action上的payload的名称,用于方便跟处理的时候统一.
action上的payload的名称,用于方便跟处理的时候统一.
action上的payload的名称,用于方便跟处理的时候统一.
# Structs
WithEventSafeExecutor 带事件观测和recover的Storage执行器.