Skip to content

Commit c7f6517

Browse files
committed
update example
1 parent a6e67a5 commit c7f6517

File tree

7 files changed

+24
-23
lines changed

7 files changed

+24
-23
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -437,22 +437,22 @@ func init() {
437437
})
438438
}
439439

440-
// We didn't define a separate eventsystemapi package, directly using event.Dispatcher as the component's exported interface
441-
var _ event.Dispatcher[reflect.Type] = (*eventsystemComponent)(nil)
440+
// We didn't define a separate eventsystemapi package, directly using event.EventSystem as the component's exported interface
441+
var _ event.EventSystem[reflect.Type] = (*eventsystemComponent)(nil)
442442

443443
type eventsystemComponent struct {
444444
component.BaseComponent[struct {
445445
Ordered *bool
446446
}]
447-
event.Dispatcher[reflect.Type]
447+
event.EventSystem[reflect.Type]
448448
}
449449

450450
func (com *eventsystemComponent) Init(ctx context.Context) error {
451451
ordered := true
452452
if com.Options().Ordered != nil {
453453
ordered = *com.Options().Ordered
454454
}
455-
com.Dispatcher = event.NewDispatcher[reflect.Type](ordered)
455+
com.EventSystem = event.NewEventSystem[reflect.Type](ordered)
456456
return nil
457457
}
458458
```
@@ -491,7 +491,7 @@ type authComponent struct {
491491
Secret string
492492
}, struct {
493493
HTTPServer component.Reference[httpserverapi.Component]
494-
EventSystem component.Reference[event.Dispatcher[reflect.Type]]
494+
EventSystem component.Reference[event.EventSystem[reflect.Type]]
495495
}]
496496
}
497497

@@ -583,7 +583,7 @@ type usersComponent struct {
583583
MaxUsers int
584584
}, struct {
585585
HTTPServer component.Reference[httpserverapi.Component]
586-
EventSystem component.Reference[event.Dispatcher[reflect.Type]]
586+
EventSystem component.Reference[event.EventSystem[reflect.Type]]
587587
}]
588588
loggedInUsers map[string]bool
589589
}
@@ -640,7 +640,7 @@ type authComponent struct {
640640
Secret string
641641
}, struct{
642642
HTTPServer component.Reference[httpserverapi.Component]
643-
EventSystem component.Reference[event.Dispatcher[reflect.Type]]
643+
EventSystem component.Reference[event.EventSystem[reflect.Type]]
644644
}]
645645
}
646646
```
@@ -1093,4 +1093,4 @@ The Gopherd/core framework provides a powerful and flexible way to build modular
10931093

10941094
This guide covers the core concepts and usage methods of Gopherd/core, from basic component implementation to advanced features and best practices. By following these guidelines, developers can fully leverage the advantages of the Gopherd/core framework to build robust, efficient backend services.
10951095

1096-
As you delve deeper into using the framework, you'll discover more possibilities and uses. Continuous practice and exploration will help you better master Gopherd/core and maximize its potential in real projects.
1096+
As you delve deeper into using the framework, you'll discover more possibilities and uses. Continuous practice and exploration will help you better master Gopherd/core and maximize its potential in real projects.

README_ZH.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -437,22 +437,22 @@ func init() {
437437
})
438438
}
439439

440-
// 我们没有定义一个单独的 eventsystemapi 的包,直接使用了 event.Dispatcher 作为组件的导出接口
441-
var _ event.Dispatcher[reflect.Type] = (*eventsystemComponent)(nil)
440+
// 我们没有定义一个单独的 eventsystemapi 的包,直接使用了 event.EventSystem 作为组件的导出接口
441+
var _ event.EventSystem[reflect.Type] = (*eventsystemComponent)(nil)
442442

443443
type eventsystemComponent struct {
444444
component.BaseComponent[struct {
445445
Ordered *bool
446446
}]
447-
event.Dispatcher[reflect.Type]
447+
event.EventSystem[reflect.Type]
448448
}
449449

450450
func (com *eventsystemComponent) Init(ctx context.Context) error {
451451
ordered := true
452452
if com.Options().Ordered != nil {
453453
ordered = *com.Options().Ordered
454454
}
455-
com.Dispatcher = event.NewDispatcher[reflect.Type](ordered)
455+
com.EventSystem = event.NewEventSystem[reflect.Type](ordered)
456456
return nil
457457
}
458458
```
@@ -491,7 +491,7 @@ type authComponent struct {
491491
Secret string
492492
}, struct {
493493
HTTPServer component.Reference[httpserverapi.Component]
494-
EventSystem component.Reference[event.Dispatcher[reflect.Type]]
494+
EventSystem component.Reference[event.EventSystem[reflect.Type]]
495495
}]
496496
}
497497

@@ -584,7 +584,7 @@ type usersComponent struct {
584584
MaxUsers int
585585
}, struct {
586586
HTTPServer component.Reference[httpserverapi.Component]
587-
EventSystem component.Reference[event.Dispatcher[reflect.Type]]
587+
EventSystem component.Reference[event.EventSystem[reflect.Type]]
588588
}]
589589
loggedInUsers map[string]bool
590590
}
@@ -641,7 +641,7 @@ type authComponent struct {
641641
Secret string
642642
}, struct{
643643
HTTPServer component.Reference[httpserverapi.Component]
644-
EventSystem component.Reference[event.Dispatcher[reflect.Type]]
644+
EventSystem component.Reference[event.EventSystem[reflect.Type]]
645645
}]
646646
}
647647
```
@@ -1099,4 +1099,4 @@ Gopherd/core 框架提供了一种强大而灵活的方式来构建模块化的
10991099

