LEFT | RIGHT |
1 package state | 1 package state |
2 | 2 |
3 import ( | 3 import ( |
4 "errors" | 4 "errors" |
5 "fmt" | 5 "fmt" |
6 "strings" | 6 "strings" |
7 "time" | 7 "time" |
8 | 8 |
9 "labix.org/v2/mgo" | 9 "labix.org/v2/mgo" |
10 "labix.org/v2/mgo/txn" | 10 "labix.org/v2/mgo/txn" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 log.Printf("state: opening state; mongo addresses: %q", info.Addrs) | 47 log.Printf("state: opening state; mongo addresses: %q", info.Addrs) |
48 if len(info.Addrs) == 0 { | 48 if len(info.Addrs) == 0 { |
49 return nil, errors.New("no mongo addresses") | 49 return nil, errors.New("no mongo addresses") |
50 } | 50 } |
51 var ( | 51 var ( |
52 session *mgo.Session | 52 session *mgo.Session |
53 fwd *sshForwarder | 53 fwd *sshForwarder |
54 err error | 54 err error |
55 ) | 55 ) |
56 if len(info.CACert) == 0 { | 56 if len(info.CACert) == 0 { |
57 » » return nil, errors.New("no CA certificate") | 57 » » return nil, errors.New("missing CA certificate") |
58 } | 58 } |
59 if info.UseSSH { | 59 if info.UseSSH { |
60 // TODO implement authorization on SSL connection; drop sshDial. | 60 // TODO implement authorization on SSL connection; drop sshDial. |
61 if len(info.Addrs) > 1 { | 61 if len(info.Addrs) > 1 { |
62 return nil, errors.New("ssh connect does not support mul
tiple addresses") | 62 return nil, errors.New("ssh connect does not support mul
tiple addresses") |
63 } | 63 } |
64 fwd, session, err = sshDial(info.Addrs[0], "") | 64 fwd, session, err = sshDial(info.Addrs[0], "") |
65 } else { | 65 } else { |
66 session, err = mgo.DialWithTimeout(strings.Join(info.Addrs, ",")
, 10*time.Minute) | 66 session, err = mgo.DialWithTimeout(strings.Join(info.Addrs, ",")
, 10*time.Minute) |
67 } | 67 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 err1 := st.watcher.Stop() | 195 err1 := st.watcher.Stop() |
196 err2 := st.pwatcher.Stop() | 196 err2 := st.pwatcher.Stop() |
197 st.db.Session.Close() | 197 st.db.Session.Close() |
198 for _, err := range []error{err1, err2} { | 198 for _, err := range []error{err1, err2} { |
199 if err != nil { | 199 if err != nil { |
200 return err | 200 return err |
201 } | 201 } |
202 } | 202 } |
203 return nil | 203 return nil |
204 } | 204 } |
LEFT | RIGHT |