Skip to content

Commit

Permalink
add micro module support
Browse files Browse the repository at this point in the history
  • Loading branch information
janishar committed Jun 30, 2024
1 parent 3f4ee6c commit 273624d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions arch/micro/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ type Router interface {
Disconnect()
LoadControllers(controllers []Controller)
}

type Module[T any] interface {
network.BaseModule[T]
Controllers() []Controller
}
2 changes: 1 addition & 1 deletion arch/micro/nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type NatsClient struct {
Timeout time.Duration
}

func NewNatsClient(config Config) *NatsClient {
func NewNatsClient(config *Config) *NatsClient {
fmt.Println("connecting to nats..")

nc, err := nats.Connect(config.NatsUrl)
Expand Down
2 changes: 1 addition & 1 deletion arch/micro/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type router struct {
natsClient *NatsClient
}

func NewRouter(mode string, config Config) Router {
func NewRouter(mode string, config *Config) Router {
natsClient := NewNatsClient(config)
return &router{
netRouter: network.NewRouter(mode),
Expand Down
8 changes: 6 additions & 2 deletions arch/network/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,14 @@ type Router interface {
LoadControllers(controllers []Controller)
}

type Module[T any] interface {
type BaseModule[T any] interface {
GetInstance() *T
RootMiddlewares() []RootMiddleware
Controllers() []Controller
AuthenticationProvider() AuthenticationProvider
AuthorizationProvider() AuthorizationProvider
}

type Module[T any] interface {
BaseModule[T]
Controllers() []Controller
}

0 comments on commit 273624d

Please sign in to comment.