Skip to content

Commit 1ee0f1b

Browse files
authored
fix: typo (#628)
1 parent b0055e3 commit 1ee0f1b

6 files changed

Lines changed: 29 additions & 30 deletions

File tree

core/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ func (c *Client) runBackground(ctx context.Context, addr string, conn quic.Conne
138138
for {
139139
select {
140140
case <-c.ctx.Done():
141-
fs.underlying.Close()
141+
fs.Close()
142142
return
143143
case <-ctx.Done():
144-
fs.underlying.Close()
144+
fs.Close()
145145
return
146146
case f := <-c.writeFrameChan:
147147
if err := fs.WriteFrame(f); err != nil {

core/connector.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func NewConnector(ctx context.Context) *Connector {
3030
}
3131

3232
// Store stores Connection to Connector,
33-
// If the connID is the same twice, the new conntion will replace the old conntion.
33+
// If the connID is the same twice, the new connection will replace the old connection.
3434
// If Connector be closed, The function will return ErrConnectorClosed.
3535
func (c *Connector) Store(connID string, conn Connection) error {
3636
select {
@@ -44,8 +44,8 @@ func (c *Connector) Store(connID string, conn Connection) error {
4444
return nil
4545
}
4646

47-
// Remove removes the conntion with the specified connID.
48-
// If the Connector does not have a conntion with the given connID, no action is taken.
47+
// Remove removes the connection with the specified connID.
48+
// If the Connector does not have a connection with the given connID, no action is taken.
4949
// If Connector be closed, The function will return ErrConnectorClosed.
5050
func (c *Connector) Remove(connID string) error {
5151
select {
@@ -60,7 +60,7 @@ func (c *Connector) Remove(connID string) error {
6060
}
6161

6262
// Get retrieves the Connection with the specified connID.
63-
// If the Connector does not have a conntion with the given connID, return nil and false.
63+
// If the Connector does not have a connection with the given connID, return nil and false.
6464
// If Connector be closed, The function will return ErrConnectorClosed.
6565
func (c *Connector) Get(connID string) (Connection, bool, error) {
6666
select {

core/context.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package core
22

33
import (
44
"context"
5-
"errors"
65
"sync"
76
"time"
87

@@ -14,9 +13,9 @@ import (
1413

1514
var ctxPool sync.Pool
1615

17-
// Context is context for stream handling.
18-
// Context is generated subsequent to the arrival of a dataStream and retains pertinent information derived from the dataStream.
19-
// The lifespan of the Context should align with the lifespan of the Stream.
16+
// Context is context for connection handling.
17+
// Context is generated subsequent to the arrival of a connection and retains pertinent information derived from the connection.
18+
// The lifespan of the Context should align with the lifespan of the connection.
2019
type Context struct {
2120
// Connection is the connection used for reading and writing frames.
2221
Connection Connection
@@ -32,7 +31,7 @@ type Context struct {
3231
Keys map[string]any
3332
// BaseLogger is the base logger.
3433
BaseLogger *slog.Logger
35-
// Using Logger to log in stream handler scope, Logger is frame-level logger.
34+
// Using Logger to log in connection handler scope, Logger is frame-level logger.
3635
Logger *slog.Logger
3736
}
3837

@@ -87,9 +86,9 @@ func (c *Context) Value(key any) any {
8786
}
8887

8988
// newContext returns a new YoMo context that implements the standard library `context.Context` interface.
90-
// The YoMo context is used to manage the lifecycle of a connection and provides a way to pass data and metadata between stream processing functions.
91-
// The lifecycle of the context is equal to the lifecycle of the connection that it is associated with.
92-
// The context can be used to manage timeouts, cancellations, and other aspects of stream processing.
89+
// The YoMo context is used to manage the lifecycle of a connection and provides a way to pass data and metadata
90+
// between connection processing functions. The lifecycle of the context is equal to the lifecycle of the connection
91+
// that it is associated with. The context can be used to manage timeouts, cancellations, and other aspects of connection processing.
9392
func newContext(conn Connection, route router.Route, logger *slog.Logger) (c *Context) {
9493
v := ctxPool.Get()
9594
if v == nil {
@@ -116,7 +115,7 @@ func newContext(conn Connection, route router.Route, logger *slog.Logger) (c *Co
116115
func (c *Context) WithFrame(f frame.Frame) error {
117116
df, ok := f.(*frame.DataFrame)
118117
if !ok {
119-
return errors.New("connection only transmit data frame")
118+
return nil
120119
}
121120

122121
fmd, err := metadata.Decode(df.Metadata)
@@ -138,7 +137,7 @@ func (c *Context) WithFrame(f frame.Frame) error {
138137

139138
// CloseWithError close dataStream with an error string.
140139
func (c *Context) CloseWithError(errString string) {
141-
c.Logger.Debug("connection closed", "error", errString)
140+
c.Logger.Debug("connection closed", "err", errString)
142141

143142
err := c.Connection.CloseWithError(errString)
144143
if err == nil {

core/frame/frame.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
// 3. DataFrame
1616
// 4. BackflowFrame
1717
// 5. RejectedFrame
18+
// 6. GoawayFrame
1819
//
1920
// Read frame comments to understand the role of the frame.
2021
type Frame interface {
@@ -25,7 +26,7 @@ type Frame interface {
2526
// Type defined The type of frame.
2627
type Type byte
2728

28-
// DataFrame carries tagged data to transmit across DataStream.
29+
// DataFrame carries tagged data to transmit across connection.
2930
type DataFrame struct {
3031
// Metadata stores additional data beyond the Payload,
3132
// it is an map[string]string{} that be encoded in msgpack.
@@ -40,8 +41,8 @@ type DataFrame struct {
4041
func (f *DataFrame) Type() Type { return TypeDataFrame }
4142

4243
// The HandshakeFrame is the frame through which the client obtains a new connection from the server.
43-
// It include essential details required for the creation of a fresh DataStream.
44-
// The server then generates the DataStream utilizing this provided information.
44+
// It includes essential details required for the creation of a fresh connection.
45+
// The server then generates the connection utilizing this provided information.
4546
type HandshakeFrame struct {
4647
// Name is the name of the dataStream that will be created.
4748
Name string
@@ -51,9 +52,9 @@ type HandshakeFrame struct {
5152
ClientType byte
5253
// ObserveDataTags is the ObserveDataTags of the dataStream that will be created.
5354
ObserveDataTags []Tag
54-
// AuthName.
55+
// AuthName is the authentication name.
5556
AuthName string
56-
// AuthPayload.
57+
// AuthPayload is the authentication payload.
5758
AuthPayload string
5859
}
5960

@@ -67,8 +68,8 @@ type HandshakeAckFrame struct{}
6768
// Type returns the type of HandshakeAckFrame.
6869
func (f *HandshakeAckFrame) Type() Type { return TypeHandshakeAckFrame }
6970

70-
// The BackflowFrame is used to receive the processed result of a DataStream with StreamFunction type
71-
// and forward it to a DataStream with StreamSource type.
71+
// The BackflowFrame is used to receive the processed result of a connection with StreamFunction type
72+
// and forward it to a connection with StreamSource type.
7273
type BackflowFrame struct {
7374
// Tag is used for data router.
7475
Tag Tag
@@ -79,7 +80,7 @@ type BackflowFrame struct {
7980
// Type returns the type of BackflowFrame.
8081
func (f *BackflowFrame) Type() Type { return TypeBackflowFrame }
8182

82-
// RejectedFrame is used to reject a ControlStream request.
83+
// RejectedFrame is used to reject a client request.
8384
type RejectedFrame struct {
8485
// Message encapsulates the rationale behind the rejection of the request.
8586
Message string
@@ -99,7 +100,7 @@ func (f *GoawayFrame) Type() Type { return TypeGoawayFrame }
99100

100101
const (
101102
TypeDataFrame Type = 0x3F // TypeDataFrame is the type of DataFrame.
102-
TypeHandshakeFrame Type = 0x31 // TypeHandshakeFrame is the type of PayloadFrame.
103+
TypeHandshakeFrame Type = 0x31 // TypeHandshakeFrame is the type of HandshakeFrame.
103104
TypeHandshakeAckFrame Type = 0x29 // TypeHandshakeAckFrame is the type of HandshakeAckFrame.
104105
TypeRejectedFrame Type = 0x39 // TypeRejectedFrame is the type of RejectedFrame.
105106
TypeBackflowFrame Type = 0x2D // TypeBackflowFrame is the type of BackflowFrame.

core/metadata/metadata.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ import (
77

88
// M stores additional information about the application.
99
//
10-
// There are three types of metadata in yomo:
10+
// There are two types of metadata in yomo:
1111
// 1. Metadata from `Authentication.Authenticate()`, This is connection-level metadata.
12-
// 2. Metadata from the handshake, This is stream-level metadata.
13-
// 3. Metadata from the DataFrame, This is frame-level metadata.
12+
// 2. Metadata from the DataFrame, This is frame-level metadata.
1413
//
15-
// the main responsibility of Metadata is to route messages to stream functions.
14+
// the main responsibility of Metadata is to route messages to connection handler.
1615
type M map[string]string
1716

1817
// New creates an M from a given key-values map.

core/router/default_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func TestRouter(t *testing.T) {
3131
assert.NoError(t, err)
3232

3333
ids = route.GetForwardRoutes(frame.Tag(1))
34-
assert.Equal(t, []string{"conn-2", "conn-3"}, ids)
34+
assert.ElementsMatch(t, []string{"conn-2", "conn-3"}, ids)
3535

3636
router.Clean()
3737

0 commit comments

Comments
 (0)