本文整理汇总了Golang中github.com/cloudfoundry/yagnats/fakeyagnats.Connect函数的典型用法代码示例。如果您正苦于以下问题:Golang Connect函数的具体用法?Golang Connect怎么用?Golang Connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Connect函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ParseConfig
func ParseConfig(logLevel *bool, configFile, logFilePath *string) (*Config, *gosteno.Logger, error) {
config := &Config{OutgoingPort: 8080}
err := cfcomponent.ReadConfigInto(config, *configFile)
if err != nil {
return nil, nil, err
}
config.setDefaults()
config.Host = net.JoinHostPort(config.Host, strconv.FormatUint(uint64(config.IncomingPort), 10))
logger := cfcomponent.NewLogger(*logLevel, *logFilePath, "loggregator trafficcontroller", config.Config)
logger.Info("Startup: Setting up the loggregator traffic controller")
if len(config.NatsHosts) == 0 {
logger.Warn("Startup: Did not receive a NATS host - not going to register component")
cfcomponent.DefaultYagnatsClientProvider = func(logger *gosteno.Logger, c *cfcomponent.Config) (yagnats.NATSConn, error) {
return fakeyagnats.Connect(), nil
}
}
err = config.validate(logger)
if err != nil {
return nil, nil, err
}
return config, logger, nil
}
开发者ID:khj0651,项目名称:loggregator,代码行数:25,代码来源:main.go
示例2: initializeComponent
func initializeComponent(config metronConfig, instrumentables []instrumentation.Instrumentable, logger *gosteno.Logger) cfcomponent.Component {
if len(config.NatsHosts) == 0 {
logger.Warn("Startup: Did not receive a NATS host - not going to register component")
cfcomponent.DefaultYagnatsClientProvider = func(logger *gosteno.Logger, c *cfcomponent.Config) (yagnats.NATSConn, error) {
return fakeyagnats.Connect(), nil
}
}
component, err := cfcomponent.NewComponent(logger, "MetronAgent", config.Index, &metronHealthMonitor{}, config.VarzPort, []string{config.VarzUser, config.VarzPass}, instrumentables)
if err != nil {
panic(err)
}
return component
}
开发者ID:khj0651,项目名称:loggregator,代码行数:15,代码来源:main.go
示例3: main
func main() {
flag.Parse()
// ** Config Setup
config := &Config{}
err := cfcomponent.ReadConfigInto(config, *configFile)
if err != nil {
panic(err)
}
dropsonde.Initialize(config.MetronAddress, "dea_logging_agent")
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
panic(err)
}
pprof.StartCPUProfile(f)
defer func() {
pprof.StopCPUProfile()
f.Close()
}()
}
if *memprofile != "" {
f, err := os.Create(*memprofile)
if err != nil {
panic(err)
}
go func() {
defer f.Close()
ticker := time.NewTicker(time.Second * 1)
defer ticker.Stop()
for {
<-ticker.C
pprof.WriteHeapProfile(f)
}
}()
}
logger := cfcomponent.NewLogger(*logLevel, *logFilePath, "deaagent", config.Config)
logger.Info("Startup: Setting up the loggregator dea logging agent")
if len(config.NatsHosts) == 0 {
logger.Warn("Startup: Did not receive a NATS host - not going to register component")
cfcomponent.DefaultYagnatsClientProvider = func(logger *gosteno.Logger, c *cfcomponent.Config) (yagnats.NATSConn, error) {
return fakeyagnats.Connect(), nil
}
}
err = config.validate(logger)
if err != nil {
panic(err)
}
// ** END Config Setup
agent := deaagent.NewAgent(*instancesJsonFilePath, logger)
go agent.Start()
killChan := make(chan os.Signal)
signal.Notify(killChan, os.Interrupt)
for {
select {
case <-cfcomponent.RegisterGoRoutineDumpSignalChannel():
cfcomponent.DumpGoRoutine()
case <-killChan:
logger.Info("Shutting down")
return
}
}
}
开发者ID:Amit-PivotalLabs,项目名称:loggregator,代码行数:73,代码来源:main.go
示例4:
proxyObj proxy.Proxy
fakeAccessLogger *fakelogger.FakeAccessLogger
r *registry.RouteRegistry
)
Context("ServeHTTP", func() {
BeforeEach(func() {
tlsConfig := &tls.Config{
CipherSuites: conf.CipherSuites,
InsecureSkipVerify: conf.SSLSkipValidation,
}
fakeAccessLogger = &fakelogger.FakeAccessLogger{}
mbus := fakeyagnats.Connect()
r = registry.NewRouteRegistry(conf, mbus, new(fakes.FakeRouteReporter))
proxyObj = proxy.NewProxy(proxy.ProxyArgs{
EndpointTimeout: conf.EndpointTimeout,
Ip: conf.Ip,
TraceKey: conf.TraceKey,
Registry: r,
Reporter: nullVarz{},
AccessLogger: fakeAccessLogger,
SecureCookies: conf.SecureCookies,
TLSConfig: tlsConfig,
RouteServiceEnabled: conf.RouteServiceEnabled,
RouteServiceTimeout: conf.RouteServiceTimeout,
Crypto: crypto,
CryptoPrev: cryptoPrev,
开发者ID:qinguoan,项目名称:vulcan,代码行数:31,代码来源:proxy_unit_test.go
示例5:
"github.com/pivotal-golang/lager/lagertest"
"encoding/json"
"fmt"
"net/http"
"time"
)
var _ = Describe("Varz", func() {
var Varz Varz
var Registry *registry.RouteRegistry
var logger lager.Logger
BeforeEach(func() {
logger = lagertest.NewTestLogger("test")
Registry = registry.NewRouteRegistry(logger, config.DefaultConfig(), fakeyagnats.Connect(), new(fakes.FakeRouteRegistryReporter))
Varz = NewVarz(Registry)
})
It("contains the following items", func() {
v := Varz
members := []string{
"responses_2xx",
"responses_3xx",
"responses_4xx",
"responses_5xx",
"responses_xxx",
"latency",
"rate",
"tags",
开发者ID:sunatthegilddotcom,项目名称:gorouter,代码行数:31,代码来源:varz_test.go
示例6: main
func main() {
seed := time.Now().UnixNano()
rand.Seed(seed)
flag.Parse()
runtime.GOMAXPROCS(runtime.NumCPU())
localIp, err := localip.LocalIP()
if err != nil {
panic(errors.New("Unable to resolve own IP address: " + err.Error()))
}
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
panic(err)
}
pprof.StartCPUProfile(f)
defer func() {
pprof.StopCPUProfile()
f.Close()
}()
}
if *memprofile != "" {
f, err := os.Create(*memprofile)
if err != nil {
panic(err)
}
go func() {
defer f.Close()
ticker := time.NewTicker(time.Second * 1)
defer ticker.Stop()
for {
<-ticker.C
pprof.WriteHeapProfile(f)
}
}()
}
conf, logger := ParseConfig(logLevel, configFile, logFilePath)
dropsonde.Initialize(conf.MetronAddress, "DopplerServer")
if len(conf.NatsHosts) == 0 {
logger.Warn("Startup: Did not receive a NATS host - not going to regsiter component")
cfcomponent.DefaultYagnatsClientProvider = func(logger *gosteno.Logger, c *cfcomponent.Config) (yagnats.NATSConn, error) {
return fakeyagnats.Connect(), nil
}
}
err = conf.Validate(logger)
if err != nil {
panic(err)
}
storeAdapter := NewStoreAdapter(conf.EtcdUrls, conf.EtcdMaxConcurrentRequests)
doppler := New(localIp, conf, logger, storeAdapter, conf.MessageDrainBufferSize, "doppler")
if err != nil {
panic(err)
}
go doppler.Start()
logger.Info("Startup: doppler server started.")
killChan := make(chan os.Signal)
signal.Notify(killChan, os.Kill, os.Interrupt)
storeAdapter = NewStoreAdapter(conf.EtcdUrls, conf.EtcdMaxConcurrentRequests)
StartHeartbeats(localIp, config.HeartbeatInterval, conf, storeAdapter, logger)
for {
select {
case <-cfcomponent.RegisterGoRoutineDumpSignalChannel():
cfcomponent.DumpGoRoutine()
case <-killChan:
logger.Info("Shutting down")
doppler.Stop()
return
}
}
}
开发者ID:JimmyMa,项目名称:loggregator,代码行数:84,代码来源:main.go
示例7:
"time"
)
var _ = Describe("RouteRegistry", func() {
var r *RouteRegistry
var messageBus *fakeyagnats.FakeNATSConn
var fooEndpoint, barEndpoint, bar2Endpoint *route.Endpoint
var configObj *config.Config
BeforeEach(func() {
configObj = config.DefaultConfig()
configObj.PruneStaleDropletsInterval = 50 * time.Millisecond
configObj.DropletStaleThreshold = 10 * time.Millisecond
messageBus = fakeyagnats.Connect()
r = NewRouteRegistry(configObj, messageBus)
fooEndpoint = route.NewEndpoint("12345", "192.168.1.1", 1234,
"id1", map[string]string{
"runtime": "ruby18",
"framework": "sinatra",
}, -1, "")
barEndpoint = route.NewEndpoint("54321", "192.168.1.2", 4321,
"id2", map[string]string{
"runtime": "javascript",
"framework": "node",
}, -1, "https://my-rs.com")
bar2Endpoint = route.NewEndpoint("54321", "192.168.1.3", 1234,
"id3", map[string]string{
开发者ID:janitorsun,项目名称:gorouter,代码行数:31,代码来源:registry_test.go
示例8:
"github.com/cloudfoundry/yagnats/fakeyagnats"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"encoding/json"
"fmt"
"net/http"
"time"
)
var _ = Describe("Varz", func() {
var Varz Varz
var Registry *registry.RouteRegistry
BeforeEach(func() {
Registry = registry.NewRouteRegistry(config.DefaultConfig(), fakeyagnats.Connect())
Varz = NewVarz(Registry)
})
It("contains the following items", func() {
v := Varz
members := []string{
"responses_2xx",
"responses_3xx",
"responses_4xx",
"responses_5xx",
"responses_xxx",
"latency",
"rate",
"tags",
开发者ID:jungle0755,项目名称:gorouter,代码行数:31,代码来源:varz_test.go
注:本文中的github.com/cloudfoundry/yagnats/fakeyagnats.Connect函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论