Skip to content

Commit

Permalink
docs: 'Note', 'Notes' -> NOTE
Browse files Browse the repository at this point in the history
Change-Id: Iac32585b4da5d3bc8480a61b112b24d7c2485b34
  • Loading branch information
andeya committed Dec 10, 2018
1 parent 4315f98 commit 3492695
Show file tree
Hide file tree
Showing 25 changed files with 88 additions and 88 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ type (
// Version returns the protocol's id and name.
Version() (byte, string)
// Pack writes the Message into the connection.
// Note: Make sure to write only once or there will be package contamination!
// NOTE: Make sure to write only once or there will be package contamination!
Pack(*Message) error
// Unpack reads bytes from the connection to the Message.
// Note: Concurrent unsafe!
// NOTE: Concurrent unsafe!
Unpack(*Message) error
}
ProtoFunc func(io.ReadWriter) Proto
Expand Down Expand Up @@ -329,7 +329,7 @@ func Get(id byte) (XferFilter, error)
func GetByName(name string) (XferFilter, error)

// XferPipe transfer filter pipe, handlers from outer-most to inner-most.
// Note: the length can not be bigger than 255!
// NOTE: the length can not be bigger than 255!
type XferPipe struct {
// Has unexported fields.
}
Expand Down
6 changes: 3 additions & 3 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@ type (
// Version returns the protocol's id and name.
Version() (byte, string)
// Pack writes the Message into the connection.
// Note: Make sure to write only once or there will be package contamination!
// NOTE: Make sure to write only once or there will be package contamination!
Pack(*Message) error
// Unpack reads bytes from the connection to the Message.
// Note: Concurrent unsafe!
// NOTE: Concurrent unsafe!
Unpack(*Message) error
}
ProtoFunc func(io.ReadWriter) Proto
Expand Down Expand Up @@ -330,7 +330,7 @@ func Get(id byte) (XferFilter, error)
func GetByName(name string) (XferFilter, error)

// XferPipe transfer filter pipe, handlers from outer-most to inner-most.
// Note: the length can not be bigger than 255!
// NOTE: the length can not be bigger than 255!
type XferPipe struct {
// Has unexported fields.
}
Expand Down
10 changes: 5 additions & 5 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TypeText(typ byte) string {
}

// Internal Framework Rerror code.
// Note: Recommended custom code is greater than 1000.
// NOTE: Recommended custom code is greater than 1000.
// unknown error code: -1.
// sender peer error code range: [100,199].
// message handling error code range: [400,499].
Expand Down Expand Up @@ -162,7 +162,7 @@ func WithRealIp(ip string) MessageSetting {
}

// WithAcceptBodyCodec sets the body codec that the sender wishes to accept.
// Note: If the specified codec is invalid, the receiver will ignore the mate data.
// NOTE: If the specified codec is invalid, the receiver will ignore the mate data.
func WithAcceptBodyCodec(bodyCodec byte) MessageSetting {
if bodyCodec == codec.NilCodecId {
return func(*Message) {}
Expand All @@ -171,7 +171,7 @@ func WithAcceptBodyCodec(bodyCodec byte) MessageSetting {
}

// GetAcceptBodyCodec gets the body codec that the sender wishes to accept.
// Note: If the specified codec is invalid, the receiver will ignore the mate data.
// NOTE: If the specified codec is invalid, the receiver will ignore the mate data.
func GetAcceptBodyCodec(meta *utils.Args) (byte, bool) {
s := meta.Peek(MetaAcceptBodyCodec)
if len(s) == 0 || len(s) > 3 {
Expand Down Expand Up @@ -269,7 +269,7 @@ var WithNewBody = socket.WithNewBody
var WithXferPipe = socket.WithXferPipe

// GetMessage gets a *Message form message stack.
// Note:
// NOTE:
// newBodyFunc is only for reading form connection;
// settings are only for writing to connection.
// func GetMessage(settings ...MessageSetting) *Message
Expand All @@ -286,7 +286,7 @@ var (
)

// SetGopool set or reset go pool config.
// Note: Make sure to call it before calling NewPeer() and Go()
// NOTE: Make sure to call it before calling NewPeer() and Go()
func SetGopool(maxGoroutinesAmount int, maxGoroutineIdleDuration time.Duration) {
_maxGoroutinesAmount, _maxGoroutineIdleDuration := maxGoroutinesAmount, maxGoroutineIdleDuration
if _gopool != nil {
Expand Down
14 changes: 7 additions & 7 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

// PeerConfig peer config
// Note:
// NOTE:
// yaml tag is used for github.com/henrylee2cn/cfgo
// ini tag is used for github.com/henrylee2cn/ini
type PeerConfig struct {
Expand Down Expand Up @@ -120,36 +120,36 @@ var SetReadLimit = socket.SetMessageSizeLimit

// SetSocketKeepAlive sets whether the operating system should send
// keepalive messages on the connection.
// Note: If have not called the function, the system defaults are used.
// NOTE: If have not called the function, the system defaults are used.
// func SetSocketKeepAlive(keepalive bool)
var SetSocketKeepAlive = socket.SetKeepAlive

// SetSocketKeepAlivePeriod sets period between keep alives.
// Note: if d<0, don't change the value.
// NOTE: if d<0, don't change the value.
// func SetSocketKeepAlivePeriod(d time.Duration)
var SetSocketKeepAlivePeriod = socket.SetKeepAlivePeriod

// SocketReadBuffer returns the size of the operating system's
// receive buffer associated with the connection.
// Note: if using the system default value, bytes=-1 and isDefault=true.
// NOTE: if using the system default value, bytes=-1 and isDefault=true.
// func SocketReadBuffer() (bytes int, isDefault bool)
var SocketReadBuffer = socket.ReadBuffer

// SetSocketReadBuffer sets the size of the operating system's
// receive buffer associated with the connection.
// Note: if bytes<0, don't change the value.
// NOTE: if bytes<0, don't change the value.
// func SetSocketReadBuffer(bytes int)
var SetSocketReadBuffer = socket.SetReadBuffer

// SocketWriteBuffer returns the size of the operating system's
// transmit buffer associated with the connection.
// Note: if using the system default value, bytes=-1 and isDefault=true.
// NOTE: if using the system default value, bytes=-1 and isDefault=true.
// func SocketWriteBuffer() (bytes int, isDefault bool)
var SocketWriteBuffer = socket.WriteBuffer

// SetSocketWriteBuffer sets the size of the operating system's
// transmit buffer associated with the connection.
// Note: if bytes<0, don't change the value.
// NOTE: if bytes<0, don't change the value.
// func SetSocketWriteBuffer(bytes int)
var SetSocketWriteBuffer = socket.SetWriteBuffer

Expand Down
16 changes: 8 additions & 8 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,23 +697,23 @@ type (
// Done returns the chan that indicates whether it has been completed.
Done() <-chan struct{}
// Reply returns the call reply.
// Notes:
// NOTE:
// Inside, <-Done() is automatically called and blocked,
// until the call is completed!
Reply() (interface{}, *Rerror)
// InputBodyCodec gets the body codec type of the input message.
// Notes:
// NOTE:
// Inside, <-Done() is automatically called and blocked,
// until the call is completed!
InputBodyCodec() byte
// InputMeta returns the header metadata of input message.
// Notes:
// NOTE:
// Inside, <-Done() is automatically called and blocked,
// until the call is completed!
InputMeta() *utils.Args
// CostTime returns the called cost time.
// If PeerConfig.CountTime=false, always returns 0.
// Notes:
// NOTE:
// Inside, <-Done() is automatically called and blocked,
// until the call is completed!
CostTime() time.Duration
Expand Down Expand Up @@ -805,7 +805,7 @@ func (c *callCmd) Done() <-chan struct{} {
}

// Reply returns the call reply.
// Notes:
// NOTE:
// Inside, <-Done() is automatically called and blocked,
// until the call is completed!
func (c *callCmd) Reply() (interface{}, *Rerror) {
Expand All @@ -814,7 +814,7 @@ func (c *callCmd) Reply() (interface{}, *Rerror) {
}

// InputBodyCodec gets the body codec type of the input message.
// Notes:
// NOTE:
// Inside, <-Done() is automatically called and blocked,
// until the call is completed!
func (c *callCmd) InputBodyCodec() byte {
Expand All @@ -823,7 +823,7 @@ func (c *callCmd) InputBodyCodec() byte {
}

// InputMeta returns the header metadata of input message.
// Notes:
// NOTE:
// Inside, <-Done() is automatically called and blocked,
// until the call is completed!
func (c *callCmd) InputMeta() *utils.Args {
Expand All @@ -833,7 +833,7 @@ func (c *callCmd) InputMeta() *utils.Args {

// CostTime returns the called cost time.
// If PeerConfig.CountTime=false, always returns 0.
// Notes:
// NOTE:
// Inside, <-Done() is automatically called and blocked,
// until the call is completed!
func (c *callCmd) CostTime() time.Duration {
Expand Down
2 changes: 1 addition & 1 deletion graceful.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func Shutdown(timeout ...time.Duration) {
}

// Reboot all the frame process gracefully.
// Notes: Windows system are not supported!
// NOTE: Windows system are not supported!
func Reboot(timeout ...time.Duration) {
graceful.Reboot(timeout...)
}
Expand Down
2 changes: 1 addition & 1 deletion log.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ var loggerOutputter = func() LoggerOutputter {
}()

// SetLoggerOutputter sets logger outputter.
// Note: Concurrent is not safe!
// NOTE: Concurrent is not safe!
func SetLoggerOutputter(outputter LoggerOutputter) {
loggerOutputter = outputter
}
Expand Down
4 changes: 2 additions & 2 deletions mixer/multiclient/multiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (c *MultiClient) AsyncCall(
}

// Call sends a message and receives reply.
// Note:
// NOTE:
// If the arg is []byte or *[]byte type, it can automatically fill in the body codec name;
// If the session is a client role and PeerConfig.RedialTimes>0, it is automatically re-called once after a failure.
func (c *MultiClient) Call(uri string, arg interface{}, result interface{}, setting ...tp.MessageSetting) tp.CallCmd {
Expand All @@ -96,7 +96,7 @@ func (c *MultiClient) Call(uri string, arg interface{}, result interface{}, sett
}

// Push sends a message, but do not receives reply.
// Note:
// NOTE:
// If the arg is []byte or *[]byte type, it can automatically fill in the body codec name;
// If the session is a client role and PeerConfig.RedialTimes>0, it is automatically re-called once after a failure.
func (c *MultiClient) Push(uri string, arg interface{}, setting ...tp.MessageSetting) *tp.Rerror {
Expand Down
4 changes: 2 additions & 2 deletions mixer/websocket/jsonSubProto/jsonSubProto.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (j *jsonSubProto) Version() (byte, string) {
const format = `{"seq":%q,"mtype":%d,"uri":%q,"meta":%q,"body_codec":%d,"body":"%s","xfer_pipe":%s}`

// Pack writes the Message into the connection.
// Note: Make sure to write only once or there will be package contamination!
// NOTE: Make sure to write only once or there will be package contamination!
func (j *jsonSubProto) Pack(m *tp.Message) error {
// marshal body
bodyBytes, err := m.MarshalBody()
Expand Down Expand Up @@ -80,7 +80,7 @@ func (j *jsonSubProto) Pack(m *tp.Message) error {
}

// Unpack reads bytes from the connection to the Message.
// Note: Concurrent unsafe!
// NOTE: Concurrent unsafe!
func (j *jsonSubProto) Unpack(m *tp.Message) error {
j.rMu.Lock()
defer j.rMu.Unlock()
Expand Down
4 changes: 2 additions & 2 deletions mixer/websocket/pbSubProto/pbSubProto.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (psp *pbSubProto) Version() (byte, string) {
}

// Pack writes the Message into the connection.
// Note: Make sure to write only once or there will be package contamination!
// NOTE: Make sure to write only once or there will be package contamination!
func (psp *pbSubProto) Pack(m *tp.Message) error {
// marshal body
bodyBytes, err := m.MarshalBody()
Expand Down Expand Up @@ -66,7 +66,7 @@ func (psp *pbSubProto) Pack(m *tp.Message) error {
}

// Unpack reads bytes from the connection to the Message.
// Note: Concurrent unsafe!
// NOTE: Concurrent unsafe!
func (psp *pbSubProto) Unpack(m *tp.Message) error {
psp.rMu.Lock()
defer psp.rMu.Unlock()
Expand Down
4 changes: 2 additions & 2 deletions mixer/websocket/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (w *wsProto) Version() (byte, string) {
}

// Pack writes the Message into the connection.
// Note: Make sure to write only once or there will be package contamination!
// NOTE: Make sure to write only once or there will be package contamination!
func (w *wsProto) Pack(m *tp.Message) error {
w.subConn.w.Reset()
err := w.subProto.Pack(m)
Expand All @@ -80,7 +80,7 @@ func (w *wsProto) Pack(m *tp.Message) error {
}

// Unpack reads bytes from the connection to the Message.
// Note: Concurrent unsafe!
// NOTE: Concurrent unsafe!
func (w *wsProto) Unpack(m *tp.Message) error {
err := ws.Message.Receive(w.conn, w.subConn.rBytes)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ type (
// DialContext connects with the peer of the destination address, using the provided context.
DialContext(ctx context.Context, addr string, protoFunc ...ProtoFunc) (Session, *Rerror)
// ServeConn serves the connection and returns a session.
// Note:
// NOTE:
// Not support automatically redials after disconnection;
// Execute the PostAcceptPlugin plugins.
ServeConn(conn net.Conn, protoFunc ...ProtoFunc) (Session, error)
// ServeListener serves the listener.
// Note: The caller ensures that the listener supports graceful shutdown.
// NOTE: The caller ensures that the listener supports graceful shutdown.
ServeListener(lis net.Listener, protoFunc ...ProtoFunc) error
}
)
Expand Down Expand Up @@ -324,7 +324,7 @@ func (p *peer) renewSessionForClient(sess *session, dialFunc func() (net.Conn, e
}

// ServeConn serves the connection and returns a session.
// Note:
// NOTE:
// Not support automatically redials after disconnection;
// Execute the PostAcceptPlugin plugins.
func (p *peer) ServeConn(conn net.Conn, protoFunc ...ProtoFunc) (Session, error) {
Expand All @@ -347,7 +347,7 @@ func (p *peer) ServeConn(conn net.Conn, protoFunc ...ProtoFunc) (Session, error)
var ErrListenClosed = errors.New("listener is closed")

// ServeListener serves the listener.
// Note: The caller ensures that the listener supports graceful shutdown.
// NOTE: The caller ensures that the listener supports graceful shutdown.
func (p *peer) ServeListener(lis net.Listener, protoFunc ...ProtoFunc) error {
defer lis.Close()
p.listeners[lis] = struct{}{}
Expand Down
2 changes: 1 addition & 1 deletion plugin/binder/binder.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ var (
)

// SetErrorFunc sets the binding or balidating error function.
// Note: If fn=nil, set as default.
// NOTE: If fn=nil, set as default.
func (s *StructArgsBinder) SetErrorFunc(fn ErrorFunc) {
if fn != nil {
s.errFunc = fn
Expand Down
6 changes: 3 additions & 3 deletions plugin/secure/secure.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,21 @@ func NewSecurePlugin(rerrCode int32, cipherkey string) tp.Plugin {
}

// EnforceSecure enforces the body of the encrypted reply message.
// Note: requires that the secure plugin has been registered!
// NOTE: requires that the secure plugin has been registered!
func EnforceSecure(output *tp.Message) {
output.Meta().Set(SECURE_META_KEY, "true")
}

// WithSecureMeta encrypts the body of the current message.
// Note: requires that the secure plugin has been registered!
// NOTE: requires that the secure plugin has been registered!
func WithSecureMeta() tp.MessageSetting {
return func(message *tp.Message) {
message.Meta().Set(SECURE_META_KEY, "true")
}
}

// WithAcceptSecureMeta requires the peer to encrypt the replying body.
// Note: requires that the secure plugin has been registered!
// NOTE: requires that the secure plugin has been registered!
func WithAcceptSecureMeta(accept bool) tp.MessageSetting {
s := fmt.Sprintf("%v", accept)
return func(message *tp.Message) {
Expand Down
4 changes: 2 additions & 2 deletions proto/jsonproto/jsonproto.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (j *jsonproto) Version() (byte, string) {
const format = `{"seq":%q,"mtype":%d,"uri":%q,"meta":%q,"body_codec":%d,"body":"%s"}`

// Pack writes the Message into the connection.
// Note: Make sure to write only once or there will be package contamination!
// NOTE: Make sure to write only once or there will be package contamination!
func (j *jsonproto) Pack(m *tp.Message) error {
// marshal body
bodyBytes, err := m.MarshalBody()
Expand Down Expand Up @@ -95,7 +95,7 @@ func (j *jsonproto) Pack(m *tp.Message) error {
}

// Unpack reads bytes from the connection to the Message.
// Note: Concurrent unsafe!
// NOTE: Concurrent unsafe!
func (j *jsonproto) Unpack(m *tp.Message) error {
j.rMu.Lock()
defer j.rMu.Unlock()
Expand Down
4 changes: 2 additions & 2 deletions proto/pbproto/pbproto.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (pp *pbproto) Version() (byte, string) {
}

// Pack writes the Message into the connection.
// Note: Make sure to write only once or there will be package contamination!
// NOTE: Make sure to write only once or there will be package contamination!
func (pp *pbproto) Pack(m *tp.Message) error {
// marshal body
bodyBytes, err := m.MarshalBody()
Expand Down Expand Up @@ -90,7 +90,7 @@ func (pp *pbproto) Pack(m *tp.Message) error {
}

// Unpack reads bytes from the connection to the Message.
// Note: Concurrent unsafe!
// NOTE: Concurrent unsafe!
func (pp *pbproto) Unpack(m *tp.Message) error {
pp.rMu.Lock()
defer pp.rMu.Unlock()
Expand Down
Loading

0 comments on commit 3492695

Please sign in to comment.