diff --git a/api/client.go b/api/client.go index 9157af0..ad01497 100644 --- a/api/client.go +++ b/api/client.go @@ -11,7 +11,7 @@ import ( type handler func([]byte) -// Client reads and decodes messages from a reader and posts thems to a go channel +// Client reads and decodes messages from a reader and posts them to a go channel type Client struct { reader Reader decoder message.Decoder @@ -35,6 +35,7 @@ func (c *Client) Channel() <-chan any { return c.channel } +// Helper method to post a message to a channel with timeout. func (c *Client) post(msg any) { select { case <-time.After(time.Second): @@ -46,7 +47,7 @@ func (c *Client) worker(channel Channel, h handler) { for { payload, err := c.reader.Read(channel) if err != nil { - // Dont report EOF as an error because it is used + // Don't report EOF as an error because it is used // by readers to signal an graceful end of input. if err != io.EOF { c.post(err) @@ -59,7 +60,7 @@ func (c *Client) worker(channel Channel, h handler) { } // Helper method to decode a message and post and error on the channel if it fails. -// Returns true if successfull. false otherwise +// Returns true if successful. False otherwise func (c *Client) decode(payload []byte, msg any) bool { if err := c.decoder(payload, msg); err != nil { c.post(err) @@ -152,7 +153,7 @@ func (c *Client) Run() { func (c *Client) Close() error { err := c.reader.Close() - // Wait for all goroutines before closing channel. + // Wait for all goroutines to finish before closing channel. c.wg.Wait() close(c.channel) return err diff --git a/api/message/msgpack/codec.go b/api/message/msgpack/codec.go index 2e684a6..ce16975 100644 --- a/api/message/msgpack/codec.go +++ b/api/message/msgpack/codec.go @@ -14,7 +14,7 @@ func createCodec() message.Codec { handle.MapType = reflect.TypeOf(map[string]any(nil)) handle.Canonical = true - // Wierd name but this is needed for the newest version of msgpack + // Weird name but this is needed for the newest version of msgpack // that has support for time and string datatypes etc. handle.WriteExt = true diff --git a/api/reader.go b/api/reader.go index 21b4be7..5dd719e 100644 --- a/api/reader.go +++ b/api/reader.go @@ -6,7 +6,7 @@ package api // This is a low-level interface typically implemented by backend drivers type Reader interface { // Read a message from a channel. - // Read may block until a message is ready or an error occured. + // Read may block until a message is ready or an error occurred. // // io.EOF is returned from a reader when there is no more data to be read. // If Read returns io.EOF all subsequent calls must also return io.EOF diff --git a/api/redis/namespace.go b/api/redis/namespace.go index 4e0167c..d02d579 100644 --- a/api/redis/namespace.go +++ b/api/redis/namespace.go @@ -19,7 +19,7 @@ const ( // // Contains a prefix and chain_id to guard keys against collision. // Prefix should be sufficient to not collide with other application using the same redis database. -// chain_id should be ok to not let multiple reader with different chains to write to the same channels. +// chain_id should be fine to not let multiple reader with different chains to write to the same channels. type Namespace struct { Prefix string diff --git a/api/redis/subscriber.go b/api/redis/subscriber.go index 07218ba..c8c7099 100644 --- a/api/redis/subscriber.go +++ b/api/redis/subscriber.go @@ -48,7 +48,7 @@ func NewSubscriber(ctx context.Context, client *redis.Client, ns Namespace, opti return sub } -// worker reads messages from redis pubsub and forwards them to +// worker reads messages from Redis pubsub and forwards them to // correct channels. func (s *Subscriber) worker() { for msg := range s.sub.Channel() { diff --git a/internal/config/cli.go b/internal/config/cli.go index a23794a..3b22223 100644 --- a/internal/config/cli.go +++ b/internal/config/cli.go @@ -7,6 +7,7 @@ import ( "github.com/spf13/pflag" ) +// Get a flag set with all flags mapping to a config value. func GetFlags() *pflag.FlagSet { flags := pflag.FlagSet{} diff --git a/internal/server/message_queue.go b/internal/server/message_queue.go index 50386ec..da46da5 100644 --- a/internal/server/message_queue.go +++ b/internal/server/message_queue.go @@ -13,7 +13,7 @@ type MessageQueue struct { // Writer to write messages to writer driver.Writer - // encoder to encode messages with + // Encoder to encode messages with encode message.Encoder }