• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

topfreegames / pitaya / 5547019595

13 Jul 2023 07:15PM UTC coverage: 62.183% (-0.02%) from 62.204%
5547019595

Pull #318

github

rsafonseca
fixup
Pull Request #318: Allow migration of static api to work for connectors, allow exposing …

9 of 9 new or added lines in 2 files covered. (100.0%)

4780 of 7687 relevant lines covered (62.18%)

0.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.81
/static.go
1
// Copyright (c) TFG Co. All Rights Reserved.
2
//
3
// Permission is hereby granted, free of charge, to any person obtaining a copy
4
// of this software and associated documentation files (the "Software"), to deal
5
// in the Software without restriction, including without limitation the rights
6
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
// copies of the Software, and to permit persons to whom the Software is
8
// furnished to do so, subject to the following conditions:
9
//
10
// The above copyright notice and this permission notice shall be included in all
11
// copies or substantial portions of the Software.
12
//
13
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
// SOFTWARE.
20

21
package pitaya
22

23
import (
24
        "context"
25
        "time"
26

27
        "github.com/golang/protobuf/proto"
28
        "github.com/spf13/viper"
29
        "github.com/topfreegames/pitaya/v2/acceptor"
30
        "github.com/topfreegames/pitaya/v2/cluster"
31
        "github.com/topfreegames/pitaya/v2/component"
32
        "github.com/topfreegames/pitaya/v2/config"
33
        "github.com/topfreegames/pitaya/v2/interfaces"
34
        "github.com/topfreegames/pitaya/v2/metrics"
35
        "github.com/topfreegames/pitaya/v2/router"
36
        "github.com/topfreegames/pitaya/v2/session"
37
        "github.com/topfreegames/pitaya/v2/worker"
38
)
39

40
var DefaultApp Pitaya
41

42
// Configure configures the app
43
func Configure(
44
        isFrontend bool,
45
        serverType string,
46
        serverMode ServerMode,
47
        serverMetadata map[string]string,
48
        cfgs ...*viper.Viper,
49
) {
1✔
50
        builder := NewBuilderWithConfigs(
1✔
51
                isFrontend,
1✔
52
                serverType,
1✔
53
                serverMode,
1✔
54
                serverMetadata,
1✔
55
                config.NewConfig(cfgs...),
1✔
56
        )
1✔
57
        DefaultApp = builder.Build()
1✔
58
        session.DefaultSessionPool = builder.SessionPool
1✔
59
}
1✔
60

61
func GetDieChan() chan bool {
1✔
62
        return DefaultApp.GetDieChan()
1✔
63
}
1✔
64

65
func SetDebug(debug bool) {
1✔
66
        DefaultApp.SetDebug(debug)
1✔
67
}
1✔
68

69
func SetHeartbeatTime(interval time.Duration) {
1✔
70
        DefaultApp.SetHeartbeatTime(interval)
1✔
71
}
1✔
72

73
func GetServerID() string {
1✔
74
        return DefaultApp.GetServerID()
1✔
75
}
1✔
76

77
func GetMetricsReporters() []metrics.Reporter {
1✔
78
        return DefaultApp.GetMetricsReporters()
1✔
79
}
1✔
80

81
func GetServer() *cluster.Server {
1✔
82
        return DefaultApp.GetServer()
1✔
83
}
1✔
84

85
func GetServerByID(id string) (*cluster.Server, error) {
1✔
86
        return DefaultApp.GetServerByID(id)
1✔
87
}
1✔
88

89
func GetServersByType(t string) (map[string]*cluster.Server, error) {
1✔
90
        return DefaultApp.GetServersByType(t)
1✔
91
}
1✔
92

93
func GetServers() []*cluster.Server {
1✔
94
        return DefaultApp.GetServers()
1✔
95
}
1✔
96

97
func GetSessionFromCtx(ctx context.Context) session.Session {
1✔
98
        return DefaultApp.GetSessionFromCtx(ctx)
1✔
99
}
1✔
100

101
func Start() {
1✔
102
        DefaultApp.Start()
1✔
103
}
1✔
104

105
func SetDictionary(dict map[string]uint16) error {
1✔
106
        return DefaultApp.SetDictionary(dict)
1✔
107
}
1✔
108

109
func AddRoute(serverType string, routingFunction router.RoutingFunc) error {
1✔
110
        return DefaultApp.AddRoute(serverType, routingFunction)
1✔
111
}
1✔
112

113
func Shutdown() {
1✔
114
        DefaultApp.Shutdown()
1✔
115
}
1✔
116

117
func StartWorker() {
1✔
118
        DefaultApp.StartWorker()
1✔
119
}
1✔
120

121
func RegisterRPCJob(rpcJob worker.RPCJob) error {
1✔
122
        return DefaultApp.RegisterRPCJob(rpcJob)
1✔
123
}
1✔
124

125
func Documentation(getPtrNames bool) (map[string]interface{}, error) {
1✔
126
        return DefaultApp.Documentation(getPtrNames)
1✔
127
}
1✔
128

129
func IsRunning() bool {
1✔
130
        return DefaultApp.IsRunning()
1✔
131
}
1✔
132

133
func RPC(ctx context.Context, routeStr string, reply proto.Message, arg proto.Message) error {
1✔
134
        return DefaultApp.RPC(ctx, routeStr, reply, arg)
1✔
135
}
1✔
136

137
func RPCTo(ctx context.Context, serverID, routeStr string, reply proto.Message, arg proto.Message) error {
1✔
138
        return DefaultApp.RPCTo(ctx, serverID, routeStr, reply, arg)
1✔
139
}
1✔
140

141
func ReliableRPC(routeStr string, metadata map[string]interface{}, reply, arg proto.Message) (jid string, err error) {
1✔
142
        return DefaultApp.ReliableRPC(routeStr, metadata, reply, arg)
1✔
143
}
1✔
144

145
func ReliableRPCWithOptions(routeStr string, metadata map[string]interface{}, reply, arg proto.Message, opts *config.EnqueueOpts) (jid string, err error) {
1✔
146
        return DefaultApp.ReliableRPCWithOptions(routeStr, metadata, reply, arg, opts)
1✔
147
}
1✔
148

149
func SendPushToUsers(route string, v interface{}, uids []string, frontendType string) ([]string, error) {
1✔
150
        return DefaultApp.SendPushToUsers(route, v, uids, frontendType)
1✔
151
}
1✔
152

153
func SendKickToUsers(uids []string, frontendType string) ([]string, error) {
1✔
154
        return DefaultApp.SendKickToUsers(uids, frontendType)
1✔
155
}
1✔
156

157
func GroupCreate(ctx context.Context, groupName string) error {
1✔
158
        return DefaultApp.GroupCreate(ctx, groupName)
1✔
159
}
1✔
160

161
func GroupCreateWithTTL(ctx context.Context, groupName string, ttlTime time.Duration) error {
1✔
162
        return DefaultApp.GroupCreateWithTTL(ctx, groupName, ttlTime)
1✔
163
}
1✔
164

165
func GroupMembers(ctx context.Context, groupName string) ([]string, error) {
1✔
166
        return DefaultApp.GroupMembers(ctx, groupName)
1✔
167
}
1✔
168

169
func GroupBroadcast(ctx context.Context, frontendType, groupName, route string, v interface{}) error {
1✔
170
        return DefaultApp.GroupBroadcast(ctx, frontendType, groupName, route, v)
1✔
171
}
1✔
172

173
func GroupContainsMember(ctx context.Context, groupName, uid string) (bool, error) {
1✔
174
        return DefaultApp.GroupContainsMember(ctx, groupName, uid)
1✔
175
}
1✔
176

177
func GroupAddMember(ctx context.Context, groupName, uid string) error {
1✔
178
        return DefaultApp.GroupAddMember(ctx, groupName, uid)
1✔
179
}
1✔
180

181
func GroupRemoveMember(ctx context.Context, groupName, uid string) error {
1✔
182
        return DefaultApp.GroupRemoveMember(ctx, groupName, uid)
1✔
183
}
1✔
184

185
func GroupRemoveAll(ctx context.Context, groupName string) error {
1✔
186
        return DefaultApp.GroupRemoveAll(ctx, groupName)
1✔
187
}
1✔
188

189
func GroupCountMembers(ctx context.Context, groupName string) (int, error) {
1✔
190
        return DefaultApp.GroupCountMembers(ctx, groupName)
1✔
191
}
1✔
192

193
func GroupRenewTTL(ctx context.Context, groupName string) error {
1✔
194
        return DefaultApp.GroupRenewTTL(ctx, groupName)
1✔
195
}
1✔
196

197
func GroupDelete(ctx context.Context, groupName string) error {
1✔
198
        return DefaultApp.GroupDelete(ctx, groupName)
1✔
199
}
1✔
200

201
func Register(c component.Component, options ...component.Option) {
1✔
202
        DefaultApp.Register(c, options...)
1✔
203
}
1✔
204

205
func RegisterRemote(c component.Component, options ...component.Option) {
1✔
206
        DefaultApp.RegisterRemote(c, options...)
1✔
207
}
1✔
208

209
func RegisterModule(module interfaces.Module, name string) error {
1✔
210
        return DefaultApp.RegisterModule(module, name)
1✔
211
}
1✔
212

213
func RegisterModuleAfter(module interfaces.Module, name string) error {
1✔
214
        return DefaultApp.RegisterModuleAfter(module, name)
1✔
215
}
1✔
216

217
func RegisterModuleBefore(module interfaces.Module, name string) error {
1✔
218
        return DefaultApp.RegisterModuleBefore(module, name)
1✔
219
}
1✔
220

221
func GetModule(name string) (interfaces.Module, error) {
1✔
222
        return DefaultApp.GetModule(name)
1✔
223
}
1✔
224

225
func AddAcceptor(ac acceptor.Acceptor) {
×
226
        DefaultApp.AddAcceptor(ac)
×
227
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc