-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Network switch mangos to nats #306
base: main
Are you sure you want to change the base?
Conversation
cmd/bots/discord/discord.go
Outdated
tools.StringVarFlagWithEnv(&c.nanomsgPubSubURL, "nano-msg-pubsub-url", | ||
tools.StringVarFlagWithEnv(&c.natsPubSubURL, "nano-msg-pubsub-url", | ||
"ipc:///tmp/discord/nano-msg-nodemon-pubsub.ipc", "Nanomsg IPC URL for pubsub socket") | ||
tools.StringVarFlagWithEnv(&c.nanomsgPairURL, "nano-msg-pair-discord-url", | ||
tools.StringVarFlagWithEnv(&c.natsPairURL, "nano-msg-pair-discord-url", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also rename flag names?
if err != nil { | ||
return err | ||
} | ||
// todo fix this. send (topic, handlerFunc) into this function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO
if err != nil { | ||
return errors.Wrap(err, "failed to subscribe to alert") | ||
} | ||
// todo fix this. send (topic, handlerFunc) into this function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO
if err != nil { | ||
return errors.Wrap(err, "failed to unsubscribe from alert") | ||
} | ||
// TODO fix this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly should be fixed?
tools.StringVarFlagWithEnv(&c.nanomsgPubSubURL, "nano-msg-pubsub-url", | ||
"ipc:///tmp/nano-msg-pubsub.ipc", "Nanomsg IPC URL for pubsub socket") | ||
tools.StringVarFlagWithEnv(&c.nanomsgPairTelegramURL, "nano-msg-pair-telegram-url", | ||
"", "Nanomsg IPC URL for pair socket") | ||
tools.StringVarFlagWithEnv(&c.nanomsgPairDiscordURL, "nano-msg-pair-discord-url", | ||
"", "Nanomsg IPC URL for pair socket") | ||
tools.StringVarFlagWithEnv(&c.natsMessagingURL, "nats-msg-pubsub-url", | ||
"nats://127.0.0.1:4222", "Nats URL for pubsub socket") | ||
tools.DurationVarFlagWithEnv(&c.natsTimeout, "nats-server-timeout", | ||
server.AUTH_TIMEOUT, "Nanomsg IPC URL for pair socket") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add an option to run nats server in the nodemon
process? What do you think? Or better to have it as another process?
cmd/messaging/nats_server.go
Outdated
if !s.ReadyForConnections(cfg.connectionTimeoutDefault) { | ||
logger.Fatal("NATS server is not ready for connections") | ||
} | ||
logger.Info(fmt.Sprintf("NATS Server is running on host %v, port %d", host, port)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my mind it's better to print message as NATS Server is running on {host}:{port}
pkg/messaging/pair/server.go
Outdated
logger.Error("failed to handle bot request", zap.Error(handleErr)) | ||
return | ||
} | ||
respndErr := request.Respond(response) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
respondErr
default: | ||
logger.Error("Unknown request type", zap.Int("type", int(t)), zap.Binary("message", msg)) | ||
} | ||
return nil | ||
// nats considers a message delivered only if there was a not nil response | ||
return []byte(okMessage), nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this message can be considered as stub? What if send non nil slice instead of "ok" string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkg/messaging/helper.go
Outdated
numberOfStringsAfterSlash = 2 | ||
) | ||
|
||
func ParseHostAndPortFromURL(natsPubSubURL string) (string, int, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use url.Parse
with net.SplitHostPort
instead of this? (link)
cmd/messaging/nats_server.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add Dockerfile
for this service?
I forgot to say, that |
"ipc:///tmp/nano-msg-nodemon-pair.ipc", "Nanomsg IPC URL for pair socket") | ||
tools.StringVarFlagWithEnv(&c.natsPubSubURL, "nats-pubsub-url", | ||
"nats://127.0.0.1:4222", "NATS server URL for pubsub messaging") | ||
tools.StringVarFlagWithEnv(&c.natsPairURL, "nats-pair-discord-url", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it still necessary for discord?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can still type some commands as far as I remember
if err != nil { | ||
return err | ||
} | ||
// err := dscBot.subSocket.SetOption(mangos.OptionSubscribe, []byte{byte(alertType)}). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file you viewed is outdated
No description provided.