id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
28,300 | topfreegames/pitaya | session/session.go | Get | func (s *Session) Get(key string) interface{} {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return nil
}
return v
} | go | func (s *Session) Get(key string) interface{} {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return nil
}
return v
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Get",
"(",
"key",
"string",
")",
"interface",
"{",
"}",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"RUnlock",
"(",
")",
"\n\n",
"v",
",",
"ok",
":=",
"s",
".",
"data",
"[",
"key",
"]",
... | // Get returns a key value | [
"Get",
"returns",
"a",
"key",
"value"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/session.go#L379-L388 |
28,301 | topfreegames/pitaya | session/session.go | Int | func (s *Session) Int(key string) int {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(int)
if !ok {
return 0
}
return value
} | go | func (s *Session) Int(key string) int {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(int)
if !ok {
return 0
}
return value
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Int",
"(",
"key",
"string",
")",
"int",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"RUnlock",
"(",
")",
"\n\n",
"v",
",",
"ok",
":=",
"s",
".",
"data",
"[",
"key",
"]",
"\n",
"if",
"!"... | // Int returns the value associated with the key as a int. | [
"Int",
"returns",
"the",
"value",
"associated",
"with",
"the",
"key",
"as",
"a",
"int",
"."
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/session.go#L391-L405 |
28,302 | topfreegames/pitaya | session/session.go | Int8 | func (s *Session) Int8(key string) int8 {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(int8)
if !ok {
return 0
}
return value
} | go | func (s *Session) Int8(key string) int8 {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(int8)
if !ok {
return 0
}
return value
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Int8",
"(",
"key",
"string",
")",
"int8",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"RUnlock",
"(",
")",
"\n\n",
"v",
",",
"ok",
":=",
"s",
".",
"data",
"[",
"key",
"]",
"\n",
"if",
"... | // Int8 returns the value associated with the key as a int8. | [
"Int8",
"returns",
"the",
"value",
"associated",
"with",
"the",
"key",
"as",
"a",
"int8",
"."
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/session.go#L408-L422 |
28,303 | topfreegames/pitaya | session/session.go | Int16 | func (s *Session) Int16(key string) int16 {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(int16)
if !ok {
return 0
}
return value
} | go | func (s *Session) Int16(key string) int16 {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(int16)
if !ok {
return 0
}
return value
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Int16",
"(",
"key",
"string",
")",
"int16",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"RUnlock",
"(",
")",
"\n\n",
"v",
",",
"ok",
":=",
"s",
".",
"data",
"[",
"key",
"]",
"\n",
"if",
... | // Int16 returns the value associated with the key as a int16. | [
"Int16",
"returns",
"the",
"value",
"associated",
"with",
"the",
"key",
"as",
"a",
"int16",
"."
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/session.go#L425-L439 |
28,304 | topfreegames/pitaya | session/session.go | Int32 | func (s *Session) Int32(key string) int32 {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(int32)
if !ok {
return 0
}
return value
} | go | func (s *Session) Int32(key string) int32 {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(int32)
if !ok {
return 0
}
return value
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Int32",
"(",
"key",
"string",
")",
"int32",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"RUnlock",
"(",
")",
"\n\n",
"v",
",",
"ok",
":=",
"s",
".",
"data",
"[",
"key",
"]",
"\n",
"if",
... | // Int32 returns the value associated with the key as a int32. | [
"Int32",
"returns",
"the",
"value",
"associated",
"with",
"the",
"key",
"as",
"a",
"int32",
"."
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/session.go#L442-L456 |
28,305 | topfreegames/pitaya | session/session.go | Int64 | func (s *Session) Int64(key string) int64 {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(int64)
if !ok {
return 0
}
return value
} | go | func (s *Session) Int64(key string) int64 {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(int64)
if !ok {
return 0
}
return value
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Int64",
"(",
"key",
"string",
")",
"int64",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"RUnlock",
"(",
")",
"\n\n",
"v",
",",
"ok",
":=",
"s",
".",
"data",
"[",
"key",
"]",
"\n",
"if",
... | // Int64 returns the value associated with the key as a int64. | [
"Int64",
"returns",
"the",
"value",
"associated",
"with",
"the",
"key",
"as",
"a",
"int64",
"."
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/session.go#L459-L473 |
28,306 | topfreegames/pitaya | session/session.go | Uint | func (s *Session) Uint(key string) uint {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(uint)
if !ok {
return 0
}
return value
} | go | func (s *Session) Uint(key string) uint {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(uint)
if !ok {
return 0
}
return value
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Uint",
"(",
"key",
"string",
")",
"uint",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"RUnlock",
"(",
")",
"\n\n",
"v",
",",
"ok",
":=",
"s",
".",
"data",
"[",
"key",
"]",
"\n",
"if",
"... | // Uint returns the value associated with the key as a uint. | [
"Uint",
"returns",
"the",
"value",
"associated",
"with",
"the",
"key",
"as",
"a",
"uint",
"."
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/session.go#L476-L490 |
28,307 | topfreegames/pitaya | session/session.go | Uint8 | func (s *Session) Uint8(key string) uint8 {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(uint8)
if !ok {
return 0
}
return value
} | go | func (s *Session) Uint8(key string) uint8 {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(uint8)
if !ok {
return 0
}
return value
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Uint8",
"(",
"key",
"string",
")",
"uint8",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"RUnlock",
"(",
")",
"\n\n",
"v",
",",
"ok",
":=",
"s",
".",
"data",
"[",
"key",
"]",
"\n",
"if",
... | // Uint8 returns the value associated with the key as a uint8. | [
"Uint8",
"returns",
"the",
"value",
"associated",
"with",
"the",
"key",
"as",
"a",
"uint8",
"."
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/session.go#L493-L507 |
28,308 | topfreegames/pitaya | session/session.go | Uint16 | func (s *Session) Uint16(key string) uint16 {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(uint16)
if !ok {
return 0
}
return value
} | go | func (s *Session) Uint16(key string) uint16 {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(uint16)
if !ok {
return 0
}
return value
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Uint16",
"(",
"key",
"string",
")",
"uint16",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"RUnlock",
"(",
")",
"\n\n",
"v",
",",
"ok",
":=",
"s",
".",
"data",
"[",
"key",
"]",
"\n",
"if",... | // Uint16 returns the value associated with the key as a uint16. | [
"Uint16",
"returns",
"the",
"value",
"associated",
"with",
"the",
"key",
"as",
"a",
"uint16",
"."
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/session.go#L510-L524 |
28,309 | topfreegames/pitaya | session/session.go | Uint32 | func (s *Session) Uint32(key string) uint32 {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(uint32)
if !ok {
return 0
}
return value
} | go | func (s *Session) Uint32(key string) uint32 {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(uint32)
if !ok {
return 0
}
return value
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Uint32",
"(",
"key",
"string",
")",
"uint32",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"RUnlock",
"(",
")",
"\n\n",
"v",
",",
"ok",
":=",
"s",
".",
"data",
"[",
"key",
"]",
"\n",
"if",... | // Uint32 returns the value associated with the key as a uint32. | [
"Uint32",
"returns",
"the",
"value",
"associated",
"with",
"the",
"key",
"as",
"a",
"uint32",
"."
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/session.go#L527-L541 |
28,310 | topfreegames/pitaya | session/session.go | Uint64 | func (s *Session) Uint64(key string) uint64 {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(uint64)
if !ok {
return 0
}
return value
} | go | func (s *Session) Uint64(key string) uint64 {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(uint64)
if !ok {
return 0
}
return value
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Uint64",
"(",
"key",
"string",
")",
"uint64",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"RUnlock",
"(",
")",
"\n\n",
"v",
",",
"ok",
":=",
"s",
".",
"data",
"[",
"key",
"]",
"\n",
"if",... | // Uint64 returns the value associated with the key as a uint64. | [
"Uint64",
"returns",
"the",
"value",
"associated",
"with",
"the",
"key",
"as",
"a",
"uint64",
"."
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/session.go#L544-L558 |
28,311 | topfreegames/pitaya | session/session.go | Float32 | func (s *Session) Float32(key string) float32 {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(float32)
if !ok {
return 0
}
return value
} | go | func (s *Session) Float32(key string) float32 {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(float32)
if !ok {
return 0
}
return value
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Float32",
"(",
"key",
"string",
")",
"float32",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"RUnlock",
"(",
")",
"\n\n",
"v",
",",
"ok",
":=",
"s",
".",
"data",
"[",
"key",
"]",
"\n",
"if... | // Float32 returns the value associated with the key as a float32. | [
"Float32",
"returns",
"the",
"value",
"associated",
"with",
"the",
"key",
"as",
"a",
"float32",
"."
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/session.go#L561-L575 |
28,312 | topfreegames/pitaya | session/session.go | Float64 | func (s *Session) Float64(key string) float64 {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(float64)
if !ok {
return 0
}
return value
} | go | func (s *Session) Float64(key string) float64 {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return 0
}
value, ok := v.(float64)
if !ok {
return 0
}
return value
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Float64",
"(",
"key",
"string",
")",
"float64",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"RUnlock",
"(",
")",
"\n\n",
"v",
",",
"ok",
":=",
"s",
".",
"data",
"[",
"key",
"]",
"\n",
"if... | // Float64 returns the value associated with the key as a float64. | [
"Float64",
"returns",
"the",
"value",
"associated",
"with",
"the",
"key",
"as",
"a",
"float64",
"."
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/session.go#L578-L592 |
28,313 | topfreegames/pitaya | session/session.go | String | func (s *Session) String(key string) string {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return ""
}
value, ok := v.(string)
if !ok {
return ""
}
return value
} | go | func (s *Session) String(key string) string {
s.RLock()
defer s.RUnlock()
v, ok := s.data[key]
if !ok {
return ""
}
value, ok := v.(string)
if !ok {
return ""
}
return value
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"String",
"(",
"key",
"string",
")",
"string",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"RUnlock",
"(",
")",
"\n\n",
"v",
",",
"ok",
":=",
"s",
".",
"data",
"[",
"key",
"]",
"\n",
"if",... | // String returns the value associated with the key as a string. | [
"String",
"returns",
"the",
"value",
"associated",
"with",
"the",
"key",
"as",
"a",
"string",
"."
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/session.go#L595-L609 |
28,314 | topfreegames/pitaya | session/session.go | PushToFront | func (s *Session) PushToFront(ctx context.Context) error {
if s.IsFrontend {
return constants.ErrFrontSessionCantPushToFront
}
return s.sendRequestToFront(ctx, constants.SessionPushRoute, true)
} | go | func (s *Session) PushToFront(ctx context.Context) error {
if s.IsFrontend {
return constants.ErrFrontSessionCantPushToFront
}
return s.sendRequestToFront(ctx, constants.SessionPushRoute, true)
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"PushToFront",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"if",
"s",
".",
"IsFrontend",
"{",
"return",
"constants",
".",
"ErrFrontSessionCantPushToFront",
"\n",
"}",
"\n",
"return",
"s",
".",
"sendReque... | // PushToFront updates the session in the frontend | [
"PushToFront",
"updates",
"the",
"session",
"in",
"the",
"frontend"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/session.go#L624-L629 |
28,315 | topfreegames/pitaya | session/session.go | Clear | func (s *Session) Clear() {
s.Lock()
defer s.Unlock()
s.uid = ""
s.data = map[string]interface{}{}
s.updateEncodedData()
} | go | func (s *Session) Clear() {
s.Lock()
defer s.Unlock()
s.uid = ""
s.data = map[string]interface{}{}
s.updateEncodedData()
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Clear",
"(",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n\n",
"s",
".",
"uid",
"=",
"\"",
"\"",
"\n",
"s",
".",
"data",
"=",
"map",
"[",
"string",
"]",
"inter... | // Clear releases all data related to current session | [
"Clear",
"releases",
"all",
"data",
"related",
"to",
"current",
"session"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/session.go#L632-L639 |
28,316 | topfreegames/pitaya | session/session.go | SetHandshakeData | func (s *Session) SetHandshakeData(data *HandshakeData) {
s.Lock()
defer s.Unlock()
s.handshakeData = data
} | go | func (s *Session) SetHandshakeData(data *HandshakeData) {
s.Lock()
defer s.Unlock()
s.handshakeData = data
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"SetHandshakeData",
"(",
"data",
"*",
"HandshakeData",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n\n",
"s",
".",
"handshakeData",
"=",
"data",
"\n",
"}"
] | // SetHandshakeData sets the handshake data received by the client. | [
"SetHandshakeData",
"sets",
"the",
"handshake",
"data",
"received",
"by",
"the",
"client",
"."
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/session/session.go#L642-L647 |
28,317 | topfreegames/pitaya | serialize/protobuf/protobuf.go | Marshal | func (s *Serializer) Marshal(v interface{}) ([]byte, error) {
pb, ok := v.(proto.Message)
if !ok {
return nil, constants.ErrWrongValueType
}
return proto.Marshal(pb)
} | go | func (s *Serializer) Marshal(v interface{}) ([]byte, error) {
pb, ok := v.(proto.Message)
if !ok {
return nil, constants.ErrWrongValueType
}
return proto.Marshal(pb)
} | [
"func",
"(",
"s",
"*",
"Serializer",
")",
"Marshal",
"(",
"v",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"pb",
",",
"ok",
":=",
"v",
".",
"(",
"proto",
".",
"Message",
")",
"\n",
"if",
"!",
"ok",
"{",
"return"... | // Marshal returns the protobuf encoding of v. | [
"Marshal",
"returns",
"the",
"protobuf",
"encoding",
"of",
"v",
"."
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/serialize/protobuf/protobuf.go#L37-L43 |
28,318 | topfreegames/pitaya | serialize/protobuf/protobuf.go | Unmarshal | func (s *Serializer) Unmarshal(data []byte, v interface{}) error {
pb, ok := v.(proto.Message)
if !ok {
return constants.ErrWrongValueType
}
return proto.Unmarshal(data, pb)
} | go | func (s *Serializer) Unmarshal(data []byte, v interface{}) error {
pb, ok := v.(proto.Message)
if !ok {
return constants.ErrWrongValueType
}
return proto.Unmarshal(data, pb)
} | [
"func",
"(",
"s",
"*",
"Serializer",
")",
"Unmarshal",
"(",
"data",
"[",
"]",
"byte",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"pb",
",",
"ok",
":=",
"v",
".",
"(",
"proto",
".",
"Message",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
... | // Unmarshal parses the protobuf-encoded data and stores the result
// in the value pointed to by v. | [
"Unmarshal",
"parses",
"the",
"protobuf",
"-",
"encoded",
"data",
"and",
"stores",
"the",
"result",
"in",
"the",
"value",
"pointed",
"to",
"by",
"v",
"."
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/serialize/protobuf/protobuf.go#L47-L53 |
28,319 | topfreegames/pitaya | timer/timer.go | NewTimer | func NewTimer(fn Func, interval time.Duration, counter int) *Timer {
id := atomic.AddInt64(&Manager.incrementID, 1)
t := &Timer{
ID: id,
fn: fn,
createAt: time.Now().UnixNano(),
interval: interval,
elapse: int64(interval), // first execution will be after interval
counter: counter,
}
// ... | go | func NewTimer(fn Func, interval time.Duration, counter int) *Timer {
id := atomic.AddInt64(&Manager.incrementID, 1)
t := &Timer{
ID: id,
fn: fn,
createAt: time.Now().UnixNano(),
interval: interval,
elapse: int64(interval), // first execution will be after interval
counter: counter,
}
// ... | [
"func",
"NewTimer",
"(",
"fn",
"Func",
",",
"interval",
"time",
".",
"Duration",
",",
"counter",
"int",
")",
"*",
"Timer",
"{",
"id",
":=",
"atomic",
".",
"AddInt64",
"(",
"&",
"Manager",
".",
"incrementID",
",",
"1",
")",
"\n",
"t",
":=",
"&",
"Ti... | // NewTimer creates a cron job | [
"NewTimer",
"creates",
"a",
"cron",
"job"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/timer/timer.go#L97-L111 |
28,320 | topfreegames/pitaya | timer/timer.go | Stop | func (t *Timer) Stop() {
if atomic.LoadInt32(&t.closed) > 0 {
return
}
// guarantee that logic is not blocked
if len(Manager.ChClosingTimer) < timerBacklog {
Manager.ChClosingTimer <- t.ID
atomic.StoreInt32(&t.closed, 1)
} else {
t.counter = 0 // automatically closed in next Cron
}
} | go | func (t *Timer) Stop() {
if atomic.LoadInt32(&t.closed) > 0 {
return
}
// guarantee that logic is not blocked
if len(Manager.ChClosingTimer) < timerBacklog {
Manager.ChClosingTimer <- t.ID
atomic.StoreInt32(&t.closed, 1)
} else {
t.counter = 0 // automatically closed in next Cron
}
} | [
"func",
"(",
"t",
"*",
"Timer",
")",
"Stop",
"(",
")",
"{",
"if",
"atomic",
".",
"LoadInt32",
"(",
"&",
"t",
".",
"closed",
")",
">",
"0",
"{",
"return",
"\n",
"}",
"\n\n",
"// guarantee that logic is not blocked",
"if",
"len",
"(",
"Manager",
".",
"... | // Stop turns off a timer. After Stop, fn will not be called forever | [
"Stop",
"turns",
"off",
"a",
"timer",
".",
"After",
"Stop",
"fn",
"will",
"not",
"be",
"called",
"forever"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/timer/timer.go#L119-L131 |
28,321 | topfreegames/pitaya | timer/timer.go | pexec | func pexec(id int64, fn Func) {
defer func() {
if err := recover(); err != nil {
logger.Log.Errorf("Call timer function error, TimerID=%d, Error=%v", id, err)
}
}()
fn()
} | go | func pexec(id int64, fn Func) {
defer func() {
if err := recover(); err != nil {
logger.Log.Errorf("Call timer function error, TimerID=%d, Error=%v", id, err)
}
}()
fn()
} | [
"func",
"pexec",
"(",
"id",
"int64",
",",
"fn",
"Func",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"err",
":=",
"recover",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Log",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"id",
",",
"err... | // execute job function with protection | [
"execute",
"job",
"function",
"with",
"protection"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/timer/timer.go#L134-L142 |
28,322 | topfreegames/pitaya | conn/codec/mocks/packet_encoder.go | NewMockPacketEncoder | func NewMockPacketEncoder(ctrl *gomock.Controller) *MockPacketEncoder {
mock := &MockPacketEncoder{ctrl: ctrl}
mock.recorder = &MockPacketEncoderMockRecorder{mock}
return mock
} | go | func NewMockPacketEncoder(ctrl *gomock.Controller) *MockPacketEncoder {
mock := &MockPacketEncoder{ctrl: ctrl}
mock.recorder = &MockPacketEncoderMockRecorder{mock}
return mock
} | [
"func",
"NewMockPacketEncoder",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockPacketEncoder",
"{",
"mock",
":=",
"&",
"MockPacketEncoder",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockPacketEncoderMockRecorder",
... | // NewMockPacketEncoder creates a new mock instance | [
"NewMockPacketEncoder",
"creates",
"a",
"new",
"mock",
"instance"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/conn/codec/mocks/packet_encoder.go#L25-L29 |
28,323 | topfreegames/pitaya | cluster/server.go | AsJSONString | func (s *Server) AsJSONString() string {
str, err := json.Marshal(s)
if err != nil {
logger.Log.Errorf("error getting server as json: %s", err.Error())
return ""
}
return string(str)
} | go | func (s *Server) AsJSONString() string {
str, err := json.Marshal(s)
if err != nil {
logger.Log.Errorf("error getting server as json: %s", err.Error())
return ""
}
return string(str)
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"AsJSONString",
"(",
")",
"string",
"{",
"str",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Log",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err"... | // AsJSONString returns the server as a json string | [
"AsJSONString",
"returns",
"the",
"server",
"as",
"a",
"json",
"string"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/cluster/server.go#L59-L66 |
28,324 | topfreegames/pitaya | rpc.go | RPC | func RPC(ctx context.Context, routeStr string, reply proto.Message, arg proto.Message) error {
return doSendRPC(ctx, "", routeStr, reply, arg)
} | go | func RPC(ctx context.Context, routeStr string, reply proto.Message, arg proto.Message) error {
return doSendRPC(ctx, "", routeStr, reply, arg)
} | [
"func",
"RPC",
"(",
"ctx",
"context",
".",
"Context",
",",
"routeStr",
"string",
",",
"reply",
"proto",
".",
"Message",
",",
"arg",
"proto",
".",
"Message",
")",
"error",
"{",
"return",
"doSendRPC",
"(",
"ctx",
",",
"\"",
"\"",
",",
"routeStr",
",",
... | // RPC calls a method in a different server | [
"RPC",
"calls",
"a",
"method",
"in",
"a",
"different",
"server"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/rpc.go#L34-L36 |
28,325 | topfreegames/pitaya | rpc.go | RPCTo | func RPCTo(ctx context.Context, serverID, routeStr string, reply proto.Message, arg proto.Message) error {
return doSendRPC(ctx, serverID, routeStr, reply, arg)
} | go | func RPCTo(ctx context.Context, serverID, routeStr string, reply proto.Message, arg proto.Message) error {
return doSendRPC(ctx, serverID, routeStr, reply, arg)
} | [
"func",
"RPCTo",
"(",
"ctx",
"context",
".",
"Context",
",",
"serverID",
",",
"routeStr",
"string",
",",
"reply",
"proto",
".",
"Message",
",",
"arg",
"proto",
".",
"Message",
")",
"error",
"{",
"return",
"doSendRPC",
"(",
"ctx",
",",
"serverID",
",",
... | // RPCTo send a rpc to a specific server | [
"RPCTo",
"send",
"a",
"rpc",
"to",
"a",
"specific",
"server"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/rpc.go#L39-L41 |
28,326 | topfreegames/pitaya | rpc.go | ReliableRPC | func ReliableRPC(
routeStr string,
metadata map[string]interface{},
reply, arg proto.Message,
) (jid string, err error) {
return app.worker.EnqueueRPC(routeStr, metadata, reply, arg)
} | go | func ReliableRPC(
routeStr string,
metadata map[string]interface{},
reply, arg proto.Message,
) (jid string, err error) {
return app.worker.EnqueueRPC(routeStr, metadata, reply, arg)
} | [
"func",
"ReliableRPC",
"(",
"routeStr",
"string",
",",
"metadata",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"reply",
",",
"arg",
"proto",
".",
"Message",
",",
")",
"(",
"jid",
"string",
",",
"err",
"error",
")",
"{",
"return",
"app",
".... | // ReliableRPC enqueues RPC to worker so it's executed asynchronously
// Default enqueue options are used | [
"ReliableRPC",
"enqueues",
"RPC",
"to",
"worker",
"so",
"it",
"s",
"executed",
"asynchronously",
"Default",
"enqueue",
"options",
"are",
"used"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/rpc.go#L45-L51 |
28,327 | topfreegames/pitaya | rpc.go | ReliableRPCWithOptions | func ReliableRPCWithOptions(
routeStr string,
metadata map[string]interface{},
reply, arg proto.Message,
opts *worker.EnqueueOpts,
) (jid string, err error) {
return app.worker.EnqueueRPCWithOptions(routeStr, metadata, reply, arg, opts)
} | go | func ReliableRPCWithOptions(
routeStr string,
metadata map[string]interface{},
reply, arg proto.Message,
opts *worker.EnqueueOpts,
) (jid string, err error) {
return app.worker.EnqueueRPCWithOptions(routeStr, metadata, reply, arg, opts)
} | [
"func",
"ReliableRPCWithOptions",
"(",
"routeStr",
"string",
",",
"metadata",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"reply",
",",
"arg",
"proto",
".",
"Message",
",",
"opts",
"*",
"worker",
".",
"EnqueueOpts",
",",
")",
"(",
"jid",
"stri... | // ReliableRPCWithOptions enqueues RPC to worker
// Receive worker options for this specific RPC | [
"ReliableRPCWithOptions",
"enqueues",
"RPC",
"to",
"worker",
"Receive",
"worker",
"options",
"for",
"this",
"specific",
"RPC"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/rpc.go#L55-L62 |
28,328 | topfreegames/pitaya | cluster/grpc_rpc_client.go | NewGRPCClient | func NewGRPCClient(
config *config.Config,
server *Server,
metricsReporters []metrics.Reporter,
bindingStorage interfaces.BindingStorage,
infoRetriever InfoRetriever,
) (*GRPCClient, error) {
gs := &GRPCClient{
config: config,
server: server,
metricsReporters: metricsReporters,
binding... | go | func NewGRPCClient(
config *config.Config,
server *Server,
metricsReporters []metrics.Reporter,
bindingStorage interfaces.BindingStorage,
infoRetriever InfoRetriever,
) (*GRPCClient, error) {
gs := &GRPCClient{
config: config,
server: server,
metricsReporters: metricsReporters,
binding... | [
"func",
"NewGRPCClient",
"(",
"config",
"*",
"config",
".",
"Config",
",",
"server",
"*",
"Server",
",",
"metricsReporters",
"[",
"]",
"metrics",
".",
"Reporter",
",",
"bindingStorage",
"interfaces",
".",
"BindingStorage",
",",
"infoRetriever",
"InfoRetriever",
... | // NewGRPCClient returns a new instance of GRPCClient | [
"NewGRPCClient",
"returns",
"a",
"new",
"instance",
"of",
"GRPCClient"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/cluster/grpc_rpc_client.go#L58-L76 |
28,329 | topfreegames/pitaya | cluster/grpc_rpc_client.go | Call | func (gs *GRPCClient) Call(ctx context.Context, rpcType protos.RPCType, route *route.Route, session *session.Session, msg *message.Message, server *Server) (*protos.Response, error) {
parent, err := tracing.ExtractSpan(ctx)
if err != nil {
logger.Log.Warnf("failed to retrieve parent span: %s", err.Error())
}
tags... | go | func (gs *GRPCClient) Call(ctx context.Context, rpcType protos.RPCType, route *route.Route, session *session.Session, msg *message.Message, server *Server) (*protos.Response, error) {
parent, err := tracing.ExtractSpan(ctx)
if err != nil {
logger.Log.Warnf("failed to retrieve parent span: %s", err.Error())
}
tags... | [
"func",
"(",
"gs",
"*",
"GRPCClient",
")",
"Call",
"(",
"ctx",
"context",
".",
"Context",
",",
"rpcType",
"protos",
".",
"RPCType",
",",
"route",
"*",
"route",
".",
"Route",
",",
"session",
"*",
"session",
".",
"Session",
",",
"msg",
"*",
"message",
... | // Call makes a RPC Call | [
"Call",
"makes",
"a",
"RPC",
"Call"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/cluster/grpc_rpc_client.go#L89-L137 |
28,330 | topfreegames/pitaya | cluster/grpc_rpc_client.go | Send | func (gs *GRPCClient) Send(uid string, d []byte) error {
return constants.ErrNotImplemented
} | go | func (gs *GRPCClient) Send(uid string, d []byte) error {
return constants.ErrNotImplemented
} | [
"func",
"(",
"gs",
"*",
"GRPCClient",
")",
"Send",
"(",
"uid",
"string",
",",
"d",
"[",
"]",
"byte",
")",
"error",
"{",
"return",
"constants",
".",
"ErrNotImplemented",
"\n",
"}"
] | // Send not implemented in grpc client | [
"Send",
"not",
"implemented",
"in",
"grpc",
"client"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/cluster/grpc_rpc_client.go#L140-L142 |
28,331 | topfreegames/pitaya | cluster/grpc_rpc_client.go | BroadcastSessionBind | func (gs *GRPCClient) BroadcastSessionBind(uid string) error {
if gs.bindingStorage == nil {
return constants.ErrNoBindingStorageModule
}
fid, _ := gs.bindingStorage.GetUserFrontendID(uid, gs.server.Type)
if fid != "" {
if c, ok := gs.clientMap.Load(fid); ok {
msg := &protos.BindMsg{
Uid: uid,
Fid: g... | go | func (gs *GRPCClient) BroadcastSessionBind(uid string) error {
if gs.bindingStorage == nil {
return constants.ErrNoBindingStorageModule
}
fid, _ := gs.bindingStorage.GetUserFrontendID(uid, gs.server.Type)
if fid != "" {
if c, ok := gs.clientMap.Load(fid); ok {
msg := &protos.BindMsg{
Uid: uid,
Fid: g... | [
"func",
"(",
"gs",
"*",
"GRPCClient",
")",
"BroadcastSessionBind",
"(",
"uid",
"string",
")",
"error",
"{",
"if",
"gs",
".",
"bindingStorage",
"==",
"nil",
"{",
"return",
"constants",
".",
"ErrNoBindingStorageModule",
"\n",
"}",
"\n",
"fid",
",",
"_",
":="... | // BroadcastSessionBind sends the binding information to other servers that may be interested in this info | [
"BroadcastSessionBind",
"sends",
"the",
"binding",
"information",
"to",
"other",
"servers",
"that",
"may",
"be",
"interested",
"in",
"this",
"info"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/cluster/grpc_rpc_client.go#L145-L163 |
28,332 | topfreegames/pitaya | cluster/grpc_rpc_client.go | SendKick | func (gs *GRPCClient) SendKick(userID string, serverType string, kick *protos.KickMsg) error {
var svID string
var err error
if gs.bindingStorage == nil {
return constants.ErrNoBindingStorageModule
}
svID, err = gs.bindingStorage.GetUserFrontendID(userID, serverType)
if err != nil {
return err
}
if c, ok... | go | func (gs *GRPCClient) SendKick(userID string, serverType string, kick *protos.KickMsg) error {
var svID string
var err error
if gs.bindingStorage == nil {
return constants.ErrNoBindingStorageModule
}
svID, err = gs.bindingStorage.GetUserFrontendID(userID, serverType)
if err != nil {
return err
}
if c, ok... | [
"func",
"(",
"gs",
"*",
"GRPCClient",
")",
"SendKick",
"(",
"userID",
"string",
",",
"serverType",
"string",
",",
"kick",
"*",
"protos",
".",
"KickMsg",
")",
"error",
"{",
"var",
"svID",
"string",
"\n",
"var",
"err",
"error",
"\n\n",
"if",
"gs",
".",
... | // SendKick sends a kick to an user | [
"SendKick",
"sends",
"a",
"kick",
"to",
"an",
"user"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/cluster/grpc_rpc_client.go#L166-L186 |
28,333 | topfreegames/pitaya | cluster/grpc_rpc_client.go | AddServer | func (gs *GRPCClient) AddServer(sv *Server) {
var host, port, portKey string
var ok bool
host, portKey = gs.getServerHost(sv)
if host == "" {
logger.Log.Errorf("server %s has no grpcHost specified in metadata", sv.ID)
return
}
if port, ok = sv.Metadata[portKey]; !ok {
logger.Log.Errorf("server %s has no %... | go | func (gs *GRPCClient) AddServer(sv *Server) {
var host, port, portKey string
var ok bool
host, portKey = gs.getServerHost(sv)
if host == "" {
logger.Log.Errorf("server %s has no grpcHost specified in metadata", sv.ID)
return
}
if port, ok = sv.Metadata[portKey]; !ok {
logger.Log.Errorf("server %s has no %... | [
"func",
"(",
"gs",
"*",
"GRPCClient",
")",
"AddServer",
"(",
"sv",
"*",
"Server",
")",
"{",
"var",
"host",
",",
"port",
",",
"portKey",
"string",
"\n",
"var",
"ok",
"bool",
"\n\n",
"host",
",",
"portKey",
"=",
"gs",
".",
"getServerHost",
"(",
"sv",
... | // AddServer is called when a new server is discovered | [
"AddServer",
"is",
"called",
"when",
"a",
"new",
"server",
"is",
"discovered"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/cluster/grpc_rpc_client.go#L214-L238 |
28,334 | topfreegames/pitaya | cluster/grpc_rpc_client.go | RemoveServer | func (gs *GRPCClient) RemoveServer(sv *Server) {
if _, ok := gs.clientMap.Load(sv.ID); ok {
// TODO: do I need to disconnect client?
gs.clientMap.Delete(sv.ID)
logger.Log.Debugf("[grpc client] removed server %s", sv.ID)
}
} | go | func (gs *GRPCClient) RemoveServer(sv *Server) {
if _, ok := gs.clientMap.Load(sv.ID); ok {
// TODO: do I need to disconnect client?
gs.clientMap.Delete(sv.ID)
logger.Log.Debugf("[grpc client] removed server %s", sv.ID)
}
} | [
"func",
"(",
"gs",
"*",
"GRPCClient",
")",
"RemoveServer",
"(",
"sv",
"*",
"Server",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"gs",
".",
"clientMap",
".",
"Load",
"(",
"sv",
".",
"ID",
")",
";",
"ok",
"{",
"// TODO: do I need to disconnect client?",
"gs",... | // RemoveServer is called when a server is removed | [
"RemoveServer",
"is",
"called",
"when",
"a",
"server",
"is",
"removed"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/cluster/grpc_rpc_client.go#L241-L247 |
28,335 | topfreegames/pitaya | serialize/json/json.go | Unmarshal | func (s *Serializer) Unmarshal(data []byte, v interface{}) error {
return json.Unmarshal(data, v)
} | go | func (s *Serializer) Unmarshal(data []byte, v interface{}) error {
return json.Unmarshal(data, v)
} | [
"func",
"(",
"s",
"*",
"Serializer",
")",
"Unmarshal",
"(",
"data",
"[",
"]",
"byte",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"v",
")",
"\n",
"}"
] | // Unmarshal parses the JSON-encoded data and stores the result
// in the value pointed to by v. | [
"Unmarshal",
"parses",
"the",
"JSON",
"-",
"encoded",
"data",
"and",
"stores",
"the",
"result",
"in",
"the",
"value",
"pointed",
"to",
"by",
"v",
"."
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/serialize/json/json.go#L42-L44 |
28,336 | topfreegames/pitaya | examples/demo/pipeline/main.go | HandlerNoArg | func (g *MetagameServer) HandlerNoArg(ctx context.Context) (*HandlerNoArgResponse, error) {
return &HandlerNoArgResponse{
Msg: "ok",
}, nil
} | go | func (g *MetagameServer) HandlerNoArg(ctx context.Context) (*HandlerNoArgResponse, error) {
return &HandlerNoArgResponse{
Msg: "ok",
}, nil
} | [
"func",
"(",
"g",
"*",
"MetagameServer",
")",
"HandlerNoArg",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"HandlerNoArgResponse",
",",
"error",
")",
"{",
"return",
"&",
"HandlerNoArgResponse",
"{",
"Msg",
":",
"\"",
"\"",
",",
"}",
",",
"nil",
... | // HandlerNoArg is a simple handler that do not have any arguments | [
"HandlerNoArg",
"is",
"a",
"simple",
"handler",
"that",
"do",
"not",
"have",
"any",
"arguments"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/examples/demo/pipeline/main.go#L57-L61 |
28,337 | topfreegames/pitaya | examples/demo/pipeline/main.go | simpleAfter | func (g *MetagameServer) simpleAfter(ctx context.Context, resp interface{}, err error) (interface{}, error) {
logger := pitaya.GetDefaultLoggerFromCtx(ctx)
logger.Infof("Simple After exec - response: %v , error: %v", resp, err)
return resp, err
} | go | func (g *MetagameServer) simpleAfter(ctx context.Context, resp interface{}, err error) (interface{}, error) {
logger := pitaya.GetDefaultLoggerFromCtx(ctx)
logger.Infof("Simple After exec - response: %v , error: %v", resp, err)
return resp, err
} | [
"func",
"(",
"g",
"*",
"MetagameServer",
")",
"simpleAfter",
"(",
"ctx",
"context",
".",
"Context",
",",
"resp",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"logger",
":=",
"pitaya",
".",
"GetD... | // Simple example of an after pipeline. The 2nd argument is the handler response. | [
"Simple",
"example",
"of",
"an",
"after",
"pipeline",
".",
"The",
"2nd",
"argument",
"is",
"the",
"handler",
"response",
"."
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/examples/demo/pipeline/main.go#L84-L89 |
28,338 | topfreegames/pitaya | component.go | Register | func Register(c component.Component, options ...component.Option) {
handlerComp = append(handlerComp, regComp{c, options})
} | go | func Register(c component.Component, options ...component.Option) {
handlerComp = append(handlerComp, regComp{c, options})
} | [
"func",
"Register",
"(",
"c",
"component",
".",
"Component",
",",
"options",
"...",
"component",
".",
"Option",
")",
"{",
"handlerComp",
"=",
"append",
"(",
"handlerComp",
",",
"regComp",
"{",
"c",
",",
"options",
"}",
")",
"\n",
"}"
] | // Register register a component with options | [
"Register",
"register",
"a",
"component",
"with",
"options"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/component.go#L39-L41 |
28,339 | topfreegames/pitaya | component.go | RegisterRemote | func RegisterRemote(c component.Component, options ...component.Option) {
remoteComp = append(remoteComp, regComp{c, options})
} | go | func RegisterRemote(c component.Component, options ...component.Option) {
remoteComp = append(remoteComp, regComp{c, options})
} | [
"func",
"RegisterRemote",
"(",
"c",
"component",
".",
"Component",
",",
"options",
"...",
"component",
".",
"Option",
")",
"{",
"remoteComp",
"=",
"append",
"(",
"remoteComp",
",",
"regComp",
"{",
"c",
",",
"options",
"}",
")",
"\n",
"}"
] | // RegisterRemote register a remote component with options | [
"RegisterRemote",
"register",
"a",
"remote",
"component",
"with",
"options"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/component.go#L44-L46 |
28,340 | topfreegames/pitaya | cluster/nats_rpc_server.go | GetUserMessagesTopic | func GetUserMessagesTopic(uid string, svType string) string {
return fmt.Sprintf("pitaya/%s/user/%s/push", svType, uid)
} | go | func GetUserMessagesTopic(uid string, svType string) string {
return fmt.Sprintf("pitaya/%s/user/%s/push", svType, uid)
} | [
"func",
"GetUserMessagesTopic",
"(",
"uid",
"string",
",",
"svType",
"string",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"svType",
",",
"uid",
")",
"\n",
"}"
] | // GetUserMessagesTopic get the topic for user | [
"GetUserMessagesTopic",
"get",
"the",
"topic",
"for",
"user"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/cluster/nats_rpc_server.go#L115-L117 |
28,341 | topfreegames/pitaya | cluster/nats_rpc_server.go | GetUserKickTopic | func GetUserKickTopic(uid string, svType string) string {
return fmt.Sprintf("pitaya/%s/user/%s/kick", svType, uid)
} | go | func GetUserKickTopic(uid string, svType string) string {
return fmt.Sprintf("pitaya/%s/user/%s/kick", svType, uid)
} | [
"func",
"GetUserKickTopic",
"(",
"uid",
"string",
",",
"svType",
"string",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"svType",
",",
"uid",
")",
"\n",
"}"
] | // GetUserKickTopic get the topic for kicking an user | [
"GetUserKickTopic",
"get",
"the",
"topic",
"for",
"kicking",
"an",
"user"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/cluster/nats_rpc_server.go#L120-L122 |
28,342 | topfreegames/pitaya | cluster/nats_rpc_server.go | onSessionBind | func (ns *NatsRPCServer) onSessionBind(ctx context.Context, s *session.Session) error {
if ns.server.Frontend {
subu, err := ns.subscribeToUserMessages(s.UID(), ns.server.Type)
if err != nil {
return err
}
subk, err := ns.subscribeToUserKickChannel(s.UID(), ns.server.Type)
if err != nil {
return err
... | go | func (ns *NatsRPCServer) onSessionBind(ctx context.Context, s *session.Session) error {
if ns.server.Frontend {
subu, err := ns.subscribeToUserMessages(s.UID(), ns.server.Type)
if err != nil {
return err
}
subk, err := ns.subscribeToUserKickChannel(s.UID(), ns.server.Type)
if err != nil {
return err
... | [
"func",
"(",
"ns",
"*",
"NatsRPCServer",
")",
"onSessionBind",
"(",
"ctx",
"context",
".",
"Context",
",",
"s",
"*",
"session",
".",
"Session",
")",
"error",
"{",
"if",
"ns",
".",
"server",
".",
"Frontend",
"{",
"subu",
",",
"err",
":=",
"ns",
".",
... | // onSessionBind should be called on each session bind | [
"onSessionBind",
"should",
"be",
"called",
"on",
"each",
"session",
"bind"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/cluster/nats_rpc_server.go#L130-L143 |
28,343 | topfreegames/pitaya | cluster/nats_rpc_server.go | Init | func (ns *NatsRPCServer) Init() error {
// TODO should we have concurrency here? it feels like we should
go ns.handleMessages()
conn, err := setupNatsConn(ns.connString, ns.appDieChan, nats.MaxReconnects(ns.maxReconnectionRetries))
if err != nil {
return err
}
ns.conn = conn
if ns.sub, err = ns.subscribe(getCh... | go | func (ns *NatsRPCServer) Init() error {
// TODO should we have concurrency here? it feels like we should
go ns.handleMessages()
conn, err := setupNatsConn(ns.connString, ns.appDieChan, nats.MaxReconnects(ns.maxReconnectionRetries))
if err != nil {
return err
}
ns.conn = conn
if ns.sub, err = ns.subscribe(getCh... | [
"func",
"(",
"ns",
"*",
"NatsRPCServer",
")",
"Init",
"(",
")",
"error",
"{",
"// TODO should we have concurrency here? it feels like we should",
"go",
"ns",
".",
"handleMessages",
"(",
")",
"\n",
"conn",
",",
"err",
":=",
"setupNatsConn",
"(",
"ns",
".",
"connS... | // Init inits nats rpc server | [
"Init",
"inits",
"nats",
"rpc",
"server"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/cluster/nats_rpc_server.go#L308-L337 |
28,344 | topfreegames/pitaya | route/route.go | NewRoute | func NewRoute(server, service, method string) *Route {
return &Route{server, service, method}
} | go | func NewRoute(server, service, method string) *Route {
return &Route{server, service, method}
} | [
"func",
"NewRoute",
"(",
"server",
",",
"service",
",",
"method",
"string",
")",
"*",
"Route",
"{",
"return",
"&",
"Route",
"{",
"server",
",",
"service",
",",
"method",
"}",
"\n",
"}"
] | // NewRoute creates a new route | [
"NewRoute",
"creates",
"a",
"new",
"route"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/route/route.go#L46-L48 |
28,345 | topfreegames/pitaya | route/route.go | String | func (r *Route) String() string {
if r.SvType != "" {
return fmt.Sprintf("%s.%s.%s", r.SvType, r.Service, r.Method)
}
return r.Short()
} | go | func (r *Route) String() string {
if r.SvType != "" {
return fmt.Sprintf("%s.%s.%s", r.SvType, r.Service, r.Method)
}
return r.Short()
} | [
"func",
"(",
"r",
"*",
"Route",
")",
"String",
"(",
")",
"string",
"{",
"if",
"r",
".",
"SvType",
"!=",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"r",
".",
"SvType",
",",
"r",
".",
"Service",
",",
"r",
".",
"Meth... | // String transforms the route into a string | [
"String",
"transforms",
"the",
"route",
"into",
"a",
"string"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/route/route.go#L51-L56 |
28,346 | topfreegames/pitaya | route/route.go | Short | func (r *Route) Short() string {
return fmt.Sprintf("%s.%s", r.Service, r.Method)
} | go | func (r *Route) Short() string {
return fmt.Sprintf("%s.%s", r.Service, r.Method)
} | [
"func",
"(",
"r",
"*",
"Route",
")",
"Short",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"r",
".",
"Service",
",",
"r",
".",
"Method",
")",
"\n",
"}"
] | // Short transforms the route into a string without the server type | [
"Short",
"transforms",
"the",
"route",
"into",
"a",
"string",
"without",
"the",
"server",
"type"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/route/route.go#L59-L61 |
28,347 | topfreegames/pitaya | route/route.go | Decode | func Decode(route string) (*Route, error) {
r := strings.Split(route, ".")
for _, s := range r {
if strings.TrimSpace(s) == "" {
return nil, ErrRouteFieldCantEmpty
}
}
switch len(r) {
case 3:
return NewRoute(r[0], r[1], r[2]), nil
case 2:
return NewRoute("", r[0], r[1]), nil
default:
logger.Log.Erro... | go | func Decode(route string) (*Route, error) {
r := strings.Split(route, ".")
for _, s := range r {
if strings.TrimSpace(s) == "" {
return nil, ErrRouteFieldCantEmpty
}
}
switch len(r) {
case 3:
return NewRoute(r[0], r[1], r[2]), nil
case 2:
return NewRoute("", r[0], r[1]), nil
default:
logger.Log.Erro... | [
"func",
"Decode",
"(",
"route",
"string",
")",
"(",
"*",
"Route",
",",
"error",
")",
"{",
"r",
":=",
"strings",
".",
"Split",
"(",
"route",
",",
"\"",
"\"",
")",
"\n",
"for",
"_",
",",
"s",
":=",
"range",
"r",
"{",
"if",
"strings",
".",
"TrimSp... | // Decode decodes the route | [
"Decode",
"decodes",
"the",
"route"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/route/route.go#L64-L80 |
28,348 | topfreegames/pitaya | examples/demo/custom_metrics/services/room.go | SetCounter | func (*Room) SetCounter(
ctx context.Context,
arg *messages.SetCounterArg,
) (*messages.Response, error) {
counterMetricName := "my_counter"
for _, reporter := range pitaya.GetMetricsReporters() {
reporter.ReportCount(counterMetricName, map[string]string{
"tag1": arg.Tag1,
"tag2": arg.Tag2,
}, arg.Value)... | go | func (*Room) SetCounter(
ctx context.Context,
arg *messages.SetCounterArg,
) (*messages.Response, error) {
counterMetricName := "my_counter"
for _, reporter := range pitaya.GetMetricsReporters() {
reporter.ReportCount(counterMetricName, map[string]string{
"tag1": arg.Tag1,
"tag2": arg.Tag2,
}, arg.Value)... | [
"func",
"(",
"*",
"Room",
")",
"SetCounter",
"(",
"ctx",
"context",
".",
"Context",
",",
"arg",
"*",
"messages",
".",
"SetCounterArg",
",",
")",
"(",
"*",
"messages",
".",
"Response",
",",
"error",
")",
"{",
"counterMetricName",
":=",
"\"",
"\"",
"\n\n... | // SetCounter sets custom my_counter | [
"SetCounter",
"sets",
"custom",
"my_counter"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/examples/demo/custom_metrics/services/room.go#L17-L31 |
28,349 | topfreegames/pitaya | examples/demo/custom_metrics/services/room.go | SetGauge1 | func (*Room) SetGauge1(
ctx context.Context,
arg *messages.SetGaugeArg,
) (*messages.Response, error) {
counterMetricName := "my_gauge_1"
for _, reporter := range pitaya.GetMetricsReporters() {
reporter.ReportGauge(counterMetricName, map[string]string{
"tag1": arg.Tag,
}, arg.Value)
}
return messages.OKR... | go | func (*Room) SetGauge1(
ctx context.Context,
arg *messages.SetGaugeArg,
) (*messages.Response, error) {
counterMetricName := "my_gauge_1"
for _, reporter := range pitaya.GetMetricsReporters() {
reporter.ReportGauge(counterMetricName, map[string]string{
"tag1": arg.Tag,
}, arg.Value)
}
return messages.OKR... | [
"func",
"(",
"*",
"Room",
")",
"SetGauge1",
"(",
"ctx",
"context",
".",
"Context",
",",
"arg",
"*",
"messages",
".",
"SetGaugeArg",
",",
")",
"(",
"*",
"messages",
".",
"Response",
",",
"error",
")",
"{",
"counterMetricName",
":=",
"\"",
"\"",
"\n\n",
... | // SetGauge1 sets custom my_gauge_1 | [
"SetGauge1",
"sets",
"custom",
"my_gauge_1"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/examples/demo/custom_metrics/services/room.go#L34-L47 |
28,350 | topfreegames/pitaya | examples/demo/custom_metrics/services/room.go | SetSummary | func (*Room) SetSummary(
ctx context.Context,
arg *messages.SetSummaryArg,
) (*messages.Response, error) {
counterMetricName := "my_summary"
for _, reporter := range pitaya.GetMetricsReporters() {
reporter.ReportSummary(counterMetricName, map[string]string{
"tag1": arg.Tag,
}, arg.Value)
}
return message... | go | func (*Room) SetSummary(
ctx context.Context,
arg *messages.SetSummaryArg,
) (*messages.Response, error) {
counterMetricName := "my_summary"
for _, reporter := range pitaya.GetMetricsReporters() {
reporter.ReportSummary(counterMetricName, map[string]string{
"tag1": arg.Tag,
}, arg.Value)
}
return message... | [
"func",
"(",
"*",
"Room",
")",
"SetSummary",
"(",
"ctx",
"context",
".",
"Context",
",",
"arg",
"*",
"messages",
".",
"SetSummaryArg",
",",
")",
"(",
"*",
"messages",
".",
"Response",
",",
"error",
")",
"{",
"counterMetricName",
":=",
"\"",
"\"",
"\n\n... | // SetSummary sets custom my_summary | [
"SetSummary",
"sets",
"custom",
"my_summary"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/examples/demo/custom_metrics/services/room.go#L66-L79 |
28,351 | topfreegames/pitaya | service/remote.go | NewRemoteService | func NewRemoteService(
rpcClient cluster.RPCClient,
rpcServer cluster.RPCServer,
sd cluster.ServiceDiscovery,
encoder codec.PacketEncoder,
serializer serialize.Serializer,
router *router.Router,
messageEncoder message.Encoder,
server *cluster.Server,
) *RemoteService {
return &RemoteService{
services: ... | go | func NewRemoteService(
rpcClient cluster.RPCClient,
rpcServer cluster.RPCServer,
sd cluster.ServiceDiscovery,
encoder codec.PacketEncoder,
serializer serialize.Serializer,
router *router.Router,
messageEncoder message.Encoder,
server *cluster.Server,
) *RemoteService {
return &RemoteService{
services: ... | [
"func",
"NewRemoteService",
"(",
"rpcClient",
"cluster",
".",
"RPCClient",
",",
"rpcServer",
"cluster",
".",
"RPCServer",
",",
"sd",
"cluster",
".",
"ServiceDiscovery",
",",
"encoder",
"codec",
".",
"PacketEncoder",
",",
"serializer",
"serialize",
".",
"Serializer... | // NewRemoteService creates and return a new RemoteService | [
"NewRemoteService",
"creates",
"and",
"return",
"a",
"new",
"RemoteService"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/service/remote.go#L64-L86 |
28,352 | topfreegames/pitaya | service/remote.go | AddRemoteBindingListener | func (r *RemoteService) AddRemoteBindingListener(bindingListener cluster.RemoteBindingListener) {
r.remoteBindingListeners = append(r.remoteBindingListeners, bindingListener)
} | go | func (r *RemoteService) AddRemoteBindingListener(bindingListener cluster.RemoteBindingListener) {
r.remoteBindingListeners = append(r.remoteBindingListeners, bindingListener)
} | [
"func",
"(",
"r",
"*",
"RemoteService",
")",
"AddRemoteBindingListener",
"(",
"bindingListener",
"cluster",
".",
"RemoteBindingListener",
")",
"{",
"r",
".",
"remoteBindingListeners",
"=",
"append",
"(",
"r",
".",
"remoteBindingListeners",
",",
"bindingListener",
")... | // AddRemoteBindingListener adds a listener | [
"AddRemoteBindingListener",
"adds",
"a",
"listener"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/service/remote.go#L122-L124 |
28,353 | topfreegames/pitaya | service/remote.go | Call | func (r *RemoteService) Call(ctx context.Context, req *protos.Request) (*protos.Response, error) {
c, err := util.GetContextFromRequest(req, r.server.ID)
var res *protos.Response
if err != nil {
res = &protos.Response{
Error: &protos.Error{
Code: e.ErrInternalCode,
Msg: err.Error(),
},
}
} else {... | go | func (r *RemoteService) Call(ctx context.Context, req *protos.Request) (*protos.Response, error) {
c, err := util.GetContextFromRequest(req, r.server.ID)
var res *protos.Response
if err != nil {
res = &protos.Response{
Error: &protos.Error{
Code: e.ErrInternalCode,
Msg: err.Error(),
},
}
} else {... | [
"func",
"(",
"r",
"*",
"RemoteService",
")",
"Call",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"protos",
".",
"Request",
")",
"(",
"*",
"protos",
".",
"Response",
",",
"error",
")",
"{",
"c",
",",
"err",
":=",
"util",
".",
"GetContext... | // Call processes a remote call | [
"Call",
"processes",
"a",
"remote",
"call"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/service/remote.go#L127-L147 |
28,354 | topfreegames/pitaya | service/remote.go | SessionBindRemote | func (r *RemoteService) SessionBindRemote(ctx context.Context, msg *protos.BindMsg) (*protos.Response, error) {
for _, r := range r.remoteBindingListeners {
r.OnUserBind(msg.Uid, msg.Fid)
}
return &protos.Response{
Data: []byte("ack"),
}, nil
} | go | func (r *RemoteService) SessionBindRemote(ctx context.Context, msg *protos.BindMsg) (*protos.Response, error) {
for _, r := range r.remoteBindingListeners {
r.OnUserBind(msg.Uid, msg.Fid)
}
return &protos.Response{
Data: []byte("ack"),
}, nil
} | [
"func",
"(",
"r",
"*",
"RemoteService",
")",
"SessionBindRemote",
"(",
"ctx",
"context",
".",
"Context",
",",
"msg",
"*",
"protos",
".",
"BindMsg",
")",
"(",
"*",
"protos",
".",
"Response",
",",
"error",
")",
"{",
"for",
"_",
",",
"r",
":=",
"range",... | // SessionBindRemote is called when a remote server binds a user session and want us to acknowledge it | [
"SessionBindRemote",
"is",
"called",
"when",
"a",
"remote",
"server",
"binds",
"a",
"user",
"session",
"and",
"want",
"us",
"to",
"acknowledge",
"it"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/service/remote.go#L150-L157 |
28,355 | topfreegames/pitaya | service/remote.go | PushToUser | func (r *RemoteService) PushToUser(ctx context.Context, push *protos.Push) (*protos.Response, error) {
logger.Log.Debugf("sending push to user %s: %v", push.GetUid(), string(push.Data))
s := session.GetSessionByUID(push.GetUid())
if s != nil {
err := s.Push(push.Route, push.Data)
if err != nil {
return nil, e... | go | func (r *RemoteService) PushToUser(ctx context.Context, push *protos.Push) (*protos.Response, error) {
logger.Log.Debugf("sending push to user %s: %v", push.GetUid(), string(push.Data))
s := session.GetSessionByUID(push.GetUid())
if s != nil {
err := s.Push(push.Route, push.Data)
if err != nil {
return nil, e... | [
"func",
"(",
"r",
"*",
"RemoteService",
")",
"PushToUser",
"(",
"ctx",
"context",
".",
"Context",
",",
"push",
"*",
"protos",
".",
"Push",
")",
"(",
"*",
"protos",
".",
"Response",
",",
"error",
")",
"{",
"logger",
".",
"Log",
".",
"Debugf",
"(",
"... | // PushToUser sends a push to user | [
"PushToUser",
"sends",
"a",
"push",
"to",
"user"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/service/remote.go#L160-L173 |
28,356 | topfreegames/pitaya | service/remote.go | KickUser | func (r *RemoteService) KickUser(ctx context.Context, kick *protos.KickMsg) (*protos.KickAnswer, error) {
logger.Log.Debugf("sending kick to user %s", kick.GetUserId())
s := session.GetSessionByUID(kick.GetUserId())
if s != nil {
err := s.Kick(ctx)
if err != nil {
return nil, err
}
return &protos.KickAnsw... | go | func (r *RemoteService) KickUser(ctx context.Context, kick *protos.KickMsg) (*protos.KickAnswer, error) {
logger.Log.Debugf("sending kick to user %s", kick.GetUserId())
s := session.GetSessionByUID(kick.GetUserId())
if s != nil {
err := s.Kick(ctx)
if err != nil {
return nil, err
}
return &protos.KickAnsw... | [
"func",
"(",
"r",
"*",
"RemoteService",
")",
"KickUser",
"(",
"ctx",
"context",
".",
"Context",
",",
"kick",
"*",
"protos",
".",
"KickMsg",
")",
"(",
"*",
"protos",
".",
"KickAnswer",
",",
"error",
")",
"{",
"logger",
".",
"Log",
".",
"Debugf",
"(",
... | // KickUser sends a kick to user | [
"KickUser",
"sends",
"a",
"kick",
"to",
"user"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/service/remote.go#L176-L189 |
28,357 | topfreegames/pitaya | service/remote.go | DoRPC | func (r *RemoteService) DoRPC(ctx context.Context, serverID string, route *route.Route, protoData []byte) (*protos.Response, error) {
msg := &message.Message{
Type: message.Request,
Route: route.Short(),
Data: protoData,
}
target, _ := r.serviceDiscovery.GetServer(serverID)
if serverID != "" && target == n... | go | func (r *RemoteService) DoRPC(ctx context.Context, serverID string, route *route.Route, protoData []byte) (*protos.Response, error) {
msg := &message.Message{
Type: message.Request,
Route: route.Short(),
Data: protoData,
}
target, _ := r.serviceDiscovery.GetServer(serverID)
if serverID != "" && target == n... | [
"func",
"(",
"r",
"*",
"RemoteService",
")",
"DoRPC",
"(",
"ctx",
"context",
".",
"Context",
",",
"serverID",
"string",
",",
"route",
"*",
"route",
".",
"Route",
",",
"protoData",
"[",
"]",
"byte",
")",
"(",
"*",
"protos",
".",
"Response",
",",
"erro... | // DoRPC do rpc and get answer | [
"DoRPC",
"do",
"rpc",
"and",
"get",
"answer"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/service/remote.go#L192-L205 |
28,358 | topfreegames/pitaya | service/remote.go | RPC | func (r *RemoteService) RPC(ctx context.Context, serverID string, route *route.Route, reply proto.Message, arg proto.Message) error {
var data []byte
var err error
if arg != nil {
data, err = proto.Marshal(arg)
if err != nil {
return err
}
}
res, err := r.DoRPC(ctx, serverID, route, data)
if err != nil {... | go | func (r *RemoteService) RPC(ctx context.Context, serverID string, route *route.Route, reply proto.Message, arg proto.Message) error {
var data []byte
var err error
if arg != nil {
data, err = proto.Marshal(arg)
if err != nil {
return err
}
}
res, err := r.DoRPC(ctx, serverID, route, data)
if err != nil {... | [
"func",
"(",
"r",
"*",
"RemoteService",
")",
"RPC",
"(",
"ctx",
"context",
".",
"Context",
",",
"serverID",
"string",
",",
"route",
"*",
"route",
".",
"Route",
",",
"reply",
"proto",
".",
"Message",
",",
"arg",
"proto",
".",
"Message",
")",
"error",
... | // RPC makes rpcs | [
"RPC",
"makes",
"rpcs"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/service/remote.go#L208-L237 |
28,359 | topfreegames/pitaya | service/remote.go | Docs | func (r *RemoteService) Docs(getPtrNames bool) (map[string]interface{}, error) {
if r == nil {
return map[string]interface{}{}, nil
}
return docgenerator.RemotesDocs(r.server.Type, r.services, getPtrNames)
} | go | func (r *RemoteService) Docs(getPtrNames bool) (map[string]interface{}, error) {
if r == nil {
return map[string]interface{}{}, nil
}
return docgenerator.RemotesDocs(r.server.Type, r.services, getPtrNames)
} | [
"func",
"(",
"r",
"*",
"RemoteService",
")",
"Docs",
"(",
"getPtrNames",
"bool",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"r",
"==",
"nil",
"{",
"return",
"map",
"[",
"string",
"]",
"interface",
"{",... | // Docs returns documentation for remotes | [
"Docs",
"returns",
"documentation",
"for",
"remotes"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/service/remote.go#L450-L455 |
28,360 | topfreegames/pitaya | component/method.go | isRemoteMethod | func isRemoteMethod(method reflect.Method) bool {
mt := method.Type
// Method must be exported.
if method.PkgPath != "" {
return false
}
// Method needs at least two ins: receiver and context.Context
if mt.NumIn() != 2 && mt.NumIn() != 3 {
return false
}
if t1 := mt.In(1); !t1.Implements(typeOfContext) {
... | go | func isRemoteMethod(method reflect.Method) bool {
mt := method.Type
// Method must be exported.
if method.PkgPath != "" {
return false
}
// Method needs at least two ins: receiver and context.Context
if mt.NumIn() != 2 && mt.NumIn() != 3 {
return false
}
if t1 := mt.In(1); !t1.Implements(typeOfContext) {
... | [
"func",
"isRemoteMethod",
"(",
"method",
"reflect",
".",
"Method",
")",
"bool",
"{",
"mt",
":=",
"method",
".",
"Type",
"\n",
"// Method must be exported.",
"if",
"method",
".",
"PkgPath",
"!=",
"\"",
"\"",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"// Me... | // isRemoteMethod decide a method is suitable remote method | [
"isRemoteMethod",
"decide",
"a",
"method",
"is",
"suitable",
"remote",
"method"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/component/method.go#L46-L82 |
28,361 | topfreegames/pitaya | component/method.go | isHandlerMethod | func isHandlerMethod(method reflect.Method) bool {
mt := method.Type
// Method must be exported.
if method.PkgPath != "" {
return false
}
// Method needs two or three ins: receiver, context.Context and optional []byte or pointer.
if mt.NumIn() != 2 && mt.NumIn() != 3 {
return false
}
if t1 := mt.In(1); !t... | go | func isHandlerMethod(method reflect.Method) bool {
mt := method.Type
// Method must be exported.
if method.PkgPath != "" {
return false
}
// Method needs two or three ins: receiver, context.Context and optional []byte or pointer.
if mt.NumIn() != 2 && mt.NumIn() != 3 {
return false
}
if t1 := mt.In(1); !t... | [
"func",
"isHandlerMethod",
"(",
"method",
"reflect",
".",
"Method",
")",
"bool",
"{",
"mt",
":=",
"method",
".",
"Type",
"\n",
"// Method must be exported.",
"if",
"method",
".",
"PkgPath",
"!=",
"\"",
"\"",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"// M... | // isHandlerMethod decide a method is suitable handler method | [
"isHandlerMethod",
"decide",
"a",
"method",
"is",
"suitable",
"handler",
"method"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/component/method.go#L85-L115 |
28,362 | topfreegames/pitaya | remote/sys.go | BindSession | func (s *Sys) BindSession(ctx context.Context, sessionData *protos.Session) (*protos.Response, error) {
sess := session.GetSessionByID(sessionData.Id)
if sess == nil {
return nil, constants.ErrSessionNotFound
}
if err := sess.Bind(ctx, sessionData.Uid); err != nil {
return nil, err
}
return &protos.Response{D... | go | func (s *Sys) BindSession(ctx context.Context, sessionData *protos.Session) (*protos.Response, error) {
sess := session.GetSessionByID(sessionData.Id)
if sess == nil {
return nil, constants.ErrSessionNotFound
}
if err := sess.Bind(ctx, sessionData.Uid); err != nil {
return nil, err
}
return &protos.Response{D... | [
"func",
"(",
"s",
"*",
"Sys",
")",
"BindSession",
"(",
"ctx",
"context",
".",
"Context",
",",
"sessionData",
"*",
"protos",
".",
"Session",
")",
"(",
"*",
"protos",
".",
"Response",
",",
"error",
")",
"{",
"sess",
":=",
"session",
".",
"GetSessionByID"... | // BindSession binds the local session | [
"BindSession",
"binds",
"the",
"local",
"session"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/remote/sys.go#L38-L47 |
28,363 | topfreegames/pitaya | remote/sys.go | Kick | func (s *Sys) Kick(ctx context.Context, msg *protos.KickMsg) (*protos.KickAnswer, error) {
res := &protos.KickAnswer{
Kicked: false,
}
sess := session.GetSessionByUID(msg.GetUserId())
if sess == nil {
return res, constants.ErrSessionNotFound
}
err := sess.Kick(ctx)
if err != nil {
return res, err
}
res.K... | go | func (s *Sys) Kick(ctx context.Context, msg *protos.KickMsg) (*protos.KickAnswer, error) {
res := &protos.KickAnswer{
Kicked: false,
}
sess := session.GetSessionByUID(msg.GetUserId())
if sess == nil {
return res, constants.ErrSessionNotFound
}
err := sess.Kick(ctx)
if err != nil {
return res, err
}
res.K... | [
"func",
"(",
"s",
"*",
"Sys",
")",
"Kick",
"(",
"ctx",
"context",
".",
"Context",
",",
"msg",
"*",
"protos",
".",
"KickMsg",
")",
"(",
"*",
"protos",
".",
"KickAnswer",
",",
"error",
")",
"{",
"res",
":=",
"&",
"protos",
".",
"KickAnswer",
"{",
"... | // Kick kicks a local user | [
"Kick",
"kicks",
"a",
"local",
"user"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/remote/sys.go#L62-L76 |
28,364 | topfreegames/pitaya | examples/demo/cluster_protobuf/services/connector.go | RemoteFunc | func (c *ConnectorRemote) RemoteFunc(ctx context.Context, message []byte) (*protos.Response, error) {
fmt.Printf("received a remote call with this message: %s\n", message)
return &protos.Response{
Msg: string(message),
}, nil
} | go | func (c *ConnectorRemote) RemoteFunc(ctx context.Context, message []byte) (*protos.Response, error) {
fmt.Printf("received a remote call with this message: %s\n", message)
return &protos.Response{
Msg: string(message),
}, nil
} | [
"func",
"(",
"c",
"*",
"ConnectorRemote",
")",
"RemoteFunc",
"(",
"ctx",
"context",
".",
"Context",
",",
"message",
"[",
"]",
"byte",
")",
"(",
"*",
"protos",
".",
"Response",
",",
"error",
")",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",... | // RemoteFunc is a function that will be called remotelly | [
"RemoteFunc",
"is",
"a",
"function",
"that",
"will",
"be",
"called",
"remotelly"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/examples/demo/cluster_protobuf/services/connector.go#L27-L32 |
28,365 | topfreegames/pitaya | module.go | RegisterModule | func RegisterModule(module interfaces.Module, name string) error {
return RegisterModuleAfter(module, name)
} | go | func RegisterModule(module interfaces.Module, name string) error {
return RegisterModuleAfter(module, name)
} | [
"func",
"RegisterModule",
"(",
"module",
"interfaces",
".",
"Module",
",",
"name",
"string",
")",
"error",
"{",
"return",
"RegisterModuleAfter",
"(",
"module",
",",
"name",
")",
"\n",
"}"
] | // RegisterModule registers a module, by default it register after registered modules | [
"RegisterModule",
"registers",
"a",
"module",
"by",
"default",
"it",
"register",
"after",
"registered",
"modules"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/module.go#L41-L43 |
28,366 | topfreegames/pitaya | module.go | RegisterModuleAfter | func RegisterModuleAfter(module interfaces.Module, name string) error {
if err := alreadyRegistered(name); err != nil {
return err
}
modulesMap[name] = module
modulesArr = append(modulesArr, moduleWrapper{
module: module,
name: name,
})
return nil
} | go | func RegisterModuleAfter(module interfaces.Module, name string) error {
if err := alreadyRegistered(name); err != nil {
return err
}
modulesMap[name] = module
modulesArr = append(modulesArr, moduleWrapper{
module: module,
name: name,
})
return nil
} | [
"func",
"RegisterModuleAfter",
"(",
"module",
"interfaces",
".",
"Module",
",",
"name",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"alreadyRegistered",
"(",
"name",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"modulesMap",
... | // RegisterModuleAfter registers a module after all registered modules | [
"RegisterModuleAfter",
"registers",
"a",
"module",
"after",
"all",
"registered",
"modules"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/module.go#L46-L58 |
28,367 | topfreegames/pitaya | module.go | GetModule | func GetModule(name string) (interfaces.Module, error) {
if m, ok := modulesMap[name]; ok {
return m, nil
}
return nil, fmt.Errorf("module with name %s not found", name)
} | go | func GetModule(name string) (interfaces.Module, error) {
if m, ok := modulesMap[name]; ok {
return m, nil
}
return nil, fmt.Errorf("module with name %s not found", name)
} | [
"func",
"GetModule",
"(",
"name",
"string",
")",
"(",
"interfaces",
".",
"Module",
",",
"error",
")",
"{",
"if",
"m",
",",
"ok",
":=",
"modulesMap",
"[",
"name",
"]",
";",
"ok",
"{",
"return",
"m",
",",
"nil",
"\n",
"}",
"\n",
"return",
"nil",
",... | // GetModule gets a module with a name | [
"GetModule",
"gets",
"a",
"module",
"with",
"a",
"name"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/module.go#L78-L83 |
28,368 | topfreegames/pitaya | module.go | startModules | func startModules() {
logger.Log.Debug("initializing all modules")
for _, modWrapper := range modulesArr {
logger.Log.Debugf("initializing module: %s", modWrapper.name)
if err := modWrapper.module.Init(); err != nil {
logger.Log.Fatalf("error starting module %s, error: %s", modWrapper.name, err.Error())
}
}... | go | func startModules() {
logger.Log.Debug("initializing all modules")
for _, modWrapper := range modulesArr {
logger.Log.Debugf("initializing module: %s", modWrapper.name)
if err := modWrapper.module.Init(); err != nil {
logger.Log.Fatalf("error starting module %s, error: %s", modWrapper.name, err.Error())
}
}... | [
"func",
"startModules",
"(",
")",
"{",
"logger",
".",
"Log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"for",
"_",
",",
"modWrapper",
":=",
"range",
"modulesArr",
"{",
"logger",
".",
"Log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"modWrapper",
".",
"n... | // startModules starts all modules in order | [
"startModules",
"starts",
"all",
"modules",
"in",
"order"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/module.go#L94-L107 |
28,369 | topfreegames/pitaya | module.go | shutdownModules | func shutdownModules() {
for i := len(modulesArr) - 1; i >= 0; i-- {
modulesArr[i].module.BeforeShutdown()
}
for i := len(modulesArr) - 1; i >= 0; i-- {
name := modulesArr[i].name
mod := modulesArr[i].module
logger.Log.Debugf("stopping module: %s", name)
if err := mod.Shutdown(); err != nil {
logger.L... | go | func shutdownModules() {
for i := len(modulesArr) - 1; i >= 0; i-- {
modulesArr[i].module.BeforeShutdown()
}
for i := len(modulesArr) - 1; i >= 0; i-- {
name := modulesArr[i].name
mod := modulesArr[i].module
logger.Log.Debugf("stopping module: %s", name)
if err := mod.Shutdown(); err != nil {
logger.L... | [
"func",
"shutdownModules",
"(",
")",
"{",
"for",
"i",
":=",
"len",
"(",
"modulesArr",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"modulesArr",
"[",
"i",
"]",
".",
"module",
".",
"BeforeShutdown",
"(",
")",
"\n",
"}",
"\n\n",
"for",
... | // shutdownModules starts all modules in reverse order | [
"shutdownModules",
"starts",
"all",
"modules",
"in",
"reverse",
"order"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/module.go#L110-L125 |
28,370 | topfreegames/pitaya | metrics/statsd_reporter.go | NewStatsdReporter | func NewStatsdReporter(
config *config.Config,
serverType string,
tagsMap map[string]string,
clientOrNil ...Client,
) (*StatsdReporter, error) {
host := config.GetString("pitaya.metrics.statsd.host")
prefix := config.GetString("pitaya.metrics.statsd.prefix")
rate, err := strconv.ParseFloat(config.GetString("pita... | go | func NewStatsdReporter(
config *config.Config,
serverType string,
tagsMap map[string]string,
clientOrNil ...Client,
) (*StatsdReporter, error) {
host := config.GetString("pitaya.metrics.statsd.host")
prefix := config.GetString("pitaya.metrics.statsd.prefix")
rate, err := strconv.ParseFloat(config.GetString("pita... | [
"func",
"NewStatsdReporter",
"(",
"config",
"*",
"config",
".",
"Config",
",",
"serverType",
"string",
",",
"tagsMap",
"map",
"[",
"string",
"]",
"string",
",",
"clientOrNil",
"...",
"Client",
",",
")",
"(",
"*",
"StatsdReporter",
",",
"error",
")",
"{",
... | // NewStatsdReporter returns an instance of statsd reportar and an error if something fails | [
"NewStatsdReporter",
"returns",
"an",
"instance",
"of",
"statsd",
"reportar",
"and",
"an",
"error",
"if",
"something",
"fails"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/metrics/statsd_reporter.go#L48-L78 |
28,371 | topfreegames/pitaya | metrics/statsd_reporter.go | ReportCount | func (s *StatsdReporter) ReportCount(metric string, tagsMap map[string]string, count float64) error {
fullTags := s.defaultTags
for k, v := range tagsMap {
fullTags = append(fullTags, fmt.Sprintf("%s:%s", k, v))
}
err := s.client.Count(metric, int64(count), fullTags, s.rate)
if err != nil {
logger.Log.Errorf... | go | func (s *StatsdReporter) ReportCount(metric string, tagsMap map[string]string, count float64) error {
fullTags := s.defaultTags
for k, v := range tagsMap {
fullTags = append(fullTags, fmt.Sprintf("%s:%s", k, v))
}
err := s.client.Count(metric, int64(count), fullTags, s.rate)
if err != nil {
logger.Log.Errorf... | [
"func",
"(",
"s",
"*",
"StatsdReporter",
")",
"ReportCount",
"(",
"metric",
"string",
",",
"tagsMap",
"map",
"[",
"string",
"]",
"string",
",",
"count",
"float64",
")",
"error",
"{",
"fullTags",
":=",
"s",
".",
"defaultTags",
"\n\n",
"for",
"k",
",",
"... | // ReportCount sends count reports to statsd | [
"ReportCount",
"sends",
"count",
"reports",
"to",
"statsd"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/metrics/statsd_reporter.go#L95-L108 |
28,372 | topfreegames/pitaya | metrics/statsd_reporter.go | ReportGauge | func (s *StatsdReporter) ReportGauge(metric string, tagsMap map[string]string, value float64) error {
fullTags := s.defaultTags
for k, v := range tagsMap {
fullTags = append(fullTags, fmt.Sprintf("%s:%s", k, v))
}
err := s.client.Gauge(metric, value, fullTags, s.rate)
if err != nil {
logger.Log.Errorf("faile... | go | func (s *StatsdReporter) ReportGauge(metric string, tagsMap map[string]string, value float64) error {
fullTags := s.defaultTags
for k, v := range tagsMap {
fullTags = append(fullTags, fmt.Sprintf("%s:%s", k, v))
}
err := s.client.Gauge(metric, value, fullTags, s.rate)
if err != nil {
logger.Log.Errorf("faile... | [
"func",
"(",
"s",
"*",
"StatsdReporter",
")",
"ReportGauge",
"(",
"metric",
"string",
",",
"tagsMap",
"map",
"[",
"string",
"]",
"string",
",",
"value",
"float64",
")",
"error",
"{",
"fullTags",
":=",
"s",
".",
"defaultTags",
"\n\n",
"for",
"k",
",",
"... | // ReportGauge sents the gauge value and reports to statsd | [
"ReportGauge",
"sents",
"the",
"gauge",
"value",
"and",
"reports",
"to",
"statsd"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/metrics/statsd_reporter.go#L111-L124 |
28,373 | topfreegames/pitaya | group.go | GroupCreate | func GroupCreate(ctx context.Context, groupName string) error {
return groupServiceInstance.GroupCreate(ctx, groupName)
} | go | func GroupCreate(ctx context.Context, groupName string) error {
return groupServiceInstance.GroupCreate(ctx, groupName)
} | [
"func",
"GroupCreate",
"(",
"ctx",
"context",
".",
"Context",
",",
"groupName",
"string",
")",
"error",
"{",
"return",
"groupServiceInstance",
".",
"GroupCreate",
"(",
"ctx",
",",
"groupName",
")",
"\n",
"}"
] | // GroupCreate creates a group | [
"GroupCreate",
"creates",
"a",
"group"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/group.go#L49-L51 |
28,374 | topfreegames/pitaya | group.go | GroupCreateWithTTL | func GroupCreateWithTTL(ctx context.Context, groupName string, ttlTime time.Duration) error {
return groupServiceInstance.GroupCreateWithTTL(ctx, groupName, ttlTime)
} | go | func GroupCreateWithTTL(ctx context.Context, groupName string, ttlTime time.Duration) error {
return groupServiceInstance.GroupCreateWithTTL(ctx, groupName, ttlTime)
} | [
"func",
"GroupCreateWithTTL",
"(",
"ctx",
"context",
".",
"Context",
",",
"groupName",
"string",
",",
"ttlTime",
"time",
".",
"Duration",
")",
"error",
"{",
"return",
"groupServiceInstance",
".",
"GroupCreateWithTTL",
"(",
"ctx",
",",
"groupName",
",",
"ttlTime"... | // GroupCreateWithTTL creates a group with given TTL | [
"GroupCreateWithTTL",
"creates",
"a",
"group",
"with",
"given",
"TTL"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/group.go#L54-L56 |
28,375 | topfreegames/pitaya | group.go | GroupBroadcast | func GroupBroadcast(ctx context.Context, frontendType, groupName, route string, v interface{}) error {
logger.Log.Debugf("Type=Broadcast Route=%s, Data=%+v", route, v)
members, err := GroupMembers(ctx, groupName)
if err != nil {
return err
}
return sendDataToMembers(members, frontendType, route, v)
} | go | func GroupBroadcast(ctx context.Context, frontendType, groupName, route string, v interface{}) error {
logger.Log.Debugf("Type=Broadcast Route=%s, Data=%+v", route, v)
members, err := GroupMembers(ctx, groupName)
if err != nil {
return err
}
return sendDataToMembers(members, frontendType, route, v)
} | [
"func",
"GroupBroadcast",
"(",
"ctx",
"context",
".",
"Context",
",",
"frontendType",
",",
"groupName",
",",
"route",
"string",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"logger",
".",
"Log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"route",
",",... | // GroupBroadcast pushes the message to all members inside group | [
"GroupBroadcast",
"pushes",
"the",
"message",
"to",
"all",
"members",
"inside",
"group"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/group.go#L64-L72 |
28,376 | topfreegames/pitaya | group.go | GroupContainsMember | func GroupContainsMember(ctx context.Context, groupName, uid string) (bool, error) {
if uid == "" {
return false, constants.ErrEmptyUID
}
return groupServiceInstance.GroupContainsMember(ctx, groupName, uid)
} | go | func GroupContainsMember(ctx context.Context, groupName, uid string) (bool, error) {
if uid == "" {
return false, constants.ErrEmptyUID
}
return groupServiceInstance.GroupContainsMember(ctx, groupName, uid)
} | [
"func",
"GroupContainsMember",
"(",
"ctx",
"context",
".",
"Context",
",",
"groupName",
",",
"uid",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"uid",
"==",
"\"",
"\"",
"{",
"return",
"false",
",",
"constants",
".",
"ErrEmptyUID",
"\n",
"... | // GroupContainsMember checks whether an UID is contained in group or not | [
"GroupContainsMember",
"checks",
"whether",
"an",
"UID",
"is",
"contained",
"in",
"group",
"or",
"not"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/group.go#L84-L89 |
28,377 | topfreegames/pitaya | group.go | GroupRemoveAll | func GroupRemoveAll(ctx context.Context, groupName string) error {
return groupServiceInstance.GroupRemoveAll(ctx, groupName)
} | go | func GroupRemoveAll(ctx context.Context, groupName string) error {
return groupServiceInstance.GroupRemoveAll(ctx, groupName)
} | [
"func",
"GroupRemoveAll",
"(",
"ctx",
"context",
".",
"Context",
",",
"groupName",
"string",
")",
"error",
"{",
"return",
"groupServiceInstance",
".",
"GroupRemoveAll",
"(",
"ctx",
",",
"groupName",
")",
"\n",
"}"
] | // GroupRemoveAll clears all UIDs | [
"GroupRemoveAll",
"clears",
"all",
"UIDs"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/group.go#L107-L109 |
28,378 | topfreegames/pitaya | group.go | GroupRenewTTL | func GroupRenewTTL(ctx context.Context, groupName string) error {
return groupServiceInstance.GroupRenewTTL(ctx, groupName)
} | go | func GroupRenewTTL(ctx context.Context, groupName string) error {
return groupServiceInstance.GroupRenewTTL(ctx, groupName)
} | [
"func",
"GroupRenewTTL",
"(",
"ctx",
"context",
".",
"Context",
",",
"groupName",
"string",
")",
"error",
"{",
"return",
"groupServiceInstance",
".",
"GroupRenewTTL",
"(",
"ctx",
",",
"groupName",
")",
"\n",
"}"
] | // GroupRenewTTL renews group with the initial TTL | [
"GroupRenewTTL",
"renews",
"group",
"with",
"the",
"initial",
"TTL"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/group.go#L117-L119 |
28,379 | topfreegames/pitaya | group.go | GroupDelete | func GroupDelete(ctx context.Context, groupName string) error {
return groupServiceInstance.GroupDelete(ctx, groupName)
} | go | func GroupDelete(ctx context.Context, groupName string) error {
return groupServiceInstance.GroupDelete(ctx, groupName)
} | [
"func",
"GroupDelete",
"(",
"ctx",
"context",
".",
"Context",
",",
"groupName",
"string",
")",
"error",
"{",
"return",
"groupServiceInstance",
".",
"GroupDelete",
"(",
"ctx",
",",
"groupName",
")",
"\n",
"}"
] | // GroupDelete deletes whole group, including UIDs and base group | [
"GroupDelete",
"deletes",
"whole",
"group",
"including",
"UIDs",
"and",
"base",
"group"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/group.go#L122-L124 |
28,380 | topfreegames/pitaya | push.go | SendPushToUsers | func SendPushToUsers(route string, v interface{}, uids []string, frontendType string) ([]string, error) {
data, err := util.SerializeOrRaw(app.serializer, v)
if err != nil {
return uids, err
}
if !app.server.Frontend && frontendType == "" {
return uids, constants.ErrFrontendTypeNotSpecified
}
var notPushedU... | go | func SendPushToUsers(route string, v interface{}, uids []string, frontendType string) ([]string, error) {
data, err := util.SerializeOrRaw(app.serializer, v)
if err != nil {
return uids, err
}
if !app.server.Frontend && frontendType == "" {
return uids, constants.ErrFrontendTypeNotSpecified
}
var notPushedU... | [
"func",
"SendPushToUsers",
"(",
"route",
"string",
",",
"v",
"interface",
"{",
"}",
",",
"uids",
"[",
"]",
"string",
",",
"frontendType",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"util",
".",
"Serializ... | // SendPushToUsers sends a message to the given list of users | [
"SendPushToUsers",
"sends",
"a",
"message",
"to",
"the",
"given",
"list",
"of",
"users"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/push.go#L33-L74 |
28,381 | topfreegames/pitaya | cluster/grpc_rpc_server.go | Init | func (gs *GRPCServer) Init() error {
port := gs.config.GetInt("pitaya.cluster.rpc.server.grpc.port")
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
if err != nil {
return err
}
gs.grpcSv = grpc.NewServer()
protos.RegisterPitayaServer(gs.grpcSv, gs.pitayaServer)
go gs.grpcSv.Serve(lis)
return nil
} | go | func (gs *GRPCServer) Init() error {
port := gs.config.GetInt("pitaya.cluster.rpc.server.grpc.port")
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
if err != nil {
return err
}
gs.grpcSv = grpc.NewServer()
protos.RegisterPitayaServer(gs.grpcSv, gs.pitayaServer)
go gs.grpcSv.Serve(lis)
return nil
} | [
"func",
"(",
"gs",
"*",
"GRPCServer",
")",
"Init",
"(",
")",
"error",
"{",
"port",
":=",
"gs",
".",
"config",
".",
"GetInt",
"(",
"\"",
"\"",
")",
"\n",
"lis",
",",
"err",
":=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",... | // Init inits grpc rpc server | [
"Init",
"inits",
"grpc",
"rpc",
"server"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/cluster/grpc_rpc_server.go#L54-L64 |
28,382 | topfreegames/pitaya | metrics/report.go | ReportTimingFromCtx | func ReportTimingFromCtx(ctx context.Context, reporters []Reporter, typ string, err error) {
code := errors.CodeFromError(err)
status := "ok"
if err != nil {
status = "failed"
}
if len(reporters) > 0 {
startTime := pcontext.GetFromPropagateCtx(ctx, constants.StartTimeKey)
route := pcontext.GetFromPropagateCt... | go | func ReportTimingFromCtx(ctx context.Context, reporters []Reporter, typ string, err error) {
code := errors.CodeFromError(err)
status := "ok"
if err != nil {
status = "failed"
}
if len(reporters) > 0 {
startTime := pcontext.GetFromPropagateCtx(ctx, constants.StartTimeKey)
route := pcontext.GetFromPropagateCt... | [
"func",
"ReportTimingFromCtx",
"(",
"ctx",
"context",
".",
"Context",
",",
"reporters",
"[",
"]",
"Reporter",
",",
"typ",
"string",
",",
"err",
"error",
")",
"{",
"code",
":=",
"errors",
".",
"CodeFromError",
"(",
"err",
")",
"\n",
"status",
":=",
"\"",
... | // ReportTimingFromCtx reports the latency from the context | [
"ReportTimingFromCtx",
"reports",
"the",
"latency",
"from",
"the",
"context"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/metrics/report.go#L35-L55 |
28,383 | topfreegames/pitaya | metrics/report.go | ReportMessageProcessDelayFromCtx | func ReportMessageProcessDelayFromCtx(ctx context.Context, reporters []Reporter, typ string) {
if len(reporters) > 0 {
startTime := pcontext.GetFromPropagateCtx(ctx, constants.StartTimeKey)
elapsed := time.Since(time.Unix(0, startTime.(int64)))
route := pcontext.GetFromPropagateCtx(ctx, constants.RouteKey)
tag... | go | func ReportMessageProcessDelayFromCtx(ctx context.Context, reporters []Reporter, typ string) {
if len(reporters) > 0 {
startTime := pcontext.GetFromPropagateCtx(ctx, constants.StartTimeKey)
elapsed := time.Since(time.Unix(0, startTime.(int64)))
route := pcontext.GetFromPropagateCtx(ctx, constants.RouteKey)
tag... | [
"func",
"ReportMessageProcessDelayFromCtx",
"(",
"ctx",
"context",
".",
"Context",
",",
"reporters",
"[",
"]",
"Reporter",
",",
"typ",
"string",
")",
"{",
"if",
"len",
"(",
"reporters",
")",
">",
"0",
"{",
"startTime",
":=",
"pcontext",
".",
"GetFromPropagat... | // ReportMessageProcessDelayFromCtx reports the delay to process the messages | [
"ReportMessageProcessDelayFromCtx",
"reports",
"the",
"delay",
"to",
"process",
"the",
"messages"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/metrics/report.go#L58-L71 |
28,384 | topfreegames/pitaya | metrics/report.go | ReportNumberOfConnectedClients | func ReportNumberOfConnectedClients(reporters []Reporter, number int64) {
for _, r := range reporters {
r.ReportGauge(ConnectedClients, map[string]string{}, float64(number))
}
} | go | func ReportNumberOfConnectedClients(reporters []Reporter, number int64) {
for _, r := range reporters {
r.ReportGauge(ConnectedClients, map[string]string{}, float64(number))
}
} | [
"func",
"ReportNumberOfConnectedClients",
"(",
"reporters",
"[",
"]",
"Reporter",
",",
"number",
"int64",
")",
"{",
"for",
"_",
",",
"r",
":=",
"range",
"reporters",
"{",
"r",
".",
"ReportGauge",
"(",
"ConnectedClients",
",",
"map",
"[",
"string",
"]",
"st... | // ReportNumberOfConnectedClients reports the number of connected clients | [
"ReportNumberOfConnectedClients",
"reports",
"the",
"number",
"of",
"connected",
"clients"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/metrics/report.go#L74-L78 |
28,385 | topfreegames/pitaya | metrics/report.go | ReportSysMetrics | func ReportSysMetrics(reporters []Reporter, period time.Duration) {
for {
for _, r := range reporters {
num := runtime.NumGoroutine()
m := &runtime.MemStats{}
runtime.ReadMemStats(m)
r.ReportGauge(Goroutines, map[string]string{}, float64(num))
r.ReportGauge(HeapSize, map[string]string{}, float64(m.Al... | go | func ReportSysMetrics(reporters []Reporter, period time.Duration) {
for {
for _, r := range reporters {
num := runtime.NumGoroutine()
m := &runtime.MemStats{}
runtime.ReadMemStats(m)
r.ReportGauge(Goroutines, map[string]string{}, float64(num))
r.ReportGauge(HeapSize, map[string]string{}, float64(m.Al... | [
"func",
"ReportSysMetrics",
"(",
"reporters",
"[",
"]",
"Reporter",
",",
"period",
"time",
".",
"Duration",
")",
"{",
"for",
"{",
"for",
"_",
",",
"r",
":=",
"range",
"reporters",
"{",
"num",
":=",
"runtime",
".",
"NumGoroutine",
"(",
")",
"\n",
"m",
... | // ReportSysMetrics reports sys metrics | [
"ReportSysMetrics",
"reports",
"sys",
"metrics"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/metrics/report.go#L81-L95 |
28,386 | topfreegames/pitaya | groups/memory_group_service.go | NewMemoryGroupService | func NewMemoryGroupService(conf *config.Config) *MemoryGroupService {
memoryOnce.Do(func() {
memoryGroups = make(map[string]*MemoryGroup)
go groupTTLCleanup(conf)
})
return &MemoryGroupService{}
} | go | func NewMemoryGroupService(conf *config.Config) *MemoryGroupService {
memoryOnce.Do(func() {
memoryGroups = make(map[string]*MemoryGroup)
go groupTTLCleanup(conf)
})
return &MemoryGroupService{}
} | [
"func",
"NewMemoryGroupService",
"(",
"conf",
"*",
"config",
".",
"Config",
")",
"*",
"MemoryGroupService",
"{",
"memoryOnce",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"memoryGroups",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"MemoryGroup",
")",
"\... | // NewMemoryGroupService returns a new group instance | [
"NewMemoryGroupService",
"returns",
"a",
"new",
"group",
"instance"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/groups/memory_group_service.go#L30-L36 |
28,387 | topfreegames/pitaya | groups/memory_group_service.go | GroupCreate | func (c *MemoryGroupService) GroupCreate(ctx context.Context, groupName string) error {
memoryGroupsMu.Lock()
defer memoryGroupsMu.Unlock()
if _, ok := memoryGroups[groupName]; ok {
return constants.ErrGroupAlreadyExists
}
memoryGroups[groupName] = &MemoryGroup{}
return nil
} | go | func (c *MemoryGroupService) GroupCreate(ctx context.Context, groupName string) error {
memoryGroupsMu.Lock()
defer memoryGroupsMu.Unlock()
if _, ok := memoryGroups[groupName]; ok {
return constants.ErrGroupAlreadyExists
}
memoryGroups[groupName] = &MemoryGroup{}
return nil
} | [
"func",
"(",
"c",
"*",
"MemoryGroupService",
")",
"GroupCreate",
"(",
"ctx",
"context",
".",
"Context",
",",
"groupName",
"string",
")",
"error",
"{",
"memoryGroupsMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"memoryGroupsMu",
".",
"Unlock",
"(",
")",
"\n\n"... | // GroupCreate creates a group without TTL | [
"GroupCreate",
"creates",
"a",
"group",
"without",
"TTL"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/groups/memory_group_service.go#L51-L61 |
28,388 | topfreegames/pitaya | groups/memory_group_service.go | GroupCreateWithTTL | func (c *MemoryGroupService) GroupCreateWithTTL(ctx context.Context, groupName string, ttlTime time.Duration) error {
memoryGroupsMu.Lock()
defer memoryGroupsMu.Unlock()
if _, ok := memoryGroups[groupName]; ok {
return constants.ErrGroupAlreadyExists
}
memoryGroups[groupName] = &MemoryGroup{LastRefresh: time.N... | go | func (c *MemoryGroupService) GroupCreateWithTTL(ctx context.Context, groupName string, ttlTime time.Duration) error {
memoryGroupsMu.Lock()
defer memoryGroupsMu.Unlock()
if _, ok := memoryGroups[groupName]; ok {
return constants.ErrGroupAlreadyExists
}
memoryGroups[groupName] = &MemoryGroup{LastRefresh: time.N... | [
"func",
"(",
"c",
"*",
"MemoryGroupService",
")",
"GroupCreateWithTTL",
"(",
"ctx",
"context",
".",
"Context",
",",
"groupName",
"string",
",",
"ttlTime",
"time",
".",
"Duration",
")",
"error",
"{",
"memoryGroupsMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"... | // GroupCreateWithTTL creates a group with TTL, which the go routine will clean later | [
"GroupCreateWithTTL",
"creates",
"a",
"group",
"with",
"TTL",
"which",
"the",
"go",
"routine",
"will",
"clean",
"later"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/groups/memory_group_service.go#L64-L74 |
28,389 | topfreegames/pitaya | groups/memory_group_service.go | GroupMembers | func (c *MemoryGroupService) GroupMembers(ctx context.Context, groupName string) ([]string, error) {
memoryGroupsMu.Lock()
defer memoryGroupsMu.Unlock()
mg, ok := memoryGroups[groupName]
if !ok {
return nil, constants.ErrGroupNotFound
}
uids := make([]string, len(mg.Uids))
copy(uids, mg.Uids)
return uids, ... | go | func (c *MemoryGroupService) GroupMembers(ctx context.Context, groupName string) ([]string, error) {
memoryGroupsMu.Lock()
defer memoryGroupsMu.Unlock()
mg, ok := memoryGroups[groupName]
if !ok {
return nil, constants.ErrGroupNotFound
}
uids := make([]string, len(mg.Uids))
copy(uids, mg.Uids)
return uids, ... | [
"func",
"(",
"c",
"*",
"MemoryGroupService",
")",
"GroupMembers",
"(",
"ctx",
"context",
".",
"Context",
",",
"groupName",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"memoryGroupsMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"memoryGrou... | // GroupMembers returns all member's UID in given group | [
"GroupMembers",
"returns",
"all",
"member",
"s",
"UID",
"in",
"given",
"group"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/groups/memory_group_service.go#L77-L90 |
28,390 | topfreegames/pitaya | groups/memory_group_service.go | GroupContainsMember | func (c *MemoryGroupService) GroupContainsMember(ctx context.Context, groupName, uid string) (bool, error) {
memoryGroupsMu.Lock()
defer memoryGroupsMu.Unlock()
mg, ok := memoryGroups[groupName]
if !ok {
return false, constants.ErrGroupNotFound
}
_, contains := elementIndex(mg.Uids, uid)
return contains, nil... | go | func (c *MemoryGroupService) GroupContainsMember(ctx context.Context, groupName, uid string) (bool, error) {
memoryGroupsMu.Lock()
defer memoryGroupsMu.Unlock()
mg, ok := memoryGroups[groupName]
if !ok {
return false, constants.ErrGroupNotFound
}
_, contains := elementIndex(mg.Uids, uid)
return contains, nil... | [
"func",
"(",
"c",
"*",
"MemoryGroupService",
")",
"GroupContainsMember",
"(",
"ctx",
"context",
".",
"Context",
",",
"groupName",
",",
"uid",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"memoryGroupsMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mem... | // GroupContainsMember check whether an UID is contained in given group or not | [
"GroupContainsMember",
"check",
"whether",
"an",
"UID",
"is",
"contained",
"in",
"given",
"group",
"or",
"not"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/groups/memory_group_service.go#L93-L104 |
28,391 | topfreegames/pitaya | groups/memory_group_service.go | GroupRemoveMember | func (c *MemoryGroupService) GroupRemoveMember(ctx context.Context, groupName, uid string) error {
memoryGroupsMu.Lock()
defer memoryGroupsMu.Unlock()
mg, ok := memoryGroups[groupName]
if !ok {
return constants.ErrGroupNotFound
}
index, contains := elementIndex(mg.Uids, uid)
if contains {
mg.Uids[index] = m... | go | func (c *MemoryGroupService) GroupRemoveMember(ctx context.Context, groupName, uid string) error {
memoryGroupsMu.Lock()
defer memoryGroupsMu.Unlock()
mg, ok := memoryGroups[groupName]
if !ok {
return constants.ErrGroupNotFound
}
index, contains := elementIndex(mg.Uids, uid)
if contains {
mg.Uids[index] = m... | [
"func",
"(",
"c",
"*",
"MemoryGroupService",
")",
"GroupRemoveMember",
"(",
"ctx",
"context",
".",
"Context",
",",
"groupName",
",",
"uid",
"string",
")",
"error",
"{",
"memoryGroupsMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"memoryGroupsMu",
".",
"Unlock",
... | // GroupRemoveMember removes specific UID from group | [
"GroupRemoveMember",
"removes",
"specific",
"UID",
"from",
"group"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/groups/memory_group_service.go#L127-L144 |
28,392 | topfreegames/pitaya | groups/memory_group_service.go | GroupRemoveAll | func (c *MemoryGroupService) GroupRemoveAll(ctx context.Context, groupName string) error {
memoryGroupsMu.Lock()
defer memoryGroupsMu.Unlock()
mg, ok := memoryGroups[groupName]
if !ok {
return constants.ErrGroupNotFound
}
mg.Uids = []string{}
return nil
} | go | func (c *MemoryGroupService) GroupRemoveAll(ctx context.Context, groupName string) error {
memoryGroupsMu.Lock()
defer memoryGroupsMu.Unlock()
mg, ok := memoryGroups[groupName]
if !ok {
return constants.ErrGroupNotFound
}
mg.Uids = []string{}
return nil
} | [
"func",
"(",
"c",
"*",
"MemoryGroupService",
")",
"GroupRemoveAll",
"(",
"ctx",
"context",
".",
"Context",
",",
"groupName",
"string",
")",
"error",
"{",
"memoryGroupsMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"memoryGroupsMu",
".",
"Unlock",
"(",
")",
"\n... | // GroupRemoveAll clears all UIDs from group | [
"GroupRemoveAll",
"clears",
"all",
"UIDs",
"from",
"group"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/groups/memory_group_service.go#L147-L158 |
28,393 | topfreegames/pitaya | groups/memory_group_service.go | GroupDelete | func (c *MemoryGroupService) GroupDelete(ctx context.Context, groupName string) error {
memoryGroupsMu.Lock()
defer memoryGroupsMu.Unlock()
_, ok := memoryGroups[groupName]
if !ok {
return constants.ErrGroupNotFound
}
delete(memoryGroups, groupName)
return nil
} | go | func (c *MemoryGroupService) GroupDelete(ctx context.Context, groupName string) error {
memoryGroupsMu.Lock()
defer memoryGroupsMu.Unlock()
_, ok := memoryGroups[groupName]
if !ok {
return constants.ErrGroupNotFound
}
delete(memoryGroups, groupName)
return nil
} | [
"func",
"(",
"c",
"*",
"MemoryGroupService",
")",
"GroupDelete",
"(",
"ctx",
"context",
".",
"Context",
",",
"groupName",
"string",
")",
"error",
"{",
"memoryGroupsMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"memoryGroupsMu",
".",
"Unlock",
"(",
")",
"\n\n"... | // GroupDelete deletes the whole group, including members and base group | [
"GroupDelete",
"deletes",
"the",
"whole",
"group",
"including",
"members",
"and",
"base",
"group"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/groups/memory_group_service.go#L161-L172 |
28,394 | topfreegames/pitaya | groups/memory_group_service.go | GroupRenewTTL | func (c *MemoryGroupService) GroupRenewTTL(ctx context.Context, groupName string) error {
memoryGroupsMu.Lock()
defer memoryGroupsMu.Unlock()
mg, ok := memoryGroups[groupName]
if !ok {
return constants.ErrGroupNotFound
}
if mg.TTL != 0 {
mg.LastRefresh = time.Now().UnixNano()
memoryGroups[groupName] = mg
... | go | func (c *MemoryGroupService) GroupRenewTTL(ctx context.Context, groupName string) error {
memoryGroupsMu.Lock()
defer memoryGroupsMu.Unlock()
mg, ok := memoryGroups[groupName]
if !ok {
return constants.ErrGroupNotFound
}
if mg.TTL != 0 {
mg.LastRefresh = time.Now().UnixNano()
memoryGroups[groupName] = mg
... | [
"func",
"(",
"c",
"*",
"MemoryGroupService",
")",
"GroupRenewTTL",
"(",
"ctx",
"context",
".",
"Context",
",",
"groupName",
"string",
")",
"error",
"{",
"memoryGroupsMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"memoryGroupsMu",
".",
"Unlock",
"(",
")",
"\n\... | // GroupRenewTTL will renew lease TTL | [
"GroupRenewTTL",
"will",
"renew",
"lease",
"TTL"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/groups/memory_group_service.go#L188-L203 |
28,395 | topfreegames/pitaya | modules/binding_storage.go | NewETCDBindingStorage | func NewETCDBindingStorage(server *cluster.Server, conf *config.Config) *ETCDBindingStorage {
b := &ETCDBindingStorage{
config: conf,
thisServer: server,
stopChan: make(chan struct{}),
}
b.configure()
return b
} | go | func NewETCDBindingStorage(server *cluster.Server, conf *config.Config) *ETCDBindingStorage {
b := &ETCDBindingStorage{
config: conf,
thisServer: server,
stopChan: make(chan struct{}),
}
b.configure()
return b
} | [
"func",
"NewETCDBindingStorage",
"(",
"server",
"*",
"cluster",
".",
"Server",
",",
"conf",
"*",
"config",
".",
"Config",
")",
"*",
"ETCDBindingStorage",
"{",
"b",
":=",
"&",
"ETCDBindingStorage",
"{",
"config",
":",
"conf",
",",
"thisServer",
":",
"server",... | // NewETCDBindingStorage returns a new instance of BindingStorage | [
"NewETCDBindingStorage",
"returns",
"a",
"new",
"instance",
"of",
"BindingStorage"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/modules/binding_storage.go#L52-L60 |
28,396 | topfreegames/pitaya | modules/binding_storage.go | PutBinding | func (b *ETCDBindingStorage) PutBinding(uid string) error {
_, err := b.cli.Put(context.Background(), getUserBindingKey(uid, b.thisServer.Type), b.thisServer.ID, clientv3.WithLease(b.leaseID))
return err
} | go | func (b *ETCDBindingStorage) PutBinding(uid string) error {
_, err := b.cli.Put(context.Background(), getUserBindingKey(uid, b.thisServer.Type), b.thisServer.ID, clientv3.WithLease(b.leaseID))
return err
} | [
"func",
"(",
"b",
"*",
"ETCDBindingStorage",
")",
"PutBinding",
"(",
"uid",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"b",
".",
"cli",
".",
"Put",
"(",
"context",
".",
"Background",
"(",
")",
",",
"getUserBindingKey",
"(",
"uid",
",",
"b",
... | // PutBinding puts the binding info into etcd | [
"PutBinding",
"puts",
"the",
"binding",
"info",
"into",
"etcd"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/modules/binding_storage.go#L74-L77 |
28,397 | topfreegames/pitaya | modules/binding_storage.go | Init | func (b *ETCDBindingStorage) Init() error {
var cli *clientv3.Client
var err error
if b.cli == nil {
cli, err = clientv3.New(clientv3.Config{
Endpoints: b.etcdEndpoints,
DialTimeout: b.etcdDialTimeout,
})
if err != nil {
return err
}
b.cli = cli
}
// namespaced etcd :)
b.cli.KV = namespace.Ne... | go | func (b *ETCDBindingStorage) Init() error {
var cli *clientv3.Client
var err error
if b.cli == nil {
cli, err = clientv3.New(clientv3.Config{
Endpoints: b.etcdEndpoints,
DialTimeout: b.etcdDialTimeout,
})
if err != nil {
return err
}
b.cli = cli
}
// namespaced etcd :)
b.cli.KV = namespace.Ne... | [
"func",
"(",
"b",
"*",
"ETCDBindingStorage",
")",
"Init",
"(",
")",
"error",
"{",
"var",
"cli",
"*",
"clientv3",
".",
"Client",
"\n",
"var",
"err",
"error",
"\n",
"if",
"b",
".",
"cli",
"==",
"nil",
"{",
"cli",
",",
"err",
"=",
"clientv3",
".",
"... | // Init starts the binding storage module | [
"Init",
"starts",
"the",
"binding",
"storage",
"module"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/modules/binding_storage.go#L159-L185 |
28,398 | topfreegames/pitaya | modules/api_docs_gen.go | NewAPIDocsGen | func NewAPIDocsGen(basePath string, services []*component.Service) *APIDocsGen {
return &APIDocsGen{
basePath: basePath,
services: services,
}
} | go | func NewAPIDocsGen(basePath string, services []*component.Service) *APIDocsGen {
return &APIDocsGen{
basePath: basePath,
services: services,
}
} | [
"func",
"NewAPIDocsGen",
"(",
"basePath",
"string",
",",
"services",
"[",
"]",
"*",
"component",
".",
"Service",
")",
"*",
"APIDocsGen",
"{",
"return",
"&",
"APIDocsGen",
"{",
"basePath",
":",
"basePath",
",",
"services",
":",
"services",
",",
"}",
"\n",
... | // NewAPIDocsGen creates a new APIDocsGen | [
"NewAPIDocsGen",
"creates",
"a",
"new",
"APIDocsGen"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/modules/api_docs_gen.go#L36-L41 |
28,399 | topfreegames/pitaya | modules/api_docs_gen.go | Init | func (a *APIDocsGen) Init() error {
for _, s := range a.services {
logger.Log.Infof("loaded svc: %s", s.Name)
}
return nil
} | go | func (a *APIDocsGen) Init() error {
for _, s := range a.services {
logger.Log.Infof("loaded svc: %s", s.Name)
}
return nil
} | [
"func",
"(",
"a",
"*",
"APIDocsGen",
")",
"Init",
"(",
")",
"error",
"{",
"for",
"_",
",",
"s",
":=",
"range",
"a",
".",
"services",
"{",
"logger",
".",
"Log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"s",
".",
"Name",
")",
"\n",
"}",
"\n",
"retur... | // Init is called on init method | [
"Init",
"is",
"called",
"on",
"init",
"method"
] | b92161d7a48c87a7759ac9cabcc23e7d56f9eebd | https://github.com/topfreegames/pitaya/blob/b92161d7a48c87a7759ac9cabcc23e7d56f9eebd/modules/api_docs_gen.go#L44-L49 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.