mirror of
https://github.com/gookit/event
synced 2025-09-26 19:11:14 +08:00
⬆️ dep: upgrade actions checkout to v5, up goutil to v0.7.1
- add run ci test on go1.22+ # Conflicts: # .github/workflows/go.yml # go.mod # go.sum
This commit is contained in:
11
.github/workflows/go.yml
vendored
11
.github/workflows/go.yml
vendored
@@ -18,11 +18,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
go_version: [1.19, '1.20', 1.21, 1.22, 1.23, 1.24]
|
||||
go_version: [1.19, 1.21, 1.22, 1.23, 1.24, 1.25]
|
||||
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
# https://github.com/actions/setup-go
|
||||
- name: Use Go ${{ matrix.go_version }}
|
||||
timeout-minutes: 3
|
||||
@@ -36,12 +36,12 @@ jobs:
|
||||
run: go test -coverprofile="profile.cov" ./...
|
||||
|
||||
- name: Send coverage
|
||||
uses: shogo82148/actions-goveralls@v1.9.1
|
||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||
uses: shogo82148/actions-goveralls@v1
|
||||
with:
|
||||
path-to-profile: profile.cov
|
||||
flag-name: Go-${{ matrix.go_version }}
|
||||
parallel: true
|
||||
shallow: true # 忽略请求报错
|
||||
|
||||
# notifies that all test jobs are finished.
|
||||
# https://github.com/shogo82148/actions-goveralls
|
||||
@@ -49,6 +49,7 @@ jobs:
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: shogo82148/actions-goveralls@v1.9.1
|
||||
- uses: shogo82148/actions-goveralls@v1
|
||||
with:
|
||||
shallow: true
|
||||
parallel-finished: true
|
||||
|
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Go Faster
|
||||
uses: WillAbides/setup-go-faster@v1.14.0
|
||||
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -15,7 +15,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
18
README.md
18
README.md
@@ -39,9 +39,10 @@ go get github.com/gookit/event
|
||||
- `On/Listen(name string, listener Listener, priority ...int)` Register event listener
|
||||
- `Subscribe/AddSubscriber(sbr Subscriber)` Subscribe to support registration of multiple event listeners
|
||||
- `Trigger/Fire(name string, params M) (error, Event)` Trigger event by name and params
|
||||
- `FireCtx(ctx context.Context, name string, params M) (error, Event)` Trigger event with context
|
||||
- `MustTrigger/MustFire(name string, params M) Event` Trigger event, there will be panic if there is an error
|
||||
- `FireEvent(e Event) (err error)` Trigger an event based on a given event instance
|
||||
- `FireBatch(es ...interface{}) (ers []error)` Trigger multiple events at once
|
||||
- `FireBatch(es ...any) (ers []error)` Trigger multiple events at once
|
||||
- `Async/FireC(name string, params M)` Push event to `chan`, asynchronous consumption processing
|
||||
- `FireAsync(e Event)` Push event to `chan`, asynchronous consumption processing
|
||||
- `AsyncFire(e Event)` Async fire event by 'go' keywords
|
||||
@@ -253,7 +254,7 @@ type Subscriber interface {
|
||||
// SubscribedEvents register event listeners
|
||||
// key: is event name
|
||||
// value: can be Listener or ListenerItem interface
|
||||
SubscribedEvents() map[string]interface{}
|
||||
SubscribedEvents() map[string]any
|
||||
}
|
||||
```
|
||||
|
||||
@@ -274,8 +275,8 @@ type MySubscriber struct {
|
||||
// ooo
|
||||
}
|
||||
|
||||
func (s *MySubscriber) SubscribedEvents() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
func (s *MySubscriber) SubscribedEvents() map[string]any {
|
||||
return map[string]any{
|
||||
"e1": event.ListenerFunc(s.e1Handler),
|
||||
"e2": event.ListenerItem{
|
||||
Priority: event.AboveNormal,
|
||||
@@ -304,11 +305,10 @@ you can implement the `event.Event` interface.
|
||||
// Event interface
|
||||
type Event interface {
|
||||
Name() string
|
||||
// Target() interface{}
|
||||
Get(key string) interface{}
|
||||
Add(key string, val interface{})
|
||||
Set(key string, val interface{})
|
||||
Data() map[string]interface{}
|
||||
Get(key string) any
|
||||
Add(key string, val any)
|
||||
Set(key string, val any)
|
||||
Data() map[string]any
|
||||
SetData(M) Event
|
||||
Abort(bool)
|
||||
IsAborted() bool
|
||||
|
@@ -39,7 +39,7 @@ go get github.com/gookit/event
|
||||
- `Trigger/Fire(name string, params M) (error, Event)` 触发事件
|
||||
- `MustTrigger/MustFire(name string, params M) Event` 触发事件,有错误则会panic
|
||||
- `FireEvent(e Event) (err error)` 根据给定的事件实例,触发事件
|
||||
- `FireBatch(es ...interface{}) (ers []error)` 一次触发多个事件
|
||||
- `FireBatch(es ...any) (ers []error)` 一次触发多个事件
|
||||
- `Async/FireC(name string, params M)` 投递事件到 `chan`,异步消费处理
|
||||
- `FireAsync(e Event)` 投递事件到 `chan`,异步消费处理
|
||||
- `AsyncFire(e Event)` 简单的通过 `go` 异步触发事件
|
||||
@@ -249,7 +249,7 @@ type Subscriber interface {
|
||||
// SubscribedEvents register event listeners
|
||||
// key: is event name
|
||||
// value: can be Listener or ListenerItem interface
|
||||
SubscribedEvents() map[string]interface{}
|
||||
SubscribedEvents() map[string]any
|
||||
}
|
||||
```
|
||||
|
||||
@@ -270,8 +270,8 @@ type MySubscriber struct {
|
||||
// ooo
|
||||
}
|
||||
|
||||
func (s *MySubscriber) SubscribedEvents() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
func (s *MySubscriber) SubscribedEvents() map[string]any {
|
||||
return map[string]any{
|
||||
"e1": event.ListenerFunc(s.e1Handler),
|
||||
"e2": event.ListenerItem{
|
||||
Priority: event.AboveNormal,
|
||||
@@ -299,11 +299,10 @@ func (s *MySubscriber) e1Handler(e event.Event) error {
|
||||
// Event interface
|
||||
type Event interface {
|
||||
Name() string
|
||||
// Target() interface{}
|
||||
Get(key string) interface{}
|
||||
Add(key string, val interface{})
|
||||
Set(key string, val interface{})
|
||||
Data() map[string]interface{}
|
||||
Get(key string) any
|
||||
Add(key string, val any)
|
||||
Set(key string, val any)
|
||||
Data() map[string]any
|
||||
SetData(M) Event
|
||||
Abort(bool)
|
||||
IsAborted() bool
|
||||
|
2
go.mod
2
go.mod
@@ -2,7 +2,7 @@ module github.com/gookit/event
|
||||
|
||||
go 1.19
|
||||
|
||||
require github.com/gookit/goutil v0.7.0
|
||||
require github.com/gookit/goutil v0.7.1
|
||||
|
||||
require (
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
|
4
go.sum
4
go.sum
@@ -1,5 +1,5 @@
|
||||
github.com/gookit/goutil v0.7.0 h1:HD4PUDW2LOSKIEBJPFD8PzNGLsL46ztpfXWVU+WtAxk=
|
||||
github.com/gookit/goutil v0.7.0/go.mod h1:vJS9HXctYTCLtCsZot5L5xF+O1oR17cDYO9R0HxBmnU=
|
||||
github.com/gookit/goutil v0.7.1 h1:AaFJPN9mrdeYBv8HOybri26EHGCC34WJVT7jUStGJsI=
|
||||
github.com/gookit/goutil v0.7.1/go.mod h1:vJS9HXctYTCLtCsZot5L5xF+O1oR17cDYO9R0HxBmnU=
|
||||
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
|
||||
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
||||
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
|
Reference in New Issue
Block a user