-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathetcdresolver.go
56 lines (49 loc) · 1.16 KB
/
etcdresolver.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and contributors.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License Version 2.0
* which accompanies this distribution, and is available at
* http://www.apache.org/licenses/
*
* See the Apache Licence for more details.
*
* Contributors:
* nuxeo.io Team
*/
package main
import "time"
const (
SERVICE_DOMAINTYTPE = "service"
URI_DOMAINTYPE = "uri"
TIME_FORMAT = "2006-01-02 15:04:05"
)
type Service struct {
index string
nodeKey string
domain string
name string
status *Status
lastAccess *time.Time
}
type EtcdResolver struct {
config *Config
watcher *watcher
watchIndex uint64
etcdcron *EtcdCron
}
func NewEtcdResolver(config *Config) (*EtcdResolver, error) {
watcher, error := NewEtcdWatcher(config)
if error != nil {
return nil, error
}
etcdcron, error := NewEtcdCron(config)
if error != nil {
return nil, error
}
return &EtcdResolver{config, watcher, 0, etcdcron}, nil
}
func (resolver *EtcdResolver) init() {
go resolver.etcdcron.init()
resolver.watcher.init()
}