Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
e8954823
Commit
e8954823
authored
Nov 25, 2016
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
2998b840
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
11 deletions
+93
-11
t/neo/cmd/neostorage-go/neostorage.go
t/neo/cmd/neostorage-go/neostorage.go
+4
-1
t/neo/neo.go
t/neo/neo.go
+16
-10
t/neo/storage.go
t/neo/storage.go
+73
-0
No files found.
t/neo/cmd/neostorage-go/neostorage.go
View file @
e8954823
...
...
@@ -6,6 +6,8 @@ package main
import
(
_
"../../storage"
// XXX rel ok?
neo
"../.."
"fmt"
)
...
...
@@ -13,6 +15,7 @@ import (
// cluster, masterv, bind ...
func
main
()
{
// TODO
var
t
neo
.
Tid
=
neo
.
MAX_TID
fmt
.
Printf
(
"%T %x
\n
"
,
t
,
t
)
println
(
"TODO"
)
}
t/neo/
zodb
.go
→
t/neo/
neo
.go
View file @
e8954823
//
XXX
license
//
TODO copyright /
license
// ZODB types
package
neo
// XXX -> zodb ?
// Package neo implements distributed object storage for ZODB
// TODO text
package
neo
// ZODB types
// XXX naming -> TID, OID ?
type
Tid
uint64
//
XXX or [8]byte ?
type
Oid
uint64
//
XXX or [8]byte ?
type
Tid
uint64
//
transaction identifier TODO encode as BE
type
Oid
uint64
//
object identifier TODO encode as BE
/*
// XXX "extended" oid - oid + serial, completely specifying object revision
type Xid struct {
Tid
Oid
}
*/
const
(
//INVALID_UUID UUID = 0
INVALID_TID
Tid
=
1
<<
64
-
1
// 0xffffffffffffffff
TODO recheck it is the same
INVALID_OID
Oid
=
0xffffffffffffffff
//
1<<64 - 1
ZERO_TID
Tid
=
0
// XXX or simply TID{} ?
// XXX -> TID0 ?
INVALID_TID
Tid
=
1
<<
64
-
1
// 0xffffffffffffffff
INVALID_OID
Oid
=
1
<<
64
-
1
ZERO_TID
Tid
=
0
// XXX or simply TID{} ?
TID0
Tid
=
ZERO_TID
// XXX ^^^ choose 1
ZERO_OID
Oid
=
0
// XXX or simply OID{} ? // XXX -> OID0
// OID_LEN = 8
// TID_LEN = 8
MAX_TID
Tid
=
0x7fffffffffffffff
// SQLite does not accept numbers above 2^63-1 // XXX -> TIDMAX ?
TIDMAX
Tid
=
MAX_TID
// XXX ^^^ choose 1
MAX_TID
Tid
=
1
<<
63
-
1
// 0x7fffffffffffffff
// SQLite does not accept numbers above 2^63-1
// ZODB also defines maxtid to be max signed int64 since baee84a6 (Jun 7 2016)
TIDMAX
Tid
=
MAX_TID
// XXX ^^^ choose 1
)
...
...
t/neo/storage.go
0 → 100644
View file @
e8954823
// TODO copyright / license
package
neo
import
(
"context"
)
// NEO Storage application
type
StorageApplication
struct
{
}
// ----------------------------------------
// Server is an interface that represents networked server XXX text
type
Server
interface
{
// ServeConn serves already established connection in a blocking way.
// ServeConn is usually run in separate goroutine XXX text
ServeConn
(
ctx
context
.
Context
,
conn
net
.
Conn
)
// XXX error ?
}
// srv.ServeConn(ctx context.Context, conn net.Conn)
// Run service on a listener
// - accept incoming connection on the listener
// - for every accepted connection spawn srv.ServeConn() in separate goroutine.
//
// the listener is closed when Serve returns.
// XXX text
// XXX move -> generic place ?
func
Serve
(
ctx
context
.
Context
,
l
net
.
Listener
,
srv
Server
)
error
{
// close listener when either cancelling or returning (e.g. due to an error)
// ( when cancelling - listener close will signal to all accepts to
// terminate with an error )
retch
:=
make
(
chan
struct
{})
defer
func
()
{
close
(
retch
)
}()
go
func
(
select
{
case
<-
ctx
.
Done
()
:
case
<-
retch
:
}
l
.
Close
()
// XXX err
)()
// main Accept -> ServeConn loop
for
{
conn
,
err
:=
l
.
Accept
()
if
err
!=
nil
{
// TODO check done channel of l/srv somehow
// TODO err -> net.Error && .Temporary() -> some throttling
return
err
}
go
srv
.
ServeConn
(
ctx
,
conn
)
}
}
// TODO text
// XXX move -> generic place ?
// XXX get (net, laddr) from srv ?
// XXX split -> separate Listen()
func
ListenAndServe
(
ctx
context
.
Context
,
net
,
laddr
string
,
srv
Server
)
error
{
l
,
err
:=
net
.
Listen
(
net
,
laddr
)
if
err
!=
nil
{
return
err
}
// TODO set keepalive on l
// TODO if TLS config -> tls.NewListener()
return
Serve
(
ctx
,
l
,
srv
)
}
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