Made Server an interface, for expandability.
parent
fb40c200a9
commit
cfc692da07
|
@ -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)
|
||||
}()
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue