MCPcopy Index your code
hub / github.com/koding/kite / NewHelloKite

Function NewHelloKite

kontrol/helper_test.go:99–135  ·  view source on GitHub ↗
(name string, conf *Config)

Source from the content-addressed store, hash-verified

97}
98
99func NewHelloKite(name string, conf *Config) (*HelloKite, error) {
100 k := kite.New(name, "1.0.0")
101 k.Config = conf.Config.Copy()
102 k.Config.Port = 0
103 k.Config.KiteKey = testutil.NewToken(name, conf.Private, conf.Public).Raw
104 // k.SetLogLevel(kite.DEBUG)
105
106 k.HandleFunc("hello", func(r *kite.Request) (interface{}, error) {
107 return fmt.Sprintf("%s says hello", name), nil
108 })
109
110 go k.Run()
111 <-k.ServerReadyNotify()
112
113 u := &url.URL{
114 Scheme: "http",
115 Host: fmt.Sprintf("127.0.0.1:%d", k.Port()),
116 Path: "/kite",
117 }
118
119 hk := &HelloKite{
120 Kite: k,
121 URL: u,
122 clients: make(map[string]*kite.Client),
123 regs: make(chan *protocol.RegisterResult, 16),
124 toks: make(chan struct{}, 16),
125 renew: make(chan struct{}, 16),
126 }
127
128 hk.Kite.OnRegister(hk.onRegister)
129
130 if err := conf.Register(hk); err != nil {
131 return nil, err
132 }
133
134 return hk, nil
135}
136
137func (hk *HelloKite) onRegister(reg *protocol.RegisterResult) {
138 hk.regs <- reg

Callers 4

createTestKiteFunction · 0.85
TestUpdateKeysFunction · 0.85
TestRegisterDenyEvilFunction · 0.85
TestMultipleRegisterFunction · 0.85

Calls 7

CopyMethod · 0.80
HandleFuncMethod · 0.80
ServerReadyNotifyMethod · 0.80
OnRegisterMethod · 0.80
RunMethod · 0.45
PortMethod · 0.45
RegisterMethod · 0.45

Tested by

no test coverage detected