本文整理汇总了Golang中github.com/willfaught/company/prototype/company/offer.Offer.Name方法的典型用法代码示例。如果您正苦于以下问题:Golang Offer.Name方法的具体用法?Golang Offer.Name怎么用?Golang Offer.Name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/willfaught/company/prototype/company/offer.Offer
的用法示例。
在下文中一共展示了Offer.Name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ExampleMethod
// ExampleMethod shows using a method.
func ExampleMethod() {
log.Println("\n***** ExampleMethod *****\n")
// Server
var server = offers.MustNewServer(configure("Server"), offers.Offers{Configuration: configure("Server")}, ":4020")
go func() {
if err := server.Start(); err != nil {
panic(err)
}
}()
// Client
var client = offers.MustNewClient(configure("Client"), ":4020").ForContext(offers.Context{ID: tigertonic.RandomBase62String(8)}).(offers.Client)
// Use
var m = offer.Offer{Interface: client, Name: "nerddomo"}
m, err := m.New()
if err != nil {
panic(err)
}
log.Printf("New: Got: %# v\n\n", pretty.Formatter(simplify(m)))
m, err = client.Get(m.ID)
if err != nil {
panic(err)
}
log.Printf("Get: Got: %# v\n\n", pretty.Formatter(simplify(m)))
m.Name = "bar"
m, err = m.Set()
if err != nil {
panic(err)
}
log.Printf("Set: Got: %# v\n\n", pretty.Formatter(simplify(m)))
m, err = m.Delete()
if err != nil {
panic(err)
}
log.Printf("Delete: Got: %# v\n\n", pretty.Formatter(simplify(m)))
// Client
if err := client.Close(); err != nil {
panic(err)
}
// Server
if err := server.Stop(); err != nil {
panic(err)
}
}
示例2: ExampleGracefulRestart
// ExampleGracefulRestart shows enabling graceful restarts.
func ExampleGracefulRestart() {
log.Println("\n***** ExampleGracefulRestart *****\n")
// Server
var gn = &gracenet.Net{}
var listener, err = gn.Listen("tcp", ":4545")
if err != nil {
panic(err)
}
var server = offers.Server{Listener: listener, Server: rpc.NewServer()}
server.RegisterName("Marketing", offers.Receiver{Configuration: configure("Server"), Interface: offers.Offers{Configuration: configure("Server")}})
go func() {
if err := server.Start(); err != nil {
panic(err)
}
}()
var done = make(chan struct{})
go func() {
var c = make(chan os.Signal, 10)
signal.Notify(c, syscall.SIGTERM, syscall.SIGUSR2)
for {
var s = <-c
switch s {
case syscall.SIGTERM:
log.Println("Received SIGTERM\n")
signal.Stop(c)
done <- struct{}{}
return
case syscall.SIGUSR2:
log.Println("Received SIGUSR2\n")
if _, err := gn.StartProcess(); err != nil {
log.Fatalln("Error:", err)
}
}
}
}()
// Client
var client = offers.MustNewClient(configure("Client"), ":4545").ForContext(offers.Context{ID: tigertonic.RandomBase62String(8)}).(offers.Client)
// Use
Main:
for {
var m = offer.Offer{Interface: client, Name: "nerddomo"}
m, err := m.New()
if err != nil {
panic(err)
}
log.Printf("New: Got: %# v\n\n", pretty.Formatter(simplify(m)))
m, err = client.Get(m.ID)
if err != nil {
panic(err)
}
log.Printf("Get: Got: %# v\n\n", pretty.Formatter(simplify(m)))
m.Name = "bar"
m, err = m.Set()
if err != nil {
panic(err)
}
log.Printf("Set: Got: %# v\n\n", pretty.Formatter(simplify(m)))
m, err = m.Delete()
if err != nil {
panic(err)
}
log.Printf("Delete: Got: %# v\n\n", pretty.Formatter(simplify(m)))
log.Println()
select {
case <-done:
break Main
case <-time.After(time.Second * 10):
}
}
// Client
if err := client.Close(); err != nil {
panic(err)
}
// Server
if err := server.Stop(); err != nil {
panic(err)
}
}