Commit d6c33660 authored by Levin Zimmermann's avatar Levin Zimmermann Committed by Kirill Smelkov

client.go: Fix URI client option parsing for supported + unsupported options

Before this patch, the parser ignored options which were already supported
by the client (for instance 'read-only') and even raised an error. But the
client can already use this option: as a9246333 describes this should happen in the
local storage URL parser.

Furthermore not-yet-supported client options (for instance compress) broke
the NEO client before this patch. Now these options only raise a warning which
informs the user that they are ignored. Why? We want to use pre-complete NEO
in real-world projects together with NEO/py clusters. Those real-world projects
may already specify options which aren't supported by our NEO/go client yet.
But it doesn't matters so much, because those options are mostly
relevant for other NEO/py cluster clients (e.g. zope nodes). Instead of
filtering those parameters before parsing them to NEO/go in a higher
level (e.g. SlapOS), NEO/go should already support any valid NEO URL
and raise warnings for not yet implemented features.
parent 4e9311d5
......@@ -26,6 +26,7 @@ import (
"math/rand"
"net/url"
"os"
"strconv"
"strings"
"sync"
......@@ -37,6 +38,7 @@ import (
"lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/go123/xsync"
"lab.nexedi.com/kirr/neo/go/internal/log"
"lab.nexedi.com/kirr/neo/go/internal/task"
taskctx "lab.nexedi.com/kirr/neo/go/internal/xcontext/task"
"lab.nexedi.com/kirr/neo/go/internal/xurl"
......@@ -537,6 +539,27 @@ func parseURL(ctx context.Context, u *url.URL) (urlinfo *urlInfo, err error) {
return nil, err
}
// mv readonly from URL => driver opts
readOnly, ok := q["read-only"]
if ok {
delete(q, "read-only")
r, err := strconv.ParseBool(readOnly)
if err != nil {
return nil, err
}
opt.ReadOnly = r
}
// pop not yet used client options
// (our neo client doesn't apply their effect yet)
for _, k := range []string {"compress", "cache-size", "logfile"} {
_, ok := q[k]
if ok {
delete(q, k)
log.Warningf(ctx, "TODO client doesn't support option '%q' yet", k)
}
}
if len(q) != 0 {
return nil, fmt.Errorf("invalid query: %v", q)
}
......
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