forked from mongodb/mongo-go-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
40 lines (33 loc) · 1.59 KB
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (C) MongoDB, Inc. 2017-present.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
package connection
import "context"
// Server is used to handle incoming Connections. It handles the boilerplate of accepting a
// Connection and cleaning it up after running a Handler. This also makes it easier to build
// higher level processors, like proxies, by handling the life cycle of the underlying
// connection.
//
// TODO(GODRIVER-269): Implement this.
type Server struct {
Addr Addr
Handler Handler
}
// ListenAndServe listens on the network address srv.Addr and calls Serve to
// handle requests on incoming connections. If srv.Addr is blank, "localhost:27017"
// is used.
func (*Server) ListenAndServe() error { return nil }
// Serve accepts incoming connections on the Listener l, creating a new service
// goroutine for each. The service goroutines call srv.Handler and do not processing
// beforehand. When srv.Handler returns, the connection is closed.
func (*Server) Serve(Listener) error { return nil }
// Shutdown gracefully shuts down the server by closing the active listeners. Shutdown
// does not handle or wait for all open connections to close and return before returning.
func (*Server) Shutdown(context.Context) error { return nil }
// Handler handles an individual Connection. Returning signals that the Connection
// is no longer needed and can be closed.
type Handler interface {
HandleConnection(Connection)
}