Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
db4a166b
Commit
db4a166b
authored
Jan 20, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X parseQuery -> xurl
parent
31ccdcba
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
28 deletions
+53
-28
go/internal/xurl/xurl.go
go/internal/xurl/xurl.go
+46
-0
go/neo/client.go
go/neo/client.go
+6
-5
go/neo/util.go
go/neo/util.go
+1
-23
No files found.
go/internal/xurl/xurl.go
0 → 100644
View file @
db4a166b
// Copyright (C) 2020-2021 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Free Software licenses or any of the Open Source
// Initiative approved licenses and Convey the resulting work. Corresponding
// source of such a combination shall include the source code for all other
// software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// Package xurl complements standard package net/url.
package
xurl
import
(
"fmt"
"net/url"
)
// ParseQuery parses query string into regular map.
// see also url.ParseQuery
func
ParseQuery
(
query
string
)
(
map
[
string
]
string
,
error
)
{
qv
,
err
:=
url
.
ParseQuery
(
query
)
if
err
!=
nil
{
return
nil
,
err
}
q
:=
map
[
string
]
string
{}
for
k
,
vv
:=
range
qv
{
if
len
(
vv
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"parameter %q without value"
,
k
)
}
if
len
(
vv
)
!=
1
{
return
nil
,
fmt
.
Errorf
(
"duplicate parameter %q "
,
k
)
}
q
[
k
]
=
vv
[
0
]
}
return
q
,
nil
}
go/neo/client.go
View file @
db4a166b
...
@@ -36,15 +36,16 @@ import (
...
@@ -36,15 +36,16 @@ import (
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/neo/go/internal/log"
"lab.nexedi.com/kirr/neo/go/internal/task"
"lab.nexedi.com/kirr/neo/go/internal/xio"
"lab.nexedi.com/kirr/neo/go/internal/xurl"
"lab.nexedi.com/kirr/neo/go/internal/xzlib"
"lab.nexedi.com/kirr/neo/go/internal/xzlib"
"lab.nexedi.com/kirr/neo/go/internal/xzodb"
"lab.nexedi.com/kirr/neo/go/internal/xzodb"
"lab.nexedi.com/kirr/neo/go/neo/internal/xsha1"
"lab.nexedi.com/kirr/neo/go/neo/internal/xsha1"
"lab.nexedi.com/kirr/neo/go/neo/neonet"
"lab.nexedi.com/kirr/neo/go/neo/neonet"
"lab.nexedi.com/kirr/neo/go/neo/proto"
"lab.nexedi.com/kirr/neo/go/neo/proto"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/internal/log"
"lab.nexedi.com/kirr/neo/go/internal/task"
"lab.nexedi.com/kirr/neo/go/internal/xio"
)
)
// Client is NEO node that talks to NEO cluster and exposes access to it via ZODB interfaces.
// Client is NEO node that talks to NEO cluster and exposes access to it via ZODB interfaces.
...
@@ -625,7 +626,7 @@ func openClientByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (
...
@@ -625,7 +626,7 @@ func openClientByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (
}
}
cred
:=
u
.
User
.
String
()
cred
:=
u
.
User
.
String
()
x
,
err
:=
p
arseQuery
(
cred
)
x
,
err
:=
xurl
.
P
arseQuery
(
cred
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
zodb
.
InvalidTid
,
fmt
.
Errorf
(
"credentials: %s"
,
err
)
return
nil
,
zodb
.
InvalidTid
,
fmt
.
Errorf
(
"credentials: %s"
,
err
)
}
}
...
@@ -664,7 +665,7 @@ func openClientByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (
...
@@ -664,7 +665,7 @@ func openClientByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (
return
nil
,
zodb
.
InvalidTid
,
fmt
.
Errorf
(
"cluster name not specified"
)
return
nil
,
zodb
.
InvalidTid
,
fmt
.
Errorf
(
"cluster name not specified"
)
}
}
q
,
err
:=
p
arseQuery
(
u
.
RawQuery
)
q
,
err
:=
xurl
.
P
arseQuery
(
u
.
RawQuery
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
zodb
.
InvalidTid
,
err
return
nil
,
zodb
.
InvalidTid
,
err
}
}
...
...
go/neo/util.go
View file @
db4a166b
// Copyright (C) 2017-202
0
Nexedi SA and Contributors.
// Copyright (C) 2017-202
1
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Kirill Smelkov <kirr@nexedi.com>
//
//
// This program is free software: you can Use, Study, Modify and Redistribute
// This program is free software: you can Use, Study, Modify and Redistribute
...
@@ -21,9 +21,7 @@ package neo
...
@@ -21,9 +21,7 @@ package neo
import
(
import
(
"context"
"context"
"fmt"
"io"
"io"
"net/url"
"lab.nexedi.com/kirr/neo/go/internal/log"
"lab.nexedi.com/kirr/neo/go/internal/log"
)
)
...
@@ -36,23 +34,3 @@ func lclose(ctx context.Context, c io.Closer) {
...
@@ -36,23 +34,3 @@ func lclose(ctx context.Context, c io.Closer) {
log
.
Error
(
ctx
,
err
)
log
.
Error
(
ctx
,
err
)
}
}
}
}
// parseQuery parses query string into regular map.
// see also url.ParseQuery
func
parseQuery
(
query
string
)
(
map
[
string
]
string
,
error
)
{
qv
,
err
:=
url
.
ParseQuery
(
query
)
if
err
!=
nil
{
return
nil
,
err
}
q
:=
map
[
string
]
string
{}
for
k
,
vv
:=
range
qv
{
if
len
(
vv
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"parameter %q without value"
,
k
)
}
if
len
(
vv
)
!=
1
{
return
nil
,
fmt
.
Errorf
(
"duplicate parameter %q "
,
k
)
}
q
[
k
]
=
vv
[
0
]
}
return
q
,
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment