Commit 2aa9b909 authored by Kirill Smelkov's avatar Kirill Smelkov

fixup! client: Refactor openClientByURL for easier testing

- no need to pass DriverOptions into parseURL - it is only zurl that is
  parsed, and also DriverOptions should not be changed by the opener.

- no need to document "If anything fails within this process an error
  and nil are returned." because that is standard omnipresent Go convention.
parent 7bad0dda
......@@ -416,11 +416,15 @@ func (c *Client) Iterate(ctx context.Context, tidMin, tidMax zodb.Tid) zodb.ITxn
func openClientByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (_ zodb.IStorageDriver, _ zodb.Tid, err error) {
defer task.Runningf(&ctx, "neo: open %s", u)(&err)
urlinfo, err := parseURL(ctx, u, opt)
urlinfo, err := parseURL(ctx, u)
if err != nil {
return nil, zodb.InvalidTid, err
}
if !opt.ReadOnly {
return nil, zodb.InvalidTid, fmt.Errorf("TODO write mode not implemented")
}
net, err := neonet.Join(ctx, urlinfo.netcfg)
if err != nil {
return nil, zodb.InvalidTid, err
......@@ -477,9 +481,8 @@ func openClientByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (
}
// parseURL extracts information from a NEO URI and puts this information into
// a urlInfo and the DriverOptions. If anything fails within this process
// an error and nil are returned.
func parseURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (urlinfo *urlInfo, err error) {
// a urlInfo.
func parseURL(ctx context.Context, u *url.URL) (urlinfo *urlInfo, err error) {
// neo(s)://[credentials@]master1,master2,...,masterN/name?options
var ssl bool
......@@ -538,13 +541,9 @@ func parseURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (urlinfo
return nil, fmt.Errorf("invalid query: %v", q)
}
if !opt.ReadOnly {
return nil, fmt.Errorf("TODO write mode not implemented")
}
masterAddr := u.Host
masterAddr := u.Host
return &urlInfo{masterAddr, name, netcfg}, nil
return &urlInfo{masterAddr, name, netcfg}, nil
}
// urlInfo encapsulates data extracted from a NEO URI.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment