Commit e2266200 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 4a0208b4
......@@ -15,41 +15,40 @@
//
// See COPYING file for full licensing terms.
// Package client provides access to NEO database via ZODB interfaces
package client
package neo
// access to NEO database via ZODB interfaces
import (
"../../neo"
"../../zodb"
"../zodb"
)
type NEOClient struct {
storLink neo.NodeLink // link to storage node
type Client struct {
storLink NodeLink // link to storage node
}
var _ zodb.IStorage = (*NEOClient)(nil)
var _ zodb.IStorage = (*Client)(nil)
//func Open(...) (*NEOClient, error) {
//func Open(...) (*Client, error) {
//}
func (c *NEOClient) StorageName() string {
func (c *Client) StorageName() string {
return "neo" // TODO more specific
}
func (c *NEOClient) Close() error {
func (c *Client) Close() error {
panic("TODO")
}
func (c *NEOClient) LastTid() zodb.Tid {
func (c *Client) LastTid() zodb.Tid {
panic("TODO")
}
func (c *NEOClient) Load(xid zodb.Xid) (data []byte, tid zodb.Tid, err error) {
func (c *Client) Load(xid zodb.Xid) (data []byte, tid zodb.Tid, err error) {
panic("TODO")
}
func (c *NEOClient) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
func (c *Client) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
panic("TODO")
}
......@@ -15,15 +15,19 @@
//
// See COPYING file for full licensing terms.
// TODO text
package storage
package neo
// NEO storage node
import (
"context"
"flag"
"fmt"
"io"
"log"
"os"
"../../zodb"
"../zodb"
_ "../zodb/wks"
)
// NEO Storage application
......@@ -194,3 +198,52 @@ func (stor *Storage) ServeClient(ctx context.Context, conn *Conn) {
//req.Put(...)
}
}
// ----------------------------------------
const storageSummary = "run NEO storage node"
// TODO options:
// cluster, masterv, bind ...
func storageUsage(w io.Writer) {
fmt.Fprintf(w,
`neostorage runs one NEO storage server.
Usage: neostorage [options] zstor XXX
`)
}
func storageMain(argv []string) {
flags := flag.FlagSet{Usage: func() { storageUsage(os.Stderr) }}
flags.Init("", flag.ExitOnError)
flags.Parse(argv[1:])
argv = flags.Args()
if len(argv) < 1 {
flags.Usage()
os.Exit(2)
}
// XXX hack
zstor, err := zodb.OpenStorageURL(argv[0])
if err != nil {
log.Fatal(err)
}
storsrv := NewStorage(zstor)
/*
ctx, cancel := context.WithCancel(context.Background())
go func() {
time.Sleep(5 * time.Second)
cancel()
}()
*/
ctx := context.Background()
err = ListenAndServe(ctx, "tcp", "localhost:1234", storsrv) // XXX hardcoded
if err != nil {
log.Fatal(err)
}
}
// Copyright (C) 2016-2017 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 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.
// neostorage - run a storage node of NEO
package storage
import (
"context"
"flag"
"fmt"
"log"
"os"
//_ "../../storage" // XXX rel ok?
neo "../../neo"
zodb "../../zodb"
_ "../../zodb/wks"
)
// TODO options:
// cluster, masterv, bind ...
func usage() {
fmt.Fprintf(os.Stderr,
`neostorage runs one NEO storage server.
Usage: neostorage [options] zstor XXX
`)
}
// -> StorageMain
func main() {
flag.Usage = usage
flag.Parse()
argv := flag.Args()
if len(argv) == 0 {
usage()
os.Exit(2)
}
zstor, err := zodb.OpenStorageURL(argv[0])
if err != nil {
log.Fatal(err)
}
storsrv := neo.NewStorage(zstor)
/*
ctx, cancel := context.WithCancel(context.Background())
go func() {
time.Sleep(5 * time.Second)
cancel()
}()
*/
ctx := context.Background()
err = neo.ListenAndServe(ctx, "tcp", "localhost:1234", storsrv)
if err != nil {
log.Fatal(err)
}
}
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