From ff6cc82b70b4e991ff098070e626d5e383da9214 Mon Sep 17 00:00:00 2001 From: bokket <3100563328@qq.com> Date: Sat, 17 Jul 2021 13:05:04 +0800 Subject: [PATCH 1/9] Add Tcp Pair Signed-off-by: bokket <3100563328@qq.com> --- docs/rfcs/12-add-tcp-pair.md | 90 ++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 docs/rfcs/12-add-tcp-pair.md diff --git a/docs/rfcs/12-add-tcp-pair.md b/docs/rfcs/12-add-tcp-pair.md new file mode 100644 index 0000000..a8ca3cf --- /dev/null +++ b/docs/rfcs/12-add-tcp-pair.md @@ -0,0 +1,90 @@ +- Author: bokket [bokkett@gmail.com](mailto:bokkett@gmail.com) +- Start Date: 2021-07-17 +- RFC PR: [beyondstorage/go-endpoint#0](https://github.com/beyondstorage/go-endpoint/pulls) +- Tracking Issue: [beyondstorage/go-endpoint/issues/7](https://github.com/beyondstorage/go-endpoint/issues/7) + +# RFC-12: Add Tcp pair + +Releated issue: [beyondstorage/go-endpoint/issues/7](https://github.com/beyondstorage/go-endpoint/issues/7) + +## Background + +hdfs usually use the `New(address string)` method to access a namenode node, the user will be the user running the code. If the address is an empty string, it will try to get the NameNode address from the Hadoop configuration file. + +## Proposal + +I suggest adding a pair to allow the user to specify the address. + +- The `type` of `tcp` should be `String` and is a `const` +- The `format` of `ProtocolTcp` should follow [go-endpoint](https://github.com/beyondstorage/go-endpoint/blob/master/README.md) +- The `value` of `endpoint` should be parsed into `address include host and port` +- Now we don't have a pair operation on the `hdfs address` or tcp-like operation + +## Rationale + +### Why not use hadoop configuration? + +We can specify the configuration of the path via `LoadHadoopConf` +If not specified, the default path `${hadoop_home}/conf` will be used + +However, there is no guarantee that the path is wrong, and it is more common for users to use the namenode address directly. + +## Compatibility + +No compatibility issues at this time. + +## Implementation + +First add a `String` type with the name `ProtocolTcp` in `endpoint`. + +```go +const { + //ProtocolTcp is the file endpoint protocol + ProtocolTcp = "tcp" +} +``` + +Then implementing the Tcp method of endpoint + +```go +func (p Endpoint) Tcp() (address string) { + if p.protocol != ProtocolTcp { + panic(Error{ + Op: "tcp", + Err: ErrInvalidValue, + Protocol: p.protocol, + Values: p.args, + }) + } + //It must be host:port + return p.args.(string) +} +``` + +Then implementing Parse and NewTcp methods + +```go +func Parse(cfg string) (Provider, error) { + s := strings.Split(cfg, ":") + + switch s[0] { + ..... + case ProtocolTcp: + //Handle tcp connection (hdfs) + return NewTcp(s[1]),nil + default: + return Endpoint{}, &Error{"parse", ErrUnsupportedProtocol, s[0], nil} + } +} +``` + + + +```go +func NewTcp(address string) Endpoint { + return Endpoint{ + protocol: ProtocolTcp, + args: path, + } +} +``` \ No newline at end of file From 5f9d3c55abb66774644b331f14249f15938f1bda Mon Sep 17 00:00:00 2001 From: bokket <3100563328@qq.com> Date: Sat, 17 Jul 2021 13:07:21 +0800 Subject: [PATCH 2/9] fix some details Signed-off-by: bokket <3100563328@qq.com> --- docs/rfcs/{12-add-tcp-pair.md => 8-add-tcp-pair.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename docs/rfcs/{12-add-tcp-pair.md => 8-add-tcp-pair.md} (95%) diff --git a/docs/rfcs/12-add-tcp-pair.md b/docs/rfcs/8-add-tcp-pair.md similarity index 95% rename from docs/rfcs/12-add-tcp-pair.md rename to docs/rfcs/8-add-tcp-pair.md index a8ca3cf..4d78c45 100644 --- a/docs/rfcs/12-add-tcp-pair.md +++ b/docs/rfcs/8-add-tcp-pair.md @@ -1,9 +1,9 @@ - Author: bokket [bokkett@gmail.com](mailto:bokkett@gmail.com) - Start Date: 2021-07-17 -- RFC PR: [beyondstorage/go-endpoint#0](https://github.com/beyondstorage/go-endpoint/pulls) +- RFC PR: [beyondstorage/go-endpoint#8](https://github.com/beyondstorage/go-endpoint/pull/8) - Tracking Issue: [beyondstorage/go-endpoint/issues/7](https://github.com/beyondstorage/go-endpoint/issues/7) -# RFC-12: Add Tcp pair +# RFC-8: Add Tcp pair Releated issue: [beyondstorage/go-endpoint/issues/7](https://github.com/beyondstorage/go-endpoint/issues/7) From c71b57c9f231967e59c81fb34b100dad37943735 Mon Sep 17 00:00:00 2001 From: bokket <3100563328@qq.com> Date: Sat, 17 Jul 2021 13:59:57 +0800 Subject: [PATCH 3/9] Correction of some issues Signed-off-by: bokket <3100563328@qq.com> --- docs/rfcs/8-add-tcp-pair.md | 77 ++++++------------------------------- 1 file changed, 12 insertions(+), 65 deletions(-) diff --git a/docs/rfcs/8-add-tcp-pair.md b/docs/rfcs/8-add-tcp-pair.md index 4d78c45..ccd155e 100644 --- a/docs/rfcs/8-add-tcp-pair.md +++ b/docs/rfcs/8-add-tcp-pair.md @@ -1,9 +1,9 @@ -- Author: bokket [bokkett@gmail.com](mailto:bokkett@gmail.com) +- Author: bokket - Start Date: 2021-07-17 - RFC PR: [beyondstorage/go-endpoint#8](https://github.com/beyondstorage/go-endpoint/pull/8) - Tracking Issue: [beyondstorage/go-endpoint/issues/7](https://github.com/beyondstorage/go-endpoint/issues/7) -# RFC-8: Add Tcp pair +# RFC-8: Add Tcp protocol Releated issue: [beyondstorage/go-endpoint/issues/7](https://github.com/beyondstorage/go-endpoint/issues/7) @@ -13,21 +13,17 @@ hdfs usually use the `New(address string)` method to access a namenode node, the ## Proposal -I suggest adding a pair to allow the user to specify the address. +I suggest adding a tcp protocol to allow the user to specify the address. + +It likes `tcp::` - The `type` of `tcp` should be `String` and is a `const` -- The `format` of `ProtocolTcp` should follow [go-endpoint](https://github.com/beyondstorage/go-endpoint/blob/master/README.md) -- The `value` of `endpoint` should be parsed into `address include host and port` -- Now we don't have a pair operation on the `hdfs address` or tcp-like operation +- The `alias` of `ProtocolTcp` should follow [go-endpoint](https://github.com/beyondstorage/go-endpoint/blob/master/README.md) +- The `value` of `endpoint` should be parsed into `ProtocolTcp` and `args include :` ## Rationale -### Why not use hadoop configuration? - -We can specify the configuration of the path via `LoadHadoopConf` -If not specified, the default path `${hadoop_home}/conf` will be used - -However, there is no guarantee that the path is wrong, and it is more common for users to use the namenode address directly. +Now we don't have a pair operation on the `hdfs address` or tcp-like operation ## Compatibility @@ -35,56 +31,7 @@ No compatibility issues at this time. ## Implementation -First add a `String` type with the name `ProtocolTcp` in `endpoint`. - -```go -const { - //ProtocolTcp is the file endpoint protocol - ProtocolTcp = "tcp" -} -``` - -Then implementing the Tcp method of endpoint - -```go -func (p Endpoint) Tcp() (address string) { - if p.protocol != ProtocolTcp { - panic(Error{ - Op: "tcp", - Err: ErrInvalidValue, - Protocol: p.protocol, - Values: p.args, - }) - } - //It must be host:port - return p.args.(string) -} -``` - -Then implementing Parse and NewTcp methods - -```go -func Parse(cfg string) (Provider, error) { - s := strings.Split(cfg, ":") - - switch s[0] { - ..... - case ProtocolTcp: - //Handle tcp connection (hdfs) - return NewTcp(s[1]),nil - default: - return Endpoint{}, &Error{"parse", ErrUnsupportedProtocol, s[0], nil} - } -} -``` - - - -```go -func NewTcp(address string) Endpoint { - return Endpoint{ - protocol: ProtocolTcp, - args: path, - } -} -``` \ No newline at end of file +- Add protocol `tcp` +- Implement protocol tcp formatted (`func (p Endpoint) Tcp() (address string)`) +- Implement protocol tcp parser (`func Parse(cfg string) (Provider, error)`) +- Implement protocol tcp object (`func NewTcp(address string) Endpoint `) \ No newline at end of file From 67471b06279d6a98ce01bebf214fb1e4ebc809b4 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Sat, 17 Jul 2021 15:00:03 +0800 Subject: [PATCH 4/9] Update docs/rfcs/8-add-tcp-pair.md --- docs/rfcs/8-add-tcp-pair.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/rfcs/8-add-tcp-pair.md b/docs/rfcs/8-add-tcp-pair.md index ccd155e..d32caad 100644 --- a/docs/rfcs/8-add-tcp-pair.md +++ b/docs/rfcs/8-add-tcp-pair.md @@ -1,7 +1,7 @@ - Author: bokket - Start Date: 2021-07-17 - RFC PR: [beyondstorage/go-endpoint#8](https://github.com/beyondstorage/go-endpoint/pull/8) -- Tracking Issue: [beyondstorage/go-endpoint/issues/7](https://github.com/beyondstorage/go-endpoint/issues/7) +- Tracking Issue: [beyondstorage/go-endpoint/issues/9](https://github.com/beyondstorage/go-endpoint/issues/9) # RFC-8: Add Tcp protocol @@ -34,4 +34,4 @@ No compatibility issues at this time. - Add protocol `tcp` - Implement protocol tcp formatted (`func (p Endpoint) Tcp() (address string)`) - Implement protocol tcp parser (`func Parse(cfg string) (Provider, error)`) -- Implement protocol tcp object (`func NewTcp(address string) Endpoint `) \ No newline at end of file +- Implement protocol tcp object (`func NewTcp(address string) Endpoint `) From dc70e703d870c3fa5ad0aa5920dcdbf303ae30e6 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Sat, 17 Jul 2021 15:01:00 +0800 Subject: [PATCH 5/9] Update and rename 8-add-tcp-pair.md to 8-add-tcp-protocol.md --- docs/rfcs/{8-add-tcp-pair.md => 8-add-tcp-protocol.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename docs/rfcs/{8-add-tcp-pair.md => 8-add-tcp-protocol.md} (97%) diff --git a/docs/rfcs/8-add-tcp-pair.md b/docs/rfcs/8-add-tcp-protocol.md similarity index 97% rename from docs/rfcs/8-add-tcp-pair.md rename to docs/rfcs/8-add-tcp-protocol.md index d32caad..6ccae34 100644 --- a/docs/rfcs/8-add-tcp-pair.md +++ b/docs/rfcs/8-add-tcp-protocol.md @@ -19,7 +19,7 @@ It likes `tcp::` - The `type` of `tcp` should be `String` and is a `const` - The `alias` of `ProtocolTcp` should follow [go-endpoint](https://github.com/beyondstorage/go-endpoint/blob/master/README.md) -- The `value` of `endpoint` should be parsed into `ProtocolTcp` and `args include :` +- The `value` of `endpoint` should be parsed into `ProtocolTcp` and `args include :` ## Rationale From 1c165aa73f7e5ecbc0b107cb1506b867e7ceb305 Mon Sep 17 00:00:00 2001 From: bokket <3100563328@qq.com> Date: Sat, 17 Jul 2021 15:23:36 +0800 Subject: [PATCH 6/9] commit --- .../{8-add-tcp-pair.md => 8-add-tcp-protocol.md} | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rename docs/rfcs/{8-add-tcp-pair.md => 8-add-tcp-protocol.md} (65%) diff --git a/docs/rfcs/8-add-tcp-pair.md b/docs/rfcs/8-add-tcp-protocol.md similarity index 65% rename from docs/rfcs/8-add-tcp-pair.md rename to docs/rfcs/8-add-tcp-protocol.md index ccd155e..bbefa46 100644 --- a/docs/rfcs/8-add-tcp-pair.md +++ b/docs/rfcs/8-add-tcp-protocol.md @@ -1,9 +1,9 @@ - Author: bokket - Start Date: 2021-07-17 - RFC PR: [beyondstorage/go-endpoint#8](https://github.com/beyondstorage/go-endpoint/pull/8) -- Tracking Issue: [beyondstorage/go-endpoint/issues/7](https://github.com/beyondstorage/go-endpoint/issues/7) +- Tracking Issue: [beyondstorage/go-endpoint/issues/9](https://github.com/beyondstorage/go-endpoint/issues/9) -# RFC-8: Add Tcp protocol +# RFC-8: Add TCP protocol Releated issue: [beyondstorage/go-endpoint/issues/7](https://github.com/beyondstorage/go-endpoint/issues/7) @@ -18,8 +18,8 @@ I suggest adding a tcp protocol to allow the user to specify the address. It likes `tcp::` - The `type` of `tcp` should be `String` and is a `const` -- The `alias` of `ProtocolTcp` should follow [go-endpoint](https://github.com/beyondstorage/go-endpoint/blob/master/README.md) -- The `value` of `endpoint` should be parsed into `ProtocolTcp` and `args include :` +- The `alias` of `ProtocolTCP` should follow [go-endpoint](https://github.com/beyondstorage/go-endpoint/blob/master/README.md) +- The `value` of `endpoint` should be parsed into `ProtocolTCP` and `args include :` ## Rationale @@ -32,6 +32,6 @@ No compatibility issues at this time. ## Implementation - Add protocol `tcp` -- Implement protocol tcp formatted (`func (p Endpoint) Tcp() (address string)`) -- Implement protocol tcp parser (`func Parse(cfg string) (Provider, error)`) -- Implement protocol tcp object (`func NewTcp(address string) Endpoint `) \ No newline at end of file +- Implement protocol tcp formatted (`func (p Endpoint) TCP() (addr,host string,port int)`) +- Implement protocol tcp parser (`func Parse(cfg string) (p Endpoint, err error)`) +- Implement protocol tcp object (`func NewTCP(host string,port int) Endpoint `) \ No newline at end of file From 16fe67a86c21859fe9d22972ce65e7ee5d345e0d Mon Sep 17 00:00:00 2001 From: bokket <3100563328@qq.com> Date: Sat, 17 Jul 2021 15:31:21 +0800 Subject: [PATCH 7/9] fix issues Signed-off-by: bokket <3100563328@qq.com> --- docs/rfcs/8-add-tcp-protocol.md | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/docs/rfcs/8-add-tcp-protocol.md b/docs/rfcs/8-add-tcp-protocol.md index 24b7c3d..044f7a8 100644 --- a/docs/rfcs/8-add-tcp-protocol.md +++ b/docs/rfcs/8-add-tcp-protocol.md @@ -18,13 +18,8 @@ I suggest adding a tcp protocol to allow the user to specify the address. It likes `tcp::` - The `type` of `tcp` should be `String` and is a `const` -<<<<<<< HEAD:docs/rfcs/8-add-tcp-protocol.md - The `alias` of `ProtocolTCP` should follow [go-endpoint](https://github.com/beyondstorage/go-endpoint/blob/master/README.md) - The `value` of `endpoint` should be parsed into `ProtocolTCP` and `args include :` -======= -- The `alias` of `ProtocolTcp` should follow [go-endpoint](https://github.com/beyondstorage/go-endpoint/blob/master/README.md) -- The `value` of `endpoint` should be parsed into `ProtocolTcp` and `args include :` ->>>>>>> dc70e703d870c3fa5ad0aa5920dcdbf303ae30e6:docs/rfcs/8-add-tcp-protocol.md ## Rationale @@ -37,12 +32,6 @@ No compatibility issues at this time. ## Implementation - Add protocol `tcp` -<<<<<<< HEAD:docs/rfcs/8-add-tcp-protocol.md - Implement protocol tcp formatted (`func (p Endpoint) TCP() (addr,host string,port int)`) - Implement protocol tcp parser (`func Parse(cfg string) (p Endpoint, err error)`) - Implement protocol tcp object (`func NewTCP(host string,port int) Endpoint `) -======= -- Implement protocol tcp formatted (`func (p Endpoint) Tcp() (address string)`) -- Implement protocol tcp parser (`func Parse(cfg string) (Provider, error)`) -- Implement protocol tcp object (`func NewTcp(address string) Endpoint `) ->>>>>>> dc70e703d870c3fa5ad0aa5920dcdbf303ae30e6:docs/rfcs/8-add-tcp-protocol.md From 621c9d469105d5669e4bba87ece68f100bfe8f44 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Sat, 17 Jul 2021 15:33:43 +0800 Subject: [PATCH 8/9] Update docs/rfcs/8-add-tcp-protocol.md --- docs/rfcs/8-add-tcp-protocol.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/rfcs/8-add-tcp-protocol.md b/docs/rfcs/8-add-tcp-protocol.md index 044f7a8..fe0b112 100644 --- a/docs/rfcs/8-add-tcp-protocol.md +++ b/docs/rfcs/8-add-tcp-protocol.md @@ -32,6 +32,6 @@ No compatibility issues at this time. ## Implementation - Add protocol `tcp` -- Implement protocol tcp formatted (`func (p Endpoint) TCP() (addr,host string,port int)`) +- Implement protocol tcp formatted (`func (p Endpoint) TCP() (addr, host string, port int)`) - Implement protocol tcp parser (`func Parse(cfg string) (p Endpoint, err error)`) - Implement protocol tcp object (`func NewTCP(host string,port int) Endpoint `) From dc9daa8158582b68d093c4302fa6451e58f69a26 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Sat, 17 Jul 2021 15:33:51 +0800 Subject: [PATCH 9/9] Update docs/rfcs/8-add-tcp-protocol.md --- docs/rfcs/8-add-tcp-protocol.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/rfcs/8-add-tcp-protocol.md b/docs/rfcs/8-add-tcp-protocol.md index fe0b112..20e0b00 100644 --- a/docs/rfcs/8-add-tcp-protocol.md +++ b/docs/rfcs/8-add-tcp-protocol.md @@ -18,7 +18,6 @@ I suggest adding a tcp protocol to allow the user to specify the address. It likes `tcp::` - The `type` of `tcp` should be `String` and is a `const` -- The `alias` of `ProtocolTCP` should follow [go-endpoint](https://github.com/beyondstorage/go-endpoint/blob/master/README.md) - The `value` of `endpoint` should be parsed into `ProtocolTCP` and `args include :` ## Rationale