From 88df5e2c740b086939fba5a02a39e5d438063202 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie <jimmyzelinskie@gmail.com> Date: Wed, 28 Jan 2015 22:51:09 -0500 Subject: [PATCH] docs: move driver docs into backend/README.md --- README.md | 36 ------------------------------------ backend/README.md | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 36 deletions(-) create mode 100644 backend/README.md diff --git a/README.md b/README.md index 59a1f56..6798357 100644 --- a/README.md +++ b/README.md @@ -50,42 +50,6 @@ $ cd $GOPATH/src/github.com/chihaya/chihaya $ godep go test -v ./... -bench . ``` -## Implementing a Driver - -The [`backend`] package is meant to provide announce deltas to a slower and more consistent database, such as the one powering a torrent-indexing website. Implementing a backend driver is heavily inspired by the standard library's [`database/sql`] package: simply create a package that implements the [`backend.Driver`] and [`backend.Conn`] interfaces and calls [`backend.Register`] in it's [`init()`]. Please note that [`backend.Conn`] must be thread-safe. A great place to start is to read the [`no-op`] driver which comes out-of-the-box with Chihaya and is meant to be used for public trackers. - -[`init()`]: http://golang.org/ref/spec#Program_execution -[`database/sql`]: http://godoc.org/database/sql -[`backend`]: http://godoc.org/github.com/chihaya/chihaya/backend -[`backend.Register`]: http://godoc.org/github.com/chihaya/chihaya/backend#Register -[`backend.Driver`]: http://godoc.org/github.com/chihaya/chihaya/backend#Driver -[`backend.Conn`]: http://godoc.org/github.com/chihaya/chihaya/backend#Conn -[`no-op`]: http://godoc.org/github.com/chihaya/chihaya/backend/noop - -### Creating a binary with your own driver - -Chihaya is designed to be extended. If you require more than the drivers provided out-of-the-box, you are free to create your own and then produce your own custom Chihaya binary. To create this binary, simply create your own main package, import your custom drivers, then call [`chihaya.Boot`] from main. - -[`chihaya.Boot`]: http://godoc.org/github.com/chihaya/chihaya - -#### Example - -```go -package main - -import ( - "github.com/chihaya/chihaya" - - // Import any of your own drivers. - _ "github.com/yourusername/chihaya-custom-backend" -) - -func main() { - // Start Chihaya normally. - chihaya.Boot() -} -``` - ## Contributing The project follows idiomatic [Go conventions] for style. If you're interested in contributing, please contact us via IRC in **[#chihaya] on [freenode]** or post to the GitHub issue tracker. Please don't write massive patches with no prior communication, as it will most likely lead to confusion and time wasted for everyone. However, small unannounced fixes are always welcome! diff --git a/backend/README.md b/backend/README.md new file mode 100644 index 0000000..c96802c --- /dev/null +++ b/backend/README.md @@ -0,0 +1,35 @@ +# Implementing a Driver + +The [`backend`] package is meant to provide announce deltas to a slower and more consistent database, such as the one powering a torrent-indexing website. Implementing a backend driver is heavily inspired by the standard library's [`database/sql`] package: simply create a package that implements the [`backend.Driver`] and [`backend.Conn`] interfaces and calls [`backend.Register`] in it's [`init()`]. Please note that [`backend.Conn`] must be thread-safe. A great place to start is to read the [`no-op`] driver which comes out-of-the-box with Chihaya and is meant to be used for public trackers. + +[`init()`]: http://golang.org/ref/spec#Program_execution +[`database/sql`]: http://godoc.org/database/sql +[`backend`]: http://godoc.org/github.com/chihaya/chihaya/backend +[`backend.Register`]: http://godoc.org/github.com/chihaya/chihaya/backend#Register +[`backend.Driver`]: http://godoc.org/github.com/chihaya/chihaya/backend#Driver +[`backend.Conn`]: http://godoc.org/github.com/chihaya/chihaya/backend#Conn +[`no-op`]: http://godoc.org/github.com/chihaya/chihaya/backend/noop + +## Creating a binary with your own driver + +Chihaya is designed to be extended. If you require more than the drivers provided out-of-the-box, you are free to create your own and then produce your own custom Chihaya binary. To create this binary, simply create your own main package, import your custom drivers, then call [`chihaya.Boot`] from main. + +[`chihaya.Boot`]: http://godoc.org/github.com/chihaya/chihaya + +### Example + +```go +package main + +import ( + "github.com/chihaya/chihaya" + + // Import any of your own drivers. + _ "github.com/yourusername/chihaya-custom-backend" +) + +func main() { + // Start Chihaya normally. + chihaya.Boot() +} +```