Made Server an interface, for expandability.

geesefs-0-30-9
Aaron Jacobs 2015-03-24 16:08:42 +11:00
parent fb40c200a9
commit cfc692da07
2 changed files with 8 additions and 7 deletions

View File

@ -22,9 +22,11 @@ import (
"golang.org/x/net/context"
)
// A Server is a function that reads ops from the supplied Connection,
// responding to them as appropriate.
type Server func(*Connection)
// A type that knows how to serve ops read from a connection.
type Server interface {
// Read and serve ops from the supplied connection until EOF.
ServeOps(*Connection)
}
// A struct representing the status of a mount operation, with a method that
// waits for unmounting.
@ -130,7 +132,7 @@ func Mount(
// Serve the connection in the background. When done, set the join status.
go func() {
server(connection)
server.ServeOps(connection)
mfs.joinStatus = connection.close()
close(mfs.joinStatusAvailable)
}()

View File

@ -33,11 +33,10 @@ import (
//
// Each file contains the string "Hello, world!".
func NewHelloFS(clock timeutil.Clock) (server fuse.Server, err error) {
fs := &helloFS{
server = &helloFS{
Clock: clock,
}
server = fuse.Server(fs.serve)
return
}
@ -45,7 +44,7 @@ type helloFS struct {
Clock timeutil.Clock
}
func (fs *helloFS) serve(c *fuse.Connection) {
func (fs *helloFS) ServeOps(c *fuse.Connection) {
for {
op, err := c.ReadOp()
if err == io.EOF {