docs: move driver docs into backend/README.md

This commit is contained in:
Jimmy Zelinskie 2015-01-28 22:51:09 -05:00
parent 87c68f1973
commit 88df5e2c74
2 changed files with 35 additions and 36 deletions

View file

@ -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!

35
backend/README.md Normal file
View file

@ -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()
}
```