Repository: cloudwego/kitex
File: server/option.go (Go)

Code before:
		di.Push(fmt.Sprintf("WithPayloadCodec(%+v)", c))

		o.RemoteOpt.PayloadCodec = c
	}}
}

// WithRegistry to set a Registry to register service
func WithRegistry(r registry.Registry) Option {
	return Option{F: func(o *internal_server.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithRegistry(%T)", r))

		o.Registry = r
	}}
}

// WithRegistryInfo to set Registry Info if needed.
// It is used to add customized info and is suggested to use with WithRegistry option.
func WithRegistryInfo(info *registry.Info) Option {
	return Option{F: func(o *internal_server.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithRegistryInfo(%+v)", info))

		o.RegistryInfo = info
	}}
}

func WithRegistryInfoSkipListenAddr(skipListenAddr bool) Option {
	return Option{F: func(o *internal_server.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithRegistryInfoAvoidListenAddr(%+v)", skipListenAddr))

		o.RegistryInfo.SkipListenAddr = skipListenAddr
	}}
}

// WithGRPCWriteBufferSize determines how much data can be batched before doing a write on the wire.
// The corresponding memory allocation for this buffer will be twice the size to keep syscalls low.
// The default value for this buffer is 32KB.
// Zero will disable the write buffer such that each write will be on underlying connection.
// Note: A Send call may not directly translate to a write.
// It corresponds to the WriteBufferSize ServerOption of gRPC.
func WithGRPCWriteBufferSize(s uint32) Option {
	return Option{F: func(o *internal_server.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithGRPCWriteBufferSize(%+v)", s))

		o.RemoteOpt.GRPCCfg.WriteBufferSize = s
	}}
}

// WithGRPCReadBufferSize lets you set the size of read buffer, this determines how much data can be read at most
// for one read syscall.
// The default value for this buffer is 32KB.
// Zero will disable read buffer for a connection so data framer can access the underlying

Review comment (suggestion):
This option is not necessary: it's enough to use `WithRegisterInfo` to specify a `RegistryInfo` with this field set to true.

Code after:
		di.Push(fmt.Sprintf("WithPayloadCodec(%+v)", c))

		o.RemoteOpt.PayloadCodec = c
	}}
}

// WithRegistry to set a Registry to register service
func WithRegistry(r registry.Registry) Option {
	return Option{F: func(o *internal_server.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithRegistry(%T)", r))

		o.Registry = r
	}}
}

// WithRegistryInfo to set Registry Info if needed.
// It is used to add customized info and is suggested to use with WithRegistry option.
func WithRegistryInfo(info *registry.Info) Option {
	return Option{F: func(o *internal_server.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithRegistryInfo(%+v)", info))

		o.RegistryInfo = info
	}}
}

// WithGRPCWriteBufferSize determines how much data can be batched before doing a write on the wire.
// The corresponding memory allocation for this buffer will be twice the size to keep syscalls low.
// The default value for this buffer is 32KB.
// Zero will disable the write buffer such that each write will be on underlying connection.
// Note: A Send call may not directly translate to a write.
// It corresponds to the WriteBufferSize ServerOption of gRPC.
func WithGRPCWriteBufferSize(s uint32) Option {
	return Option{F: func(o *internal_server.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithGRPCWriteBufferSize(%+v)", s))

		o.RemoteOpt.GRPCCfg.WriteBufferSize = s
	}}
}

// WithGRPCReadBufferSize lets you set the size of read buffer, this determines how much data can be read at most
// for one read syscall.
// The default value for this buffer is 32KB.
// Zero will disable read buffer for a connection so data framer can access the underlying
// conn directly.
// It corresponds to the ReadBufferSize ServerOption of gRPC.
func WithGRPCReadBufferSize(s uint32) Option {
	return Option{F: func(o *internal_server.Options, di *utils.Slice) {
		di.Push(fmt.Sprintf("WithGRPCReadBufferSize(%+v)", s))

		o.RemoteOpt.GRPCCfg.ReadBufferSize = s
	}}