11001100
本指南涵盖了 Gopherd/core 的核心概念和使用方法,从基本的组件实现到高级特性和最佳实践。通过遵循这些指导原则,开发者可以充分利用 Gopherd/core 框架的优势,构建出健壮、高效的后端服务。
11011101

1102-
随着你对框架的深入使用,你会发现更多的可能性和用法。不断实践和探索,将帮助你更好地掌握 Gopherd/core,并在实际项目中发挥其最大潜力。
1102+
随着你对框架的深入使用,你会发现更多的可能性和用法。不断实践和探索,将帮助你更好地掌握 Gopherd/core,并在实际项目中发挥其最大潜力。

components/auth/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type authComponent struct {
2626
Secret string
2727
}, struct {
2828
HTTPServer component.Reference[httpserverapi.Component]
29-
EventSystem component.Reference[event.Dispatcher[reflect.Type]]
29+
EventSystem component.Reference[event.EventSystem[reflect.Type]]
3030
}]
3131
}
3232

components/eventsystem/eventsystem.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,20 @@ func init() {
1616
})
1717
}
1818

19-
// 我们没有定义一个单独的 eventsystemapi 的包,直接使用了 event.Dispatcher 作为组件的导出接口
20-
var _ event.Dispatcher[reflect.Type] = (*eventsystemComponent)(nil)
19+
var _ event.EventSystem[reflect.Type] = (*eventsystemComponent)(nil)
2120

2221
type eventsystemComponent struct {
2322
component.BaseComponent[struct {
2423
Ordered *bool
2524
}]
26-
event.Dispatcher[reflect.Type]
25+
event.EventSystem[reflect.Type]
2726
}
2827

2928
func (com *eventsystemComponent) Init(ctx context.Context) error {
3029
ordered := true
3130
if com.Options().Ordered != nil {
3231
ordered = *com.Options().Ordered
3332
}
34-
com.Dispatcher = event.NewDispatcher[reflect.Type](ordered)
33+
com.EventSystem = event.NewEventSystem[reflect.Type](ordered)
3534
return nil
3635
}

components/users/users.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type usersComponent struct {
2525
MaxUsers int
2626
}, struct {
2727
HTTPServer component.Reference[httpserverapi.Component]
28-
EventSystem component.Reference[event.Dispatcher[reflect.Type]]
28+
EventSystem component.Reference[event.EventSystem[reflect.Type]]
2929
}]
3030
loggedInUsers map[string]bool
3131
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ go 1.22.4
44

55
require (
66
github.com/BurntSushi/toml v1.4.0
7-
github.com/gopherd/core v0.0.0-20240812095151-15613a2d75fd
7+
github.com/gopherd/core v0.0.0-20240817135422-69c2ff6478af
88
gopkg.in/yaml.v3 v3.0.1
99
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ github.com/gopherd/core v0.0.0-20240812074656-1640cb9f913f h1:T6CggDV5B1xtQAcYX9
44
github.com/gopherd/core v0.0.0-20240812074656-1640cb9f913f/go.mod h1:KfAPtxaKLEFiby8PpGwdgp86auCmLU82+khBzHhUTaM=
55
github.com/gopherd/core v0.0.0-20240812095151-15613a2d75fd h1:h/j6yveUloCMI/tZdl/ZIksox/pJQwmmw4fdFu6oR6o=
66
github.com/gopherd/core v0.0.0-20240812095151-15613a2d75fd/go.mod h1:KfAPtxaKLEFiby8PpGwdgp86auCmLU82+khBzHhUTaM=
7+
github.com/gopherd/core v0.0.0-20240817135422-69c2ff6478af h1:JMYoktVFhoUzviWDuCILK2izovx1a2XJ0k8fT6zmZX0=
8+
github.com/gopherd/core v0.0.0-20240817135422-69c2ff6478af/go.mod h1:KfAPtxaKLEFiby8PpGwdgp86auCmLU82+khBzHhUTaM=
79
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
810
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
911
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

0 commit comments

Comments
 (0)