本文整理汇总了Golang中github.com/bketelsen/skynet.NewConsoleLogger函数的典型用法代码示例。如果您正苦于以下问题:Golang NewConsoleLogger函数的具体用法?Golang NewConsoleLogger怎么用?Golang NewConsoleLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewConsoleLogger函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
config, _ := skynet.GetClientConfig()
var err error
config.Log = skynet.NewConsoleLogger("TestServiceClient", os.Stderr)
client := client.NewClient(config)
// This will not fail if no services currently exist, as connections are created on demand
// this saves from chicken and egg issues with dependencies between services
service := client.GetService("TestService", "", "", "") // any version, any region, any host
// This on the other hand will fail if it can't find a service to connect to
in := map[string]interface{}{
"data": "Upcase me!!",
}
out := map[string]interface{}{}
err = service.Send(nil, "Upcase", in, &out)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(out["data"].(string))
}
开发者ID:yahame,项目名称:skynet,代码行数:27,代码来源:client.go
示例2: initializeConfig
func initializeConfig(c *skynet.ServiceConfig) {
if c.Log == nil {
c.Log = skynet.NewConsoleLogger(os.Stderr)
}
if c.Name == "" {
c.Name = "SkynetService"
}
if c.Version == "" {
c.Version = "1"
}
if c.Region == "" {
c.Region = "local"
}
if c.ServiceAddr.IPAddress == "" {
c.ServiceAddr.IPAddress = "127.0.0.1"
}
if c.ServiceAddr.Port == 0 {
c.ServiceAddr.Port = 9000
}
if c.DoozerConfig == nil {
c.DoozerConfig = &skynet.DoozerConfig{
Uri: "127.0.0.1:8046",
AutoDiscover: true,
}
}
}
开发者ID:skelterjohn,项目名称:skynet,代码行数:32,代码来源:service.go
示例3: main
func main() {
f := NewFibonacci()
config, _ := skynet.GetServiceConfigFromFlags()
config.Name = "Fibonacci"
config.Version = "1"
config.Region = "Jersey"
var err error
mlogger, err := skynet.NewMongoLogger("localhost", "skynet", "log", config.UUID)
clogger := skynet.NewConsoleLogger(os.Stdout)
config.Log = skynet.NewMultiLogger(mlogger, clogger)
if err != nil {
config.Log.Item("Could not connect to mongo db for logging")
}
service := service.CreateService(f, config)
// handle panic so that we remove ourselves from the pool in case of catastrophic failure
defer func() {
service.Shutdown()
if err := recover(); err != nil {
log.Println("Unrecovered error occured: ", err)
}
}()
// If we pass false here service will not be Registered
// we could do other work/tasks by implementing the Started method and calling Register() when we're ready
waiter := service.Start(true)
// waiting on the sync.WaitGroup returned by service.Start() will wait for the service to finish running.
waiter.Wait()
}
开发者ID:skelterjohn,项目名称:skynet,代码行数:32,代码来源:fibservice.go
示例4: doSomething
func doSomething(q *client.Query, do func(*rpc.Client, skynet.Logger)) {
log := skynet.NewConsoleLogger(os.Stderr)
for _, instance := range q.FindInstances() {
conn, err := net.Dial("tcp", instance.Config.AdminAddr.String())
if err != nil {
log.Item(err)
continue
}
rpcClient := bsonrpc.NewClient(conn)
do(rpcClient, log)
conn.Close()
}
}
开发者ID:skelterjohn,项目名称:skynet,代码行数:14,代码来源:admin.go
示例5: getDaemonServiceClient
func getDaemonServiceClient(q *client.Query) (c *client.Client, service *client.ServiceClient) {
config, _ := skynet.GetClientConfigFromFlags(os.Args...)
config.Log = skynet.NewConsoleLogger(os.Stderr)
c = client.NewClient(config)
registered := true
query := &client.Query{
DoozerConn: c.DoozerConn,
Service: "SkynetDaemon",
//Host: "127.0.0.1",
Registered: ®istered,
}
service = c.GetServiceFromQuery(query)
return
}
开发者ID:sdmajor,项目名称:skynet,代码行数:17,代码来源:remote.go
示例6: main
// Daemon will run and maintain skynet services.
//
// Daemon will initially deploy those specified in the file given in the "-config" option
//
// Daemon will run the "SkynetDeployment" service, which can be used to remotely spawn
// new services on the host.
func main() {
config, args := skynet.GetServiceConfig()
config.Name = "SkynetDaemon"
config.Version = "1"
// skydaemon does not listen to admin RPC requests
config.AdminAddr = nil
var err error
mlogger, err := skynet.NewMongoLogger("localhost", "skynet", "log", config.UUID)
clogger := skynet.NewConsoleLogger("skydaemon", os.Stdout)
config.Log = skynet.NewMultiLogger(mlogger, clogger)
if err != nil {
config.Log.Item("Could not connect to mongo db for logging")
}
deployment := &SkynetDaemon{
Log: config.Log,
Services: map[string]*SubService{},
}
s := service.CreateService(deployment, config)
deployment.Service = s
// handle panic so that we remove ourselves from the pool in case of catastrophic failure
/*defer func() {
s.Shutdown()
if err := recover(); err != nil {
log.Println("Unrecovered error occured: ", err)
}
}()*/
if len(args) == 1 {
err := deployConfig(deployment, args[0])
if err != nil {
config.Log.Item(err)
}
}
// If we pass false here service will not be Registered
// we could do other work/tasks by implementing the Started method and calling Register() when we're ready
s.Start(true).Wait()
}
开发者ID:yahame,项目名称:skynet,代码行数:49,代码来源:main.go
示例7: NewClient
func NewClient(config *skynet.ClientConfig) *Client {
if config.Log == nil {
config.Log = skynet.NewConsoleLogger(os.Stderr)
}
if config.ConnectionPoolSize == 0 {
config.ConnectionPoolSize = 1
}
client := &Client{
Config: config,
DoozerConn: skynet.NewDoozerConnectionFromConfig(*config.DoozerConfig, config.Log),
Log: config.Log,
}
client.Log.Item(config)
client.DoozerConn.Connect()
return client
}
开发者ID:dahankzter,项目名称:skynet,代码行数:21,代码来源:client.go
示例8: main
func main() {
var err error
flag.Parse()
log = skynet.NewConsoleLogger("dashboard", os.Stderr)
if *mgoserver == "" {
log.Item(skynet.MongoError{"", "No mongodb server url (both -mgoserver and SKYNET_MGOSERVER missing)"})
}
mlogger, err := skynet.NewMongoLogger(*mgoserver, "skynet", "log", skynet.UUID())
if err != nil {
log.Item(skynet.MongoError{Addr: "Could not connect to mongo db for logging", Err: err.Error()})
}
log = skynet.NewMultiLogger(mlogger, log)
DC = Doozer()
http.HandleFunc("/", indexHandler)
http.HandleFunc("/logs/search", searchHandler)
http.Handle("/media/", http.StripPrefix("/media/", http.FileServer(http.Dir(*webroot+"/tmpl"))))
http.Handle("/favicon.ico", http.FileServer(http.Dir(*webroot+"/tmpl/images")))
http.Handle("/logs/ws", websocket.Handler(wsHandler))
im := client.NewInstanceMonitor(DC)
http.Handle("/instances/ws", websocket.Handler(func(ws *websocket.Conn) {
NewInstanceSocket(ws, im)
}))
// Cache templates
layoutTmpl = template.Must(template.ParseFiles(*webroot + "/tmpl/layout.html.template"))
indexTmpl = template.Must(template.ParseFiles(*webroot + "/tmpl/index.html.template"))
searchTmpl = template.Must(template.ParseFiles(*webroot + "/tmpl/search.html.template"))
err = http.ListenAndServe(*addr, nil)
if err != nil {
log.Panic("ListenAndServe: " + err.Error())
}
}
开发者ID:yahame,项目名称:skynet,代码行数:39,代码来源:dashboard.go
示例9: NewClient
func NewClient(config *skynet.ClientConfig) *Client {
if config.Log == nil {
config.Log = skynet.NewConsoleLogger(os.Stderr)
}
if config.ConnectionPoolSize == 0 {
config.ConnectionPoolSize = 1
}
client := &Client{
Config: config,
DoozerConn: skynet.NewDoozerConnectionFromConfig(*config.DoozerConfig, config.Log),
Log: config.Log,
servicePools: map[string]*servicePool{},
}
client.Log.Item(config)
client.DoozerConn.Connect()
client.instanceMonitor = NewInstanceMonitor(client.DoozerConn)
return client
}
开发者ID:sdmajor,项目名称:skynet,代码行数:24,代码来源:client.go
示例10: NewClient
func NewClient(config *skynet.ClientConfig) *Client {
if config.Log == nil {
config.Log = skynet.NewConsoleLogger("skynet", os.Stderr)
}
if config.MaxConnectionsToInstance == 0 {
panic("must have at least one connection allowed to an instance")
}
client := &Client{
Config: config,
DoozerConn: skynet.NewDoozerConnectionFromConfig(*config.DoozerConfig, config.Log),
Log: config.Log,
servicePools: map[string]*servicePool{},
}
client.Log.Item(config)
client.DoozerConn.Connect()
client.instanceMonitor = NewInstanceMonitor(client.DoozerConn)
return client
}
开发者ID:yahame,项目名称:skynet,代码行数:24,代码来源:client.go
示例11: main
func main() {
logger := skynet.NewConsoleLogger("Sky", os.Stdout)
config = skynet.ClientConfig{
DoozerConfig: &skynet.DoozerConfig{},
Log: logger,
}
skynet.FlagsForClient(&config, flagset)
err := flagset.Parse(os.Args[1:])
if err != nil {
fmt.Println(err)
return
}
query := &skynet.Query{
DoozerConn: Doozer(config.DoozerConfig),
Service: *ServiceNameFlag,
Version: *VersionFlag,
Host: *HostFlag,
Region: *RegionFlag,
Port: *PortFlag,
}
fmt.Println(flagset.Args())
switch flagset.Arg(0) {
case "help", "h":
CommandLineHelp()
case "services":
ListServices(query)
case "hosts":
ListHosts(query)
case "regions":
ListRegions(query)
case "instances":
ListInstances(query)
case "versions":
ListServiceVersions(query)
case "topology":
PrintTopology(query)
case "register":
Register(query)
case "unregister":
Unregister(query)
case "stop":
Stop(query)
case "restart":
Restart(query)
case "deploy":
args := flagset.Args()
fmt.Println(args)
if len(args) < 2 {
fmt.Println("Usage: deploy <service path> <args>")
return
}
Deploy(query, args[1], args[2:]...)
case "cli":
InteractiveShell()
default:
CommandLineHelp()
}
}
开发者ID:yahame,项目名称:skynet,代码行数:66,代码来源:sky.go
注:本文中的github.com/bketelsen/skynet.NewConsoleLogger函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论