-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Description
Hello!
I'm currently in the process of learning fp-go and am aiming to apply functional programming principles in Go. To get hands-on experience, I've taken a straightforward task: rewriting a Go function that initializes a NATS JetStream connection and subsequently creates multiple streams.
Here's the original code for context:
func Fx(lc fx.Lifecycle, natsConn *nats.Conn) FX {
lc.Append(fx.Hook{OnStart: func(ctx context.Context) error {
js, err := jetstream.New(natsConn)
if err != nil {
return err
}
if err = GetCreateEventsStream(ctx, js); err != nil {
return err
}
if err = GetCreateAlertsStream(ctx, js); err != nil {
return err
}
if err = GetCreateDLQStream(ctx, js); err != nil {
return err
}
return nil
}})
return FX{}
}Could someone guide me on the idiomatic way to rewrite this function using fp-go? I'm looking for a functional approach that would align with the paradigms and best practices of the library.
Thank you!
Metadata
Metadata
Assignees
Labels
No labels