This repository has been archived by the owner on Jun 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Open and open funtions renamed in db.go as open and opendAndLoad function names. Open name is used in server.go to create a connection for server and database. Due to renaming Open and open functions , test files, example code in /example and README changed.
- Loading branch information
Showing
7 changed files
with
41 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package kvs | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"net/http" | ||
) | ||
|
||
// Open creates an HTTP and database connection. HTTP connection listens HTTP | ||
// requests from client and database connection listens database commands from | ||
// server. addr is the HTTP address and dbName is the database name. If HTTP | ||
// address is empty, localhost and default port is used. In contrast, dbName | ||
// needs to be specified. If it is not specified, it returns error and the | ||
// connection is not established. | ||
func Open(addr string, dbName string) (*Kvs, error) { | ||
if dbName == "" { | ||
return nil, fmt.Errorf("empty database name is not valid") | ||
} | ||
if addr == "" { | ||
addr = ":1234" | ||
} | ||
go log.Fatal(http.ListenAndServe(addr, nil)) | ||
return open(dbName) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters