// Creates a new server. func New(path, listen string) (*Server, error) { sqlPath := filepath.Join(path, "storage.sql") util.EnsureAbsent(sqlPath) s := &Server{ received: make(map[string]bool), path: path, listen: listen, sql: sql.NewSQL(sqlPath), router: mux.NewRouter(), client: transport.NewClient(), } // Read existing name or generate a new one. if b, err := ioutil.ReadFile(filepath.Join(path, "name")); err == nil { s.name = string(b) } else { s.name = fmt.Sprintf("%07x", rand.Int())[0:7] if err = ioutil.WriteFile(filepath.Join(path, "name"), []byte(s.name), 0644); err != nil { panic(err) } } return s, nil }
// Creates a new server. func New(path, listen string) (*Server, error) { sqlPath := filepath.Join(path, "storage.sql") util.EnsureAbsent(sqlPath) s := &Server{ name: listen, path: path, listen: listen, sql: sql.NewSQL(sqlPath), router: mux.NewRouter(), client: transport.NewClient(), } return s, nil }
// Creates a new server. func New(path, listen string) (*Server, error) { cs, err := transport.Encode(listen) if err != nil { return nil, err } sqlPath := filepath.Join(path, "storage.sql") util.EnsureAbsent(sqlPath) s := &Server{ path: path, listen: listen, sql: sql.NewSQL(sqlPath), router: mux.NewRouter(), client: transport.NewClient(), cluster: NewCluster(path, cs), } return s, nil }
// Creates a new server. func New(path, listen string) (*Server, error) { cs, err := transport.Encode(listen) if err != nil { return nil, err } log.Printf("My connection string is %s", cs) sqlPath := filepath.Join(path, "storage.sql") util.EnsureAbsent(sqlPath) s := &Server{ path: path, name: strings.Replace(listen, "/", "-", -1), listen: listen, connection_string: cs, sql: sql.NewSQL(sqlPath), router: mux.NewRouter(), client: transport.NewClient(), } return s, nil }
// Creates a new server. func New(path, listen, join string) (*Server, error) { cs, err := transport.Encode(listen) if err != nil { return nil, err } sqlPath := filepath.Join(path, "storage.sql") util.EnsureAbsent(sqlPath) s := &Server{ path: path, listen: listen, name: path, connectionString: cs, sql: sql.NewSQL(sqlPath), router: mux.NewRouter(), client: transport.NewClient(), execCommand: make(chan *ExecCommand), } return s, nil }
// Creates a new server. func New(path, listen string) (*Server, error) { cs, err := transport.Encode(listen) if err != nil { return nil, err } log.Printf("Starting server at" + cs) sqlPath := filepath.Join(path, "storage.sql") util.EnsureAbsent(sqlPath) s := &Server{ path: path, listen: listen, sql: sql.NewSQL(sqlPath), router: mux.NewRouter(), client: transport.NewClient(), block: false, } return s, nil }
// Creates a new database. func NewDB(path string) *DB { sqlPath := filepath.Join(path, "storage.sql") util.EnsureAbsent(sqlPath) return &DB{sql: sql.NewSQL(sqlPath), notify: make(chan *sql.Output)} }