mirror of https://github.com/docker/docs.git
Godep update github.com/docker/docker/pkg/...
Signed-off-by: Dong Chen <dongluo.chen@docker.com>
This commit is contained in:
parent
c73f17fb6e
commit
bc27cedd8c
|
|
@ -33,38 +33,38 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/docker/docker/pkg/discovery",
|
"ImportPath": "github.com/docker/docker/pkg/discovery",
|
||||||
"Comment": "v1.4.1-9107-gf11b6a2",
|
"Comment": "v1.4.1-10581-gb65fd8e",
|
||||||
"Rev": "f11b6a2ab313a03d051dd6f69d264d0482df72d6"
|
"Rev": "b65fd8e879545e8c9b859ea9b6b825ac50c79e46"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/docker/docker/pkg/ioutils",
|
"ImportPath": "github.com/docker/docker/pkg/ioutils",
|
||||||
"Comment": "v1.4.1-9107-gf11b6a2",
|
"Comment": "v1.4.1-10581-gb65fd8e",
|
||||||
"Rev": "f11b6a2ab313a03d051dd6f69d264d0482df72d6"
|
"Rev": "b65fd8e879545e8c9b859ea9b6b825ac50c79e46"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/docker/docker/pkg/longpath",
|
"ImportPath": "github.com/docker/docker/pkg/longpath",
|
||||||
"Comment": "v1.4.1-9107-gf11b6a2",
|
"Comment": "v1.4.1-10581-gb65fd8e",
|
||||||
"Rev": "f11b6a2ab313a03d051dd6f69d264d0482df72d6"
|
"Rev": "b65fd8e879545e8c9b859ea9b6b825ac50c79e46"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/docker/docker/pkg/parsers/kernel",
|
"ImportPath": "github.com/docker/docker/pkg/parsers/kernel",
|
||||||
"Comment": "v1.4.1-9107-gf11b6a2",
|
"Comment": "v1.4.1-10581-gb65fd8e",
|
||||||
"Rev": "f11b6a2ab313a03d051dd6f69d264d0482df72d6"
|
"Rev": "b65fd8e879545e8c9b859ea9b6b825ac50c79e46"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/docker/docker/pkg/random",
|
"ImportPath": "github.com/docker/docker/pkg/random",
|
||||||
"Comment": "v1.4.1-9107-gf11b6a2",
|
"Comment": "v1.4.1-10581-gb65fd8e",
|
||||||
"Rev": "f11b6a2ab313a03d051dd6f69d264d0482df72d6"
|
"Rev": "b65fd8e879545e8c9b859ea9b6b825ac50c79e46"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/docker/docker/pkg/stringid",
|
"ImportPath": "github.com/docker/docker/pkg/stringid",
|
||||||
"Comment": "v1.4.1-9107-gf11b6a2",
|
"Comment": "v1.4.1-10581-gb65fd8e",
|
||||||
"Rev": "f11b6a2ab313a03d051dd6f69d264d0482df72d6"
|
"Rev": "b65fd8e879545e8c9b859ea9b6b825ac50c79e46"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/docker/docker/pkg/version",
|
"ImportPath": "github.com/docker/docker/pkg/version",
|
||||||
"Comment": "v1.4.1-9107-gf11b6a2",
|
"Comment": "v1.4.1-10581-gb65fd8e",
|
||||||
"Rev": "f11b6a2ab313a03d051dd6f69d264d0482df72d6"
|
"Rev": "b65fd8e879545e8c9b859ea9b6b825ac50c79e46"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/docker/engine-api/types",
|
"ImportPath": "github.com/docker/engine-api/types",
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,8 @@ import (
|
||||||
var (
|
var (
|
||||||
// Backends is a global map of discovery backends indexed by their
|
// Backends is a global map of discovery backends indexed by their
|
||||||
// associated scheme.
|
// associated scheme.
|
||||||
backends map[string]Backend
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
backends = make(map[string]Backend)
|
backends = make(map[string]Backend)
|
||||||
}
|
)
|
||||||
|
|
||||||
// Register makes a discovery backend available by the provided scheme.
|
// Register makes a discovery backend available by the provided scheme.
|
||||||
// If Register is called twice with the same scheme an error is returned.
|
// If Register is called twice with the same scheme an error is returned.
|
||||||
|
|
@ -42,7 +38,7 @@ func parse(rawurl string) (string, string) {
|
||||||
|
|
||||||
// ParseAdvertise parses the --cluster-advertise daemon config which accepts
|
// ParseAdvertise parses the --cluster-advertise daemon config which accepts
|
||||||
// <ip-address>:<port> or <interface-name>:<port>
|
// <ip-address>:<port> or <interface-name>:<port>
|
||||||
func ParseAdvertise(store, advertise string) (string, error) {
|
func ParseAdvertise(advertise string) (string, error) {
|
||||||
var (
|
var (
|
||||||
iface *net.Interface
|
iface *net.Interface
|
||||||
addrs []net.Addr
|
addrs []net.Addr
|
||||||
|
|
@ -93,7 +89,7 @@ func ParseAdvertise(store, advertise string) (string, error) {
|
||||||
return "", fmt.Errorf("couldnt find a valid ip-address in interface %s", advertise)
|
return "", fmt.Errorf("couldnt find a valid ip-address in interface %s", advertise)
|
||||||
}
|
}
|
||||||
|
|
||||||
addr = fmt.Sprintf("%s:%s", addr, port)
|
addr = net.JoinHostPort(addr, port)
|
||||||
return addr, nil
|
return addr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
package discovery
|
package discovery
|
||||||
|
|
||||||
import (
|
import "net"
|
||||||
"fmt"
|
|
||||||
"net"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewEntry creates a new entry.
|
// NewEntry creates a new entry.
|
||||||
func NewEntry(url string) (*Entry, error) {
|
func NewEntry(url string) (*Entry, error) {
|
||||||
|
|
@ -27,7 +24,7 @@ func (e *Entry) Equals(cmp *Entry) bool {
|
||||||
|
|
||||||
// String returns the string form of an entry.
|
// String returns the string form of an entry.
|
||||||
func (e *Entry) String() string {
|
func (e *Entry) String() string {
|
||||||
return fmt.Sprintf("%s:%s", e.Host, e.Port)
|
return net.JoinHostPort(e.Host, e.Port)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Entries is a list of *Entry with some helpers.
|
// Entries is a list of *Entry with some helpers.
|
||||||
|
|
|
||||||
83
Godeps/_workspace/src/github.com/docker/docker/pkg/discovery/memory/memory.go
generated
vendored
Normal file
83
Godeps/_workspace/src/github.com/docker/docker/pkg/discovery/memory/memory.go
generated
vendored
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
package memory
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/docker/docker/pkg/discovery"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Discovery implements a descovery backend that keeps
|
||||||
|
// data in memory.
|
||||||
|
type Discovery struct {
|
||||||
|
heartbeat time.Duration
|
||||||
|
values []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
Init()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Init registers the memory backend on demand.
|
||||||
|
func Init() {
|
||||||
|
discovery.Register("memory", &Discovery{})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize sets the heartbeat for the memory backend.
|
||||||
|
func (s *Discovery) Initialize(_ string, heartbeat time.Duration, _ time.Duration, _ map[string]string) error {
|
||||||
|
s.heartbeat = heartbeat
|
||||||
|
s.values = make([]string, 0)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Watch sends periodic discovery updates to a channel.
|
||||||
|
func (s *Discovery) Watch(stopCh <-chan struct{}) (<-chan discovery.Entries, <-chan error) {
|
||||||
|
ch := make(chan discovery.Entries)
|
||||||
|
errCh := make(chan error)
|
||||||
|
ticker := time.NewTicker(s.heartbeat)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
defer close(errCh)
|
||||||
|
defer close(ch)
|
||||||
|
|
||||||
|
// Send the initial entries if available.
|
||||||
|
var currentEntries discovery.Entries
|
||||||
|
if len(s.values) > 0 {
|
||||||
|
var err error
|
||||||
|
currentEntries, err = discovery.CreateEntries(s.values)
|
||||||
|
if err != nil {
|
||||||
|
errCh <- err
|
||||||
|
} else {
|
||||||
|
ch <- currentEntries
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Periodically send updates.
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-ticker.C:
|
||||||
|
newEntries, err := discovery.CreateEntries(s.values)
|
||||||
|
if err != nil {
|
||||||
|
errCh <- err
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the file has really changed.
|
||||||
|
if !newEntries.Equals(currentEntries) {
|
||||||
|
ch <- newEntries
|
||||||
|
}
|
||||||
|
currentEntries = newEntries
|
||||||
|
case <-stopCh:
|
||||||
|
ticker.Stop()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
return ch, errCh
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register adds a new address to the discovery.
|
||||||
|
func (s *Discovery) Register(addr string) error {
|
||||||
|
s.values = append(s.values, addr)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
package ioutils
|
package ioutils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -11,45 +9,43 @@ import (
|
||||||
// is a flush. In addition, the Close method can be called to intercept
|
// is a flush. In addition, the Close method can be called to intercept
|
||||||
// Read/Write calls if the targets lifecycle has already ended.
|
// Read/Write calls if the targets lifecycle has already ended.
|
||||||
type WriteFlusher struct {
|
type WriteFlusher struct {
|
||||||
mu sync.Mutex
|
w io.Writer
|
||||||
w io.Writer
|
flusher flusher
|
||||||
flusher http.Flusher
|
flushed chan struct{}
|
||||||
flushed bool
|
flushedOnce sync.Once
|
||||||
closed error
|
closed chan struct{}
|
||||||
|
closeLock sync.Mutex
|
||||||
// TODO(stevvooe): Use channel for closed instead, remove mutex. Using a
|
|
||||||
// channel will allow one to properly order the operations.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var errWriteFlusherClosed = errors.New("writeflusher: closed")
|
type flusher interface {
|
||||||
|
Flush()
|
||||||
|
}
|
||||||
|
|
||||||
|
var errWriteFlusherClosed = io.EOF
|
||||||
|
|
||||||
func (wf *WriteFlusher) Write(b []byte) (n int, err error) {
|
func (wf *WriteFlusher) Write(b []byte) (n int, err error) {
|
||||||
wf.mu.Lock()
|
select {
|
||||||
defer wf.mu.Unlock()
|
case <-wf.closed:
|
||||||
if wf.closed != nil {
|
return 0, errWriteFlusherClosed
|
||||||
return 0, wf.closed
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
n, err = wf.w.Write(b)
|
n, err = wf.w.Write(b)
|
||||||
wf.flush() // every write is a flush.
|
wf.Flush() // every write is a flush.
|
||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush the stream immediately.
|
// Flush the stream immediately.
|
||||||
func (wf *WriteFlusher) Flush() {
|
func (wf *WriteFlusher) Flush() {
|
||||||
wf.mu.Lock()
|
select {
|
||||||
defer wf.mu.Unlock()
|
case <-wf.closed:
|
||||||
|
|
||||||
wf.flush()
|
|
||||||
}
|
|
||||||
|
|
||||||
// flush the stream immediately without taking a lock. Used internally.
|
|
||||||
func (wf *WriteFlusher) flush() {
|
|
||||||
if wf.closed != nil {
|
|
||||||
return
|
return
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
wf.flushed = true
|
wf.flushedOnce.Do(func() {
|
||||||
|
close(wf.flushed)
|
||||||
|
})
|
||||||
wf.flusher.Flush()
|
wf.flusher.Flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,34 +55,38 @@ func (wf *WriteFlusher) Flushed() bool {
|
||||||
// BUG(stevvooe): Remove this method. Its use is inherently racy. Seems to
|
// BUG(stevvooe): Remove this method. Its use is inherently racy. Seems to
|
||||||
// be used to detect whether or a response code has been issued or not.
|
// be used to detect whether or a response code has been issued or not.
|
||||||
// Another hook should be used instead.
|
// Another hook should be used instead.
|
||||||
wf.mu.Lock()
|
var flushed bool
|
||||||
defer wf.mu.Unlock()
|
select {
|
||||||
|
case <-wf.flushed:
|
||||||
return wf.flushed
|
flushed = true
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
return flushed
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close closes the write flusher, disallowing any further writes to the
|
// Close closes the write flusher, disallowing any further writes to the
|
||||||
// target. After the flusher is closed, all calls to write or flush will
|
// target. After the flusher is closed, all calls to write or flush will
|
||||||
// result in an error.
|
// result in an error.
|
||||||
func (wf *WriteFlusher) Close() error {
|
func (wf *WriteFlusher) Close() error {
|
||||||
wf.mu.Lock()
|
wf.closeLock.Lock()
|
||||||
defer wf.mu.Unlock()
|
defer wf.closeLock.Unlock()
|
||||||
|
|
||||||
if wf.closed != nil {
|
select {
|
||||||
return wf.closed
|
case <-wf.closed:
|
||||||
|
return errWriteFlusherClosed
|
||||||
|
default:
|
||||||
|
close(wf.closed)
|
||||||
}
|
}
|
||||||
|
|
||||||
wf.closed = errWriteFlusherClosed
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWriteFlusher returns a new WriteFlusher.
|
// NewWriteFlusher returns a new WriteFlusher.
|
||||||
func NewWriteFlusher(w io.Writer) *WriteFlusher {
|
func NewWriteFlusher(w io.Writer) *WriteFlusher {
|
||||||
var flusher http.Flusher
|
var fl flusher
|
||||||
if f, ok := w.(http.Flusher); ok {
|
if f, ok := w.(flusher); ok {
|
||||||
flusher = f
|
fl = f
|
||||||
} else {
|
} else {
|
||||||
flusher = &NopFlusher{}
|
fl = &NopFlusher{}
|
||||||
}
|
}
|
||||||
return &WriteFlusher{w: w, flusher: flusher}
|
return &WriteFlusher{w: w, flusher: fl, closed: make(chan struct{}), flushed: make(chan struct{})}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue