diff --git a/build/Makefile b/build/Makefile index 00229bb9ac..1cedfa14be 100644 --- a/build/Makefile +++ b/build/Makefile @@ -57,7 +57,7 @@ KIND_PROFILE ?= agones KIND_CONTAINER_NAME=kind-$(KIND_PROFILE)-control-plane # Game Server image to use while doing end-to-end tests -GS_TEST_IMAGE ?= gcr.io/agones-images/udp-server:0.7 +GS_TEST_IMAGE ?= gcr.io/agones-images/udp-server:0.8 # Directory that this Makefile is in. mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) diff --git a/examples/fleet.yaml b/examples/fleet.yaml index f199731301..eea0dc334a 100644 --- a/examples/fleet.yaml +++ b/examples/fleet.yaml @@ -67,4 +67,4 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.7 \ No newline at end of file + image: gcr.io/agones-images/udp-server:0.8 \ No newline at end of file diff --git a/examples/simple-udp/Makefile b/examples/simple-udp/Makefile index 7d99d402c0..7a1030e08e 100644 --- a/examples/simple-udp/Makefile +++ b/examples/simple-udp/Makefile @@ -27,7 +27,7 @@ REPOSITORY = gcr.io/agones-images mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) project_path := $(dir $(mkfile_path)) -server_tag = $(REPOSITORY)/udp-server:0.7 +server_tag = $(REPOSITORY)/udp-server:0.8 root_path = $(realpath $(project_path)/../..) # _____ _ diff --git a/examples/simple-udp/fleet-distributed.yaml b/examples/simple-udp/fleet-distributed.yaml index 1d1c33a915..4a397e5baa 100644 --- a/examples/simple-udp/fleet-distributed.yaml +++ b/examples/simple-udp/fleet-distributed.yaml @@ -32,7 +32,7 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.7 + image: gcr.io/agones-images/udp-server:0.8 resources: requests: memory: "32Mi" diff --git a/examples/simple-udp/fleet.yaml b/examples/simple-udp/fleet.yaml index c4c41a01f5..c0448327bb 100644 --- a/examples/simple-udp/fleet.yaml +++ b/examples/simple-udp/fleet.yaml @@ -27,7 +27,7 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.7 + image: gcr.io/agones-images/udp-server:0.8 resources: requests: memory: "64Mi" diff --git a/examples/simple-udp/gameserver.yaml b/examples/simple-udp/gameserver.yaml index 0abc74d7f9..121551ff68 100644 --- a/examples/simple-udp/gameserver.yaml +++ b/examples/simple-udp/gameserver.yaml @@ -25,7 +25,7 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.7 + image: gcr.io/agones-images/udp-server:0.8 resources: requests: memory: "32Mi" diff --git a/examples/simple-udp/gameserverset.yaml b/examples/simple-udp/gameserverset.yaml index 0c2b0cc510..e62b2da8cb 100644 --- a/examples/simple-udp/gameserverset.yaml +++ b/examples/simple-udp/gameserverset.yaml @@ -31,4 +31,4 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.7 \ No newline at end of file + image: gcr.io/agones-images/udp-server:0.8 \ No newline at end of file diff --git a/examples/simple-udp/main.go b/examples/simple-udp/main.go index e1d545f9d7..bedd977d8e 100644 --- a/examples/simple-udp/main.go +++ b/examples/simple-udp/main.go @@ -94,6 +94,9 @@ func readWriteLoop(conn net.PacketConn, stop chan struct{}, s *sdk.SDK) { case "GAMESERVER": writeGameServerName(s, conn, sender) + case "ALLOCATE": + allocate(s) + case "WATCH": watchGameServerEvents(s) @@ -126,6 +129,14 @@ func readWriteLoop(conn net.PacketConn, stop chan struct{}, s *sdk.SDK) { } } +// allocate attemps to allocate this gameserver +func allocate(s *sdk.SDK) { + err := s.Allocate() + if err != nil { + log.Fatalf("could not allocate gameserver: %v", err) + } +} + // readPacket reads a string from the connection func readPacket(conn net.PacketConn, b []byte) (net.Addr, string) { n, sender, err := conn.ReadFrom(b) diff --git a/install/helm/agones/templates/NOTES.txt b/install/helm/agones/templates/NOTES.txt index c8928e9238..9d31364ee5 100644 --- a/install/helm/agones/templates/NOTES.txt +++ b/install/helm/agones/templates/NOTES.txt @@ -19,7 +19,7 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.7 + image: gcr.io/agones-images/udp-server:0.8 Finally don't forget to explore our documentation and usage guides on how to develop and host dedicated game servers on top of Agones. : diff --git a/pkg/sdk/sdk.pb.go b/pkg/sdk/sdk.pb.go index 8e3fb2544e..9136853f8a 100644 --- a/pkg/sdk/sdk.pb.go +++ b/pkg/sdk/sdk.pb.go @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC All Rights Reserved. +// Copyright 2019 Google LLC All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ func (m *Empty) Reset() { *m = Empty{} } func (m *Empty) String() string { return proto.CompactTextString(m) } func (*Empty) ProtoMessage() {} func (*Empty) Descriptor() ([]byte, []int) { - return fileDescriptor_sdk_fdecc22016921ca8, []int{0} + return fileDescriptor_sdk_e1f182e54a272927, []int{0} } func (m *Empty) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Empty.Unmarshal(m, b) @@ -83,7 +83,7 @@ func (m *KeyValue) Reset() { *m = KeyValue{} } func (m *KeyValue) String() string { return proto.CompactTextString(m) } func (*KeyValue) ProtoMessage() {} func (*KeyValue) Descriptor() ([]byte, []int) { - return fileDescriptor_sdk_fdecc22016921ca8, []int{1} + return fileDescriptor_sdk_e1f182e54a272927, []int{1} } func (m *KeyValue) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_KeyValue.Unmarshal(m, b) @@ -133,7 +133,7 @@ func (m *GameServer) Reset() { *m = GameServer{} } func (m *GameServer) String() string { return proto.CompactTextString(m) } func (*GameServer) ProtoMessage() {} func (*GameServer) Descriptor() ([]byte, []int) { - return fileDescriptor_sdk_fdecc22016921ca8, []int{2} + return fileDescriptor_sdk_e1f182e54a272927, []int{2} } func (m *GameServer) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GameServer.Unmarshal(m, b) @@ -196,7 +196,7 @@ func (m *GameServer_ObjectMeta) Reset() { *m = GameServer_ObjectMeta{} } func (m *GameServer_ObjectMeta) String() string { return proto.CompactTextString(m) } func (*GameServer_ObjectMeta) ProtoMessage() {} func (*GameServer_ObjectMeta) Descriptor() ([]byte, []int) { - return fileDescriptor_sdk_fdecc22016921ca8, []int{2, 0} + return fileDescriptor_sdk_e1f182e54a272927, []int{2, 0} } func (m *GameServer_ObjectMeta) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GameServer_ObjectMeta.Unmarshal(m, b) @@ -290,7 +290,7 @@ func (m *GameServer_Spec) Reset() { *m = GameServer_Spec{} } func (m *GameServer_Spec) String() string { return proto.CompactTextString(m) } func (*GameServer_Spec) ProtoMessage() {} func (*GameServer_Spec) Descriptor() ([]byte, []int) { - return fileDescriptor_sdk_fdecc22016921ca8, []int{2, 1} + return fileDescriptor_sdk_e1f182e54a272927, []int{2, 1} } func (m *GameServer_Spec) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GameServer_Spec.Unmarshal(m, b) @@ -331,7 +331,7 @@ func (m *GameServer_Spec_Health) Reset() { *m = GameServer_Spec_Health{} func (m *GameServer_Spec_Health) String() string { return proto.CompactTextString(m) } func (*GameServer_Spec_Health) ProtoMessage() {} func (*GameServer_Spec_Health) Descriptor() ([]byte, []int) { - return fileDescriptor_sdk_fdecc22016921ca8, []int{2, 1, 0} + return fileDescriptor_sdk_e1f182e54a272927, []int{2, 1, 0} } func (m *GameServer_Spec_Health) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GameServer_Spec_Health.Unmarshal(m, b) @@ -392,7 +392,7 @@ func (m *GameServer_Status) Reset() { *m = GameServer_Status{} } func (m *GameServer_Status) String() string { return proto.CompactTextString(m) } func (*GameServer_Status) ProtoMessage() {} func (*GameServer_Status) Descriptor() ([]byte, []int) { - return fileDescriptor_sdk_fdecc22016921ca8, []int{2, 2} + return fileDescriptor_sdk_e1f182e54a272927, []int{2, 2} } func (m *GameServer_Status) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GameServer_Status.Unmarshal(m, b) @@ -445,7 +445,7 @@ func (m *GameServer_Status_Port) Reset() { *m = GameServer_Status_Port{} func (m *GameServer_Status_Port) String() string { return proto.CompactTextString(m) } func (*GameServer_Status_Port) ProtoMessage() {} func (*GameServer_Status_Port) Descriptor() ([]byte, []int) { - return fileDescriptor_sdk_fdecc22016921ca8, []int{2, 2, 0} + return fileDescriptor_sdk_e1f182e54a272927, []int{2, 2, 0} } func (m *GameServer_Status_Port) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GameServer_Status_Port.Unmarshal(m, b) @@ -506,6 +506,8 @@ const _ = grpc.SupportPackageIsVersion4 type SDKClient interface { // Call when the GameServer is ready Ready(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) + // Call to self Allocation the GameServer + Allocate(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) // Call when the GameServer is shutting down Shutdown(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) // Send a Empty every d Duration to declare that this GameSever is healthy @@ -537,6 +539,15 @@ func (c *sDKClient) Ready(ctx context.Context, in *Empty, opts ...grpc.CallOptio return out, nil } +func (c *sDKClient) Allocate(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) { + out := new(Empty) + err := c.cc.Invoke(ctx, "/stable.agones.dev.sdk.SDK/Allocate", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *sDKClient) Shutdown(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) { out := new(Empty) err := c.cc.Invoke(ctx, "/stable.agones.dev.sdk.SDK/Shutdown", in, out, opts...) @@ -643,6 +654,8 @@ func (c *sDKClient) SetAnnotation(ctx context.Context, in *KeyValue, opts ...grp type SDKServer interface { // Call when the GameServer is ready Ready(context.Context, *Empty) (*Empty, error) + // Call to self Allocation the GameServer + Allocate(context.Context, *Empty) (*Empty, error) // Call when the GameServer is shutting down Shutdown(context.Context, *Empty) (*Empty, error) // Send a Empty every d Duration to declare that this GameSever is healthy @@ -679,6 +692,24 @@ func _SDK_Ready_Handler(srv interface{}, ctx context.Context, dec func(interface return interceptor(ctx, in, info, handler) } +func _SDK_Allocate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SDKServer).Allocate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/stable.agones.dev.sdk.SDK/Allocate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SDKServer).Allocate(ctx, req.(*Empty)) + } + return interceptor(ctx, in, info, handler) +} + func _SDK_Shutdown_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(Empty) if err := dec(in); err != nil { @@ -806,6 +837,10 @@ var _SDK_serviceDesc = grpc.ServiceDesc{ MethodName: "Ready", Handler: _SDK_Ready_Handler, }, + { + MethodName: "Allocate", + Handler: _SDK_Allocate_Handler, + }, { MethodName: "Shutdown", Handler: _SDK_Shutdown_Handler, @@ -838,58 +873,59 @@ var _SDK_serviceDesc = grpc.ServiceDesc{ Metadata: "sdk.proto", } -func init() { proto.RegisterFile("sdk.proto", fileDescriptor_sdk_fdecc22016921ca8) } - -var fileDescriptor_sdk_fdecc22016921ca8 = []byte{ - // 789 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xef, 0x6e, 0xe3, 0x44, - 0x10, 0x97, 0x1b, 0xdb, 0x4d, 0xc6, 0x94, 0xa6, 0xdb, 0x20, 0xf9, 0xac, 0x8a, 0x2b, 0x16, 0x42, - 0x21, 0xe2, 0xec, 0x53, 0xf8, 0x72, 0x44, 0x02, 0xf1, 0xa7, 0xe5, 0x40, 0xc7, 0x89, 0xca, 0x39, - 0x15, 0xe9, 0x84, 0x14, 0x6d, 0xec, 0x51, 0x62, 0xe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2d, - 0x3f, 0x07, 0x08, 0x00, 0x00, +func init() { proto.RegisterFile("sdk.proto", fileDescriptor_sdk_e1f182e54a272927) } + +var fileDescriptor_sdk_e1f182e54a272927 = []byte{ + // 802 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xe1, 0x6e, 0xe3, 0x44, + 0x10, 0x96, 0x1b, 0xdb, 0x4d, 0xc6, 0x94, 0xb6, 0xdb, 0x20, 0xf9, 0xac, 0x8a, 0x2b, 0x16, 0x42, + 0x21, 0xe2, 0xec, 0x53, 0xf8, 0x73, 0x44, 0x02, 0x71, 0xd0, 0x72, 0xa0, 0xe3, 0x44, 0xe5, 0x9c, + 0x8a, 0x74, 0x42, 0x8a, 0x36, 0xf6, 0x28, 0x31, 0x71, 0xbc, 0xd6, 0xee, 0x26, 0xa7, 0xfc, 0xe5, + 0x15, 0x78, 0x06, 0x04, 0x7f, 0xe0, 0x65, 0x78, 0x05, 0x1e, 0x82, 0x9f, 0x68, 0xd7, 0x76, 0x1d, + 0xee, 0x7a, 0xd7, 0x54, 0xed, 0xaf, 0xcc, 0xce, 0xcc, 0xf7, 0x7d, 0xeb, 0xd9, 0xd9, 0xd9, 0x40, + 0x47, 0x24, 0xf3, 0xa0, 0xe0, 0x4c, 0x32, 0xf2, 0x9e, 0x90, 0x74, 0x92, 0x61, 0x40, 0xa7, 0x2c, + 0x47, 0x11, 0x24, 0xb8, 0x0a, 0x44, 0x32, 0xf7, 0x8e, 0xa7, 0x8c, 0x4d, 0x33, 0x0c, 0x69, 0x91, + 0x86, 0x34, 0xcf, 0x99, 0xa4, 0x32, 0x65, 0xb9, 0x28, 0x41, 0xfe, 0x2e, 0x58, 0x67, 0x8b, 0x42, + 0xae, 0xfd, 0x01, 0xb4, 0x9f, 0xe2, 0xfa, 0x82, 0x66, 0x4b, 0x24, 0x07, 0xd0, 0x9a, 0xe3, 0xda, + 0x35, 0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e3, 0xd9, 0x5d, 0x0a, 0xdd, 0xd3, 0x42, 0x47, 0xe4, 0x30, 0x7c, 0xa9, 0xa8, 0x37, + 0xe4, 0x1e, 0xaa, 0xef, 0x6a, 0x8f, 0x50, 0xea, 0xc1, 0x41, 0xee, 0xbf, 0x81, 0xab, 0x7e, 0x55, + 0xaf, 0x29, 0x9c, 0xa7, 0x75, 0xba, 0xde, 0x7e, 0xa8, 0x1e, 0xcf, 0x84, 0x4a, 0x1a, 0xea, 0xd1, + 0xa6, 0x8e, 0x86, 0xc1, 0xde, 0x08, 0x65, 0x33, 0xdf, 0x6e, 0xab, 0x75, 0x5f, 0x6b, 0xdd, 0xf3, + 0xba, 0x8d, 0x56, 0x33, 0x9d, 0x87, 0x46, 0xff, 0x2b, 0xeb, 0x45, 0x4b, 0x24, 0xf3, 0x89, 0xad, + 0xff, 0x23, 0x7c, 0xfa, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xcc, 0xfa, 0xc6, 0xec, 0x65, 0x08, + 0x00, 0x00, } diff --git a/pkg/sdk/sdk.pb.gw.go b/pkg/sdk/sdk.pb.gw.go index c16b28fecb..55293f91ea 100644 --- a/pkg/sdk/sdk.pb.gw.go +++ b/pkg/sdk/sdk.pb.gw.go @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC All Rights Reserved. +// Copyright 2019 Google LLC All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -56,6 +56,19 @@ func request_SDK_Ready_0(ctx context.Context, marshaler runtime.Marshaler, clien } +func request_SDK_Allocate_0(ctx context.Context, marshaler runtime.Marshaler, client SDKClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq Empty + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Allocate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + func request_SDK_Shutdown_0(ctx context.Context, marshaler runtime.Marshaler, client SDKClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq Empty var metadata runtime.ServerMetadata @@ -229,6 +242,35 @@ func RegisterSDKHandlerClient(ctx context.Context, mux *runtime.ServeMux, client }) + mux.Handle("POST", pattern_SDK_Allocate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + if cn, ok := w.(http.CloseNotifier); ok { + go func(done <-chan struct{}, closed <-chan bool) { + select { + case <-done: + case <-closed: + cancel() + } + }(ctx.Done(), cn.CloseNotify()) + } + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SDK_Allocate_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_SDK_Allocate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("POST", pattern_SDK_Shutdown_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -409,6 +451,8 @@ func RegisterSDKHandlerClient(ctx context.Context, mux *runtime.ServeMux, client var ( pattern_SDK_Ready_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"ready"}, "")) + pattern_SDK_Allocate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"allocate"}, "")) + pattern_SDK_Shutdown_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"shutdown"}, "")) pattern_SDK_Health_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"health"}, "")) @@ -425,6 +469,8 @@ var ( var ( forward_SDK_Ready_0 = runtime.ForwardResponseMessage + forward_SDK_Allocate_0 = runtime.ForwardResponseMessage + forward_SDK_Shutdown_0 = runtime.ForwardResponseMessage forward_SDK_Health_0 = runtime.ForwardResponseMessage diff --git a/pkg/sdkserver/localsdk.go b/pkg/sdkserver/localsdk.go index cfff36383c..c98d240700 100644 --- a/pkg/sdkserver/localsdk.go +++ b/pkg/sdkserver/localsdk.go @@ -121,6 +121,12 @@ func (l *LocalSDKServer) Ready(context.Context, *sdk.Empty) (*sdk.Empty, error) return &sdk.Empty{}, nil } +// Allocate logs that an allocate request has been received +func (l *LocalSDKServer) Allocate(context.Context, *sdk.Empty) (*sdk.Empty, error) { + logrus.Info("Allocate request has been received!") + return &sdk.Empty{}, nil +} + // Shutdown logs that the shutdown request has been received func (l *LocalSDKServer) Shutdown(context.Context, *sdk.Empty) (*sdk.Empty, error) { logrus.Info("Shutdown request has been received!") diff --git a/pkg/sdkserver/sdkserver.go b/pkg/sdkserver/sdkserver.go index 02802507de..b34cba38d3 100644 --- a/pkg/sdkserver/sdkserver.go +++ b/pkg/sdkserver/sdkserver.go @@ -35,6 +35,7 @@ import ( "github.com/sirupsen/logrus" "golang.org/x/net/context" corev1 "k8s.io/api/core/v1" + k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/util/clock" @@ -55,7 +56,17 @@ const ( updateAnnotation Operation = "updateAnnotation" ) -var _ sdk.SDKServer = &SDKServer{} +var ( + _ sdk.SDKServer = &SDKServer{} + + defaultTimeout = 30 * time.Second + defaultBackoff = wait.Backoff{ + Duration: 100 * time.Millisecond, + Factor: 1, + Jitter: 0.1, + Steps: 5, + } +) // SDKServer is a gRPC server, that is meant to be a sidecar // for a GameServer that will update the game server status on SDK requests @@ -330,6 +341,51 @@ func (s *SDKServer) Ready(ctx context.Context, e *sdk.Empty) (*sdk.Empty, error) return e, nil } +// Allocate set the GameServer to Allocate, as longs as it's not in UnHealthy, +// Shutdown or has a DeletionTimeStamp(). Times out after 30 seconds if it cannot +// complete the operation due to contention issues. +func (s *SDKServer) Allocate(context.Context, *sdk.Empty) (*sdk.Empty, error) { + s.logger.Info("Received self Allocate request") + + now := s.clock.Now() + err := wait.ExponentialBackoff(defaultBackoff, func() (done bool, err error) { + gs, err := s.gameServer() + if err != nil { + return true, err + } + + if !gs.ObjectMeta.DeletionTimestamp.IsZero() { + return true, nil + } + + switch gs.Status.State { + case stablev1alpha1.GameServerStateUnhealthy: + return true, errors.New("cannot Allocate an Unhealthy GameServer") + + case stablev1alpha1.GameServerStateShutdown: + return true, errors.New("cannot Allocate a Shutdown GameServer") + } + + gsCopy := gs.DeepCopy() + gsCopy.Status.State = stablev1alpha1.GameServerStateAllocated + _, err = s.gameServerGetter.GameServers(s.namespace).Update(gsCopy) + + // if a contention, and we are under the timeout period. + if k8serrors.IsConflict(err) { + // TODO: write a test for this + if s.clock.Since(now) > defaultTimeout { + return true, errors.New("Allocation request timed out") + } + + return false, nil + } + + return true, errors.Wrap(err, "could not update gameserver to Allocated") + }) + + return &sdk.Empty{}, errors.WithStack(err) +} + // Shutdown enters the Shutdown state change for this GameServer into // the workqueue so it can be updated func (s *SDKServer) Shutdown(ctx context.Context, e *sdk.Empty) (*sdk.Empty, error) { diff --git a/pkg/sdkserver/sdkserver_test.go b/pkg/sdkserver/sdkserver_test.go index 04d08fb127..d47d91dd8f 100644 --- a/pkg/sdkserver/sdkserver_test.go +++ b/pkg/sdkserver/sdkserver_test.go @@ -23,11 +23,14 @@ import ( "agones.dev/agones/pkg/apis/stable/v1alpha1" "agones.dev/agones/pkg/sdk" agtesting "agones.dev/agones/pkg/testing" + "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" "golang.org/x/net/context" + k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/watch" @@ -101,6 +104,15 @@ func TestSidecarRun(t *testing.T) { metadataPrefix + "test-2": "annotation-2"}, }, }, + "allocated": { + f: func(sc *SDKServer, ctx context.Context) { + _, err := sc.Allocate(ctx, &sdk.Empty{}) + assert.NoError(t, err) + }, + expected: expected{ + state: v1alpha1.GameServerStateAllocated, + }, + }, } for k, v := range fixtures { @@ -143,6 +155,11 @@ func TestSidecarRun(t *testing.T) { }) sc, err := NewSDKServer("test", "default", m.KubeClient, m.AgonesClient) + stop := make(chan struct{}) + defer close(stop) + sc.informerFactory.Start(stop) + assert.True(t, cache.WaitForCacheSync(stop, sc.gameServerSynced)) + assert.Nil(t, err) sc.recorder = m.FakeRecorder @@ -630,6 +647,177 @@ func TestSDKServerUpdateEventHandler(t *testing.T) { assert.Equal(t, fixture.ObjectMeta.Name, sdkGS.ObjectMeta.Name) } +func TestSDKServerAllocate(t *testing.T) { + t.Parallel() + + defaultGs := &v1alpha1.GameServer{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + Namespace: "default", + }, + Status: v1alpha1.GameServerStatus{ + State: v1alpha1.GameServerStateReady, + }, + } + + setup := func(t *testing.T, fixture *v1alpha1.GameServer) (agtesting.Mocks, *SDKServer, chan struct{}) { + m := agtesting.NewMocks() + m.AgonesClient.AddReactor("list", "gameservers", func(action k8stesting.Action) (bool, runtime.Object, error) { + return true, &v1alpha1.GameServerList{Items: []v1alpha1.GameServer{*fixture}}, nil + }) + stop := make(chan struct{}) + sc, err := defaultSidecar(m) + assert.Nil(t, err) + sc.informerFactory.Start(stop) + assert.True(t, cache.WaitForCacheSync(stop, sc.gameServerSynced)) + return m, sc, stop + } + + t.Run("works perfectly", func(t *testing.T) { + m, sc, stop := setup(t, defaultGs.DeepCopy()) + defer close(stop) + + done := make(chan struct{}, 10) + m.AgonesClient.AddReactor("update", "gameservers", func(action k8stesting.Action) (bool, runtime.Object, error) { + ua := action.(k8stesting.UpdateAction) + gs := ua.GetObject().(*v1alpha1.GameServer) + assert.Equal(t, v1alpha1.GameServerStateAllocated, gs.Status.State) + + defer func() { + done <- struct{}{} + }() + + return true, gs, nil + }) + + _, err := sc.Allocate(context.Background(), &sdk.Empty{}) + assert.NoError(t, err) + + select { + case <-done: + case <-time.After(5 * time.Second): + assert.Fail(t, "should be updated") + } + }) + + t.Run("contention on first build", func(t *testing.T) { + m, sc, stop := setup(t, defaultGs.DeepCopy()) + defer close(stop) + + done := make(chan struct{}, 10) + count := 0 + + m.AgonesClient.AddReactor("update", "gameservers", func(action k8stesting.Action) (bool, runtime.Object, error) { + ua := action.(k8stesting.UpdateAction) + defer func() { + done <- struct{}{} + }() + + count++ + if count == 1 { + return true, nil, k8serrors.NewConflict(schema.ParseGroupResource(""), "gameservers", errors.New("contention")) + } + + gs := ua.GetObject().(*v1alpha1.GameServer) + assert.Equal(t, v1alpha1.GameServerStateAllocated, gs.Status.State) + return true, gs, nil + }) + + _, err := sc.Allocate(context.Background(), &sdk.Empty{}) + assert.NoError(t, err) + + select { + case <-done: + case <-time.After(5 * time.Second): + assert.Fail(t, "have contention") + } + + select { + case <-done: + case <-time.After(5 * time.Second): + assert.Fail(t, "should be updated") + } + }) + + t.Run("timeout", func(t *testing.T) { + m, sc, stop := setup(t, defaultGs.DeepCopy()) + defer close(stop) + + now := time.Now() + fc := clock.NewFakeClock(now) + sc.clock = fc + + done := make(chan struct{}, 10) + + m.AgonesClient.AddReactor("update", "gameservers", func(action k8stesting.Action) (bool, runtime.Object, error) { + defer func() { + done <- struct{}{} + }() + + // move past timeout + fc.Step(40 * time.Second) + return true, nil, k8serrors.NewConflict(schema.ParseGroupResource(""), "gameservers", errors.New("contention")) + }) + + _, err := sc.Allocate(context.Background(), &sdk.Empty{}) + assert.EqualError(t, err, "Allocation request timed out") + + select { + case <-done: + case <-time.After(5 * time.Second): + assert.Fail(t, "have contention") + } + }) + + t.Run("unhealthy gameserver", func(t *testing.T) { + gs := defaultGs.DeepCopy() + gs.Status.State = v1alpha1.GameServerStateUnhealthy + _, sc, stop := setup(t, gs.DeepCopy()) + defer close(stop) + + _, err := sc.Allocate(context.Background(), &sdk.Empty{}) + assert.EqualError(t, err, "cannot Allocate an Unhealthy GameServer") + }) + + t.Run("Shutdown gameserver", func(t *testing.T) { + gs := defaultGs.DeepCopy() + gs.Status.State = v1alpha1.GameServerStateShutdown + _, sc, stop := setup(t, gs.DeepCopy()) + defer close(stop) + + _, err := sc.Allocate(context.Background(), &sdk.Empty{}) + assert.EqualError(t, err, "cannot Allocate a Shutdown GameServer") + }) + + t.Run("Deleting gameserver", func(t *testing.T) { + gs := defaultGs.DeepCopy() + now := metav1.Now() + gs.ObjectMeta.DeletionTimestamp = &now + _, sc, stop := setup(t, gs.DeepCopy()) + defer close(stop) + + _, err := sc.Allocate(context.Background(), &sdk.Empty{}) + assert.NoError(t, err) + }) + + t.Run("Unexpected error", func(t *testing.T) { + m, sc, stop := setup(t, defaultGs.DeepCopy()) + defer close(stop) + done := make(chan struct{}, 10) + + m.AgonesClient.AddReactor("update", "gameservers", func(action k8stesting.Action) (bool, runtime.Object, error) { + defer func() { + done <- struct{}{} + }() + + return true, nil, errors.New("a bad thing happened") + }) + + _, err := sc.Allocate(context.Background(), &sdk.Empty{}) + assert.Error(t, err) + }) +} + func defaultSidecar(m agtesting.Mocks) (*SDKServer, error) { return NewSDKServer("test", "default", m.KubeClient, m.AgonesClient) } diff --git a/sdk.proto b/sdk.proto index 1abae4404a..9311b38212 100644 --- a/sdk.proto +++ b/sdk.proto @@ -28,6 +28,15 @@ service SDK { body: "*" }; } + + // Call to self Allocation the GameServer + rpc Allocate(Empty) returns (Empty) { + option (google.api.http) = { + post: "/allocate" + body: "*" + }; + } + // Call when the GameServer is shutting down rpc Shutdown (Empty) returns (Empty) { option (google.api.http) = { diff --git a/sdk.swagger.json b/sdk.swagger.json index d87c3ba3d5..a26044d77a 100644 --- a/sdk.swagger.json +++ b/sdk.swagger.json @@ -14,6 +14,33 @@ "application/json" ], "paths": { + "/allocate": { + "post": { + "summary": "Call to self Allocation the GameServer", + "operationId": "Allocate", + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/sdkEmpty" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/sdkEmpty" + } + } + ], + "tags": [ + "SDK" + ] + } + }, "/gameserver": { "get": { "summary": "Retrieve the current GameServer data", diff --git a/sdks/cpp/include/agones/sdk.grpc.pb.h b/sdks/cpp/include/agones/sdk.grpc.pb.h index 10ed1df4f4..7c0cb92ee8 100644 --- a/sdks/cpp/include/agones/sdk.grpc.pb.h +++ b/sdks/cpp/include/agones/sdk.grpc.pb.h @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC All Rights Reserved. +// Copyright 2019 Google LLC All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -77,6 +77,14 @@ class SDK final { std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::stable::agones::dev::sdk::Empty>> PrepareAsyncReady(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) { return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::stable::agones::dev::sdk::Empty>>(PrepareAsyncReadyRaw(context, request, cq)); } + // Call to self Allocation the GameServer + virtual ::grpc::Status Allocate(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::stable::agones::dev::sdk::Empty* response) = 0; + std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::stable::agones::dev::sdk::Empty>> AsyncAllocate(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) { + return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::stable::agones::dev::sdk::Empty>>(AsyncAllocateRaw(context, request, cq)); + } + std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::stable::agones::dev::sdk::Empty>> PrepareAsyncAllocate(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) { + return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::stable::agones::dev::sdk::Empty>>(PrepareAsyncAllocateRaw(context, request, cq)); + } // Call when the GameServer is shutting down virtual ::grpc::Status Shutdown(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::stable::agones::dev::sdk::Empty* response) = 0; std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::stable::agones::dev::sdk::Empty>> AsyncShutdown(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) { @@ -134,6 +142,8 @@ class SDK final { virtual ~experimental_async_interface() {} // Call when the GameServer is ready virtual void Ready(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty* request, ::stable::agones::dev::sdk::Empty* response, std::function) = 0; + // Call to self Allocation the GameServer + virtual void Allocate(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty* request, ::stable::agones::dev::sdk::Empty* response, std::function) = 0; // Call when the GameServer is shutting down virtual void Shutdown(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty* request, ::stable::agones::dev::sdk::Empty* response, std::function) = 0; // Send a Empty every d Duration to declare that this GameSever is healthy @@ -149,6 +159,8 @@ class SDK final { private: virtual ::grpc::ClientAsyncResponseReaderInterface< ::stable::agones::dev::sdk::Empty>* AsyncReadyRaw(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientAsyncResponseReaderInterface< ::stable::agones::dev::sdk::Empty>* PrepareAsyncReadyRaw(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) = 0; + virtual ::grpc::ClientAsyncResponseReaderInterface< ::stable::agones::dev::sdk::Empty>* AsyncAllocateRaw(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) = 0; + virtual ::grpc::ClientAsyncResponseReaderInterface< ::stable::agones::dev::sdk::Empty>* PrepareAsyncAllocateRaw(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientAsyncResponseReaderInterface< ::stable::agones::dev::sdk::Empty>* AsyncShutdownRaw(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientAsyncResponseReaderInterface< ::stable::agones::dev::sdk::Empty>* PrepareAsyncShutdownRaw(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientWriterInterface< ::stable::agones::dev::sdk::Empty>* HealthRaw(::grpc::ClientContext* context, ::stable::agones::dev::sdk::Empty* response) = 0; @@ -174,6 +186,13 @@ class SDK final { std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::stable::agones::dev::sdk::Empty>> PrepareAsyncReady(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) { return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::stable::agones::dev::sdk::Empty>>(PrepareAsyncReadyRaw(context, request, cq)); } + ::grpc::Status Allocate(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::stable::agones::dev::sdk::Empty* response) override; + std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::stable::agones::dev::sdk::Empty>> AsyncAllocate(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) { + return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::stable::agones::dev::sdk::Empty>>(AsyncAllocateRaw(context, request, cq)); + } + std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::stable::agones::dev::sdk::Empty>> PrepareAsyncAllocate(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) { + return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::stable::agones::dev::sdk::Empty>>(PrepareAsyncAllocateRaw(context, request, cq)); + } ::grpc::Status Shutdown(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::stable::agones::dev::sdk::Empty* response) override; std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::stable::agones::dev::sdk::Empty>> AsyncShutdown(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) { return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::stable::agones::dev::sdk::Empty>>(AsyncShutdownRaw(context, request, cq)); @@ -224,6 +243,7 @@ class SDK final { public StubInterface::experimental_async_interface { public: void Ready(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty* request, ::stable::agones::dev::sdk::Empty* response, std::function) override; + void Allocate(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty* request, ::stable::agones::dev::sdk::Empty* response, std::function) override; void Shutdown(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty* request, ::stable::agones::dev::sdk::Empty* response, std::function) override; void GetGameServer(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty* request, ::stable::agones::dev::sdk::GameServer* response, std::function) override; void SetLabel(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::KeyValue* request, ::stable::agones::dev::sdk::Empty* response, std::function) override; @@ -241,6 +261,8 @@ class SDK final { class experimental_async async_stub_{this}; ::grpc::ClientAsyncResponseReader< ::stable::agones::dev::sdk::Empty>* AsyncReadyRaw(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) override; ::grpc::ClientAsyncResponseReader< ::stable::agones::dev::sdk::Empty>* PrepareAsyncReadyRaw(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) override; + ::grpc::ClientAsyncResponseReader< ::stable::agones::dev::sdk::Empty>* AsyncAllocateRaw(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) override; + ::grpc::ClientAsyncResponseReader< ::stable::agones::dev::sdk::Empty>* PrepareAsyncAllocateRaw(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) override; ::grpc::ClientAsyncResponseReader< ::stable::agones::dev::sdk::Empty>* AsyncShutdownRaw(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) override; ::grpc::ClientAsyncResponseReader< ::stable::agones::dev::sdk::Empty>* PrepareAsyncShutdownRaw(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) override; ::grpc::ClientWriter< ::stable::agones::dev::sdk::Empty>* HealthRaw(::grpc::ClientContext* context, ::stable::agones::dev::sdk::Empty* response) override; @@ -256,6 +278,7 @@ class SDK final { ::grpc::ClientAsyncResponseReader< ::stable::agones::dev::sdk::Empty>* AsyncSetAnnotationRaw(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::KeyValue& request, ::grpc::CompletionQueue* cq) override; ::grpc::ClientAsyncResponseReader< ::stable::agones::dev::sdk::Empty>* PrepareAsyncSetAnnotationRaw(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::KeyValue& request, ::grpc::CompletionQueue* cq) override; const ::grpc::internal::RpcMethod rpcmethod_Ready_; + const ::grpc::internal::RpcMethod rpcmethod_Allocate_; const ::grpc::internal::RpcMethod rpcmethod_Shutdown_; const ::grpc::internal::RpcMethod rpcmethod_Health_; const ::grpc::internal::RpcMethod rpcmethod_GetGameServer_; @@ -271,6 +294,8 @@ class SDK final { virtual ~Service(); // Call when the GameServer is ready virtual ::grpc::Status Ready(::grpc::ServerContext* context, const ::stable::agones::dev::sdk::Empty* request, ::stable::agones::dev::sdk::Empty* response); + // Call to self Allocation the GameServer + virtual ::grpc::Status Allocate(::grpc::ServerContext* context, const ::stable::agones::dev::sdk::Empty* request, ::stable::agones::dev::sdk::Empty* response); // Call when the GameServer is shutting down virtual ::grpc::Status Shutdown(::grpc::ServerContext* context, const ::stable::agones::dev::sdk::Empty* request, ::stable::agones::dev::sdk::Empty* response); // Send a Empty every d Duration to declare that this GameSever is healthy @@ -305,12 +330,32 @@ class SDK final { } }; template + class WithAsyncMethod_Allocate : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service *service) {} + public: + WithAsyncMethod_Allocate() { + ::grpc::Service::MarkMethodAsync(1); + } + ~WithAsyncMethod_Allocate() override { + BaseClassMustBeDerivedFromService(this); + } + // disable synchronous version of this method + ::grpc::Status Allocate(::grpc::ServerContext* context, const ::stable::agones::dev::sdk::Empty* request, ::stable::agones::dev::sdk::Empty* response) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + void RequestAllocate(::grpc::ServerContext* context, ::stable::agones::dev::sdk::Empty* request, ::grpc::ServerAsyncResponseWriter< ::stable::agones::dev::sdk::Empty>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { + ::grpc::Service::RequestAsyncUnary(1, context, request, response, new_call_cq, notification_cq, tag); + } + }; + template class WithAsyncMethod_Shutdown : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithAsyncMethod_Shutdown() { - ::grpc::Service::MarkMethodAsync(1); + ::grpc::Service::MarkMethodAsync(2); } ~WithAsyncMethod_Shutdown() override { BaseClassMustBeDerivedFromService(this); @@ -321,7 +366,7 @@ class SDK final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestShutdown(::grpc::ServerContext* context, ::stable::agones::dev::sdk::Empty* request, ::grpc::ServerAsyncResponseWriter< ::stable::agones::dev::sdk::Empty>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(1, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(2, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -330,7 +375,7 @@ class SDK final { void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithAsyncMethod_Health() { - ::grpc::Service::MarkMethodAsync(2); + ::grpc::Service::MarkMethodAsync(3); } ~WithAsyncMethod_Health() override { BaseClassMustBeDerivedFromService(this); @@ -341,7 +386,7 @@ class SDK final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestHealth(::grpc::ServerContext* context, ::grpc::ServerAsyncReader< ::stable::agones::dev::sdk::Empty, ::stable::agones::dev::sdk::Empty>* reader, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncClientStreaming(2, context, reader, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncClientStreaming(3, context, reader, new_call_cq, notification_cq, tag); } }; template @@ -350,7 +395,7 @@ class SDK final { void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithAsyncMethod_GetGameServer() { - ::grpc::Service::MarkMethodAsync(3); + ::grpc::Service::MarkMethodAsync(4); } ~WithAsyncMethod_GetGameServer() override { BaseClassMustBeDerivedFromService(this); @@ -361,7 +406,7 @@ class SDK final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestGetGameServer(::grpc::ServerContext* context, ::stable::agones::dev::sdk::Empty* request, ::grpc::ServerAsyncResponseWriter< ::stable::agones::dev::sdk::GameServer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(3, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(4, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -370,7 +415,7 @@ class SDK final { void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithAsyncMethod_WatchGameServer() { - ::grpc::Service::MarkMethodAsync(4); + ::grpc::Service::MarkMethodAsync(5); } ~WithAsyncMethod_WatchGameServer() override { BaseClassMustBeDerivedFromService(this); @@ -381,7 +426,7 @@ class SDK final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestWatchGameServer(::grpc::ServerContext* context, ::stable::agones::dev::sdk::Empty* request, ::grpc::ServerAsyncWriter< ::stable::agones::dev::sdk::GameServer>* writer, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncServerStreaming(4, context, request, writer, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncServerStreaming(5, context, request, writer, new_call_cq, notification_cq, tag); } }; template @@ -390,7 +435,7 @@ class SDK final { void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithAsyncMethod_SetLabel() { - ::grpc::Service::MarkMethodAsync(5); + ::grpc::Service::MarkMethodAsync(6); } ~WithAsyncMethod_SetLabel() override { BaseClassMustBeDerivedFromService(this); @@ -401,7 +446,7 @@ class SDK final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestSetLabel(::grpc::ServerContext* context, ::stable::agones::dev::sdk::KeyValue* request, ::grpc::ServerAsyncResponseWriter< ::stable::agones::dev::sdk::Empty>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(5, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(6, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -410,7 +455,7 @@ class SDK final { void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithAsyncMethod_SetAnnotation() { - ::grpc::Service::MarkMethodAsync(6); + ::grpc::Service::MarkMethodAsync(7); } ~WithAsyncMethod_SetAnnotation() override { BaseClassMustBeDerivedFromService(this); @@ -421,10 +466,10 @@ class SDK final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestSetAnnotation(::grpc::ServerContext* context, ::stable::agones::dev::sdk::KeyValue* request, ::grpc::ServerAsyncResponseWriter< ::stable::agones::dev::sdk::Empty>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(6, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(7, context, request, response, new_call_cq, notification_cq, tag); } }; - typedef WithAsyncMethod_Ready > > > > > > AsyncService; + typedef WithAsyncMethod_Ready > > > > > > > AsyncService; template class WithGenericMethod_Ready : public BaseClass { private: @@ -443,12 +488,29 @@ class SDK final { } }; template + class WithGenericMethod_Allocate : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service *service) {} + public: + WithGenericMethod_Allocate() { + ::grpc::Service::MarkMethodGeneric(1); + } + ~WithGenericMethod_Allocate() override { + BaseClassMustBeDerivedFromService(this); + } + // disable synchronous version of this method + ::grpc::Status Allocate(::grpc::ServerContext* context, const ::stable::agones::dev::sdk::Empty* request, ::stable::agones::dev::sdk::Empty* response) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + }; + template class WithGenericMethod_Shutdown : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithGenericMethod_Shutdown() { - ::grpc::Service::MarkMethodGeneric(1); + ::grpc::Service::MarkMethodGeneric(2); } ~WithGenericMethod_Shutdown() override { BaseClassMustBeDerivedFromService(this); @@ -465,7 +527,7 @@ class SDK final { void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithGenericMethod_Health() { - ::grpc::Service::MarkMethodGeneric(2); + ::grpc::Service::MarkMethodGeneric(3); } ~WithGenericMethod_Health() override { BaseClassMustBeDerivedFromService(this); @@ -482,7 +544,7 @@ class SDK final { void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithGenericMethod_GetGameServer() { - ::grpc::Service::MarkMethodGeneric(3); + ::grpc::Service::MarkMethodGeneric(4); } ~WithGenericMethod_GetGameServer() override { BaseClassMustBeDerivedFromService(this); @@ -499,7 +561,7 @@ class SDK final { void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithGenericMethod_WatchGameServer() { - ::grpc::Service::MarkMethodGeneric(4); + ::grpc::Service::MarkMethodGeneric(5); } ~WithGenericMethod_WatchGameServer() override { BaseClassMustBeDerivedFromService(this); @@ -516,7 +578,7 @@ class SDK final { void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithGenericMethod_SetLabel() { - ::grpc::Service::MarkMethodGeneric(5); + ::grpc::Service::MarkMethodGeneric(6); } ~WithGenericMethod_SetLabel() override { BaseClassMustBeDerivedFromService(this); @@ -533,7 +595,7 @@ class SDK final { void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithGenericMethod_SetAnnotation() { - ::grpc::Service::MarkMethodGeneric(6); + ::grpc::Service::MarkMethodGeneric(7); } ~WithGenericMethod_SetAnnotation() override { BaseClassMustBeDerivedFromService(this); @@ -565,12 +627,32 @@ class SDK final { } }; template + class WithRawMethod_Allocate : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service *service) {} + public: + WithRawMethod_Allocate() { + ::grpc::Service::MarkMethodRaw(1); + } + ~WithRawMethod_Allocate() override { + BaseClassMustBeDerivedFromService(this); + } + // disable synchronous version of this method + ::grpc::Status Allocate(::grpc::ServerContext* context, const ::stable::agones::dev::sdk::Empty* request, ::stable::agones::dev::sdk::Empty* response) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + void RequestAllocate(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { + ::grpc::Service::RequestAsyncUnary(1, context, request, response, new_call_cq, notification_cq, tag); + } + }; + template class WithRawMethod_Shutdown : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithRawMethod_Shutdown() { - ::grpc::Service::MarkMethodRaw(1); + ::grpc::Service::MarkMethodRaw(2); } ~WithRawMethod_Shutdown() override { BaseClassMustBeDerivedFromService(this); @@ -581,7 +663,7 @@ class SDK final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestShutdown(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(1, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(2, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -590,7 +672,7 @@ class SDK final { void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithRawMethod_Health() { - ::grpc::Service::MarkMethodRaw(2); + ::grpc::Service::MarkMethodRaw(3); } ~WithRawMethod_Health() override { BaseClassMustBeDerivedFromService(this); @@ -601,7 +683,7 @@ class SDK final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestHealth(::grpc::ServerContext* context, ::grpc::ServerAsyncReader< ::grpc::ByteBuffer, ::grpc::ByteBuffer>* reader, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncClientStreaming(2, context, reader, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncClientStreaming(3, context, reader, new_call_cq, notification_cq, tag); } }; template @@ -610,7 +692,7 @@ class SDK final { void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithRawMethod_GetGameServer() { - ::grpc::Service::MarkMethodRaw(3); + ::grpc::Service::MarkMethodRaw(4); } ~WithRawMethod_GetGameServer() override { BaseClassMustBeDerivedFromService(this); @@ -621,7 +703,7 @@ class SDK final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestGetGameServer(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(3, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(4, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -630,7 +712,7 @@ class SDK final { void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithRawMethod_WatchGameServer() { - ::grpc::Service::MarkMethodRaw(4); + ::grpc::Service::MarkMethodRaw(5); } ~WithRawMethod_WatchGameServer() override { BaseClassMustBeDerivedFromService(this); @@ -641,7 +723,7 @@ class SDK final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestWatchGameServer(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncWriter< ::grpc::ByteBuffer>* writer, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncServerStreaming(4, context, request, writer, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncServerStreaming(5, context, request, writer, new_call_cq, notification_cq, tag); } }; template @@ -650,7 +732,7 @@ class SDK final { void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithRawMethod_SetLabel() { - ::grpc::Service::MarkMethodRaw(5); + ::grpc::Service::MarkMethodRaw(6); } ~WithRawMethod_SetLabel() override { BaseClassMustBeDerivedFromService(this); @@ -661,7 +743,7 @@ class SDK final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestSetLabel(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(5, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(6, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -670,7 +752,7 @@ class SDK final { void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithRawMethod_SetAnnotation() { - ::grpc::Service::MarkMethodRaw(6); + ::grpc::Service::MarkMethodRaw(7); } ~WithRawMethod_SetAnnotation() override { BaseClassMustBeDerivedFromService(this); @@ -681,7 +763,7 @@ class SDK final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestSetAnnotation(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(6, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(7, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -705,12 +787,32 @@ class SDK final { virtual ::grpc::Status StreamedReady(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< ::stable::agones::dev::sdk::Empty,::stable::agones::dev::sdk::Empty>* server_unary_streamer) = 0; }; template + class WithStreamedUnaryMethod_Allocate : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service *service) {} + public: + WithStreamedUnaryMethod_Allocate() { + ::grpc::Service::MarkMethodStreamed(1, + new ::grpc::internal::StreamedUnaryHandler< ::stable::agones::dev::sdk::Empty, ::stable::agones::dev::sdk::Empty>(std::bind(&WithStreamedUnaryMethod_Allocate::StreamedAllocate, this, std::placeholders::_1, std::placeholders::_2))); + } + ~WithStreamedUnaryMethod_Allocate() override { + BaseClassMustBeDerivedFromService(this); + } + // disable regular version of this method + ::grpc::Status Allocate(::grpc::ServerContext* context, const ::stable::agones::dev::sdk::Empty* request, ::stable::agones::dev::sdk::Empty* response) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + // replace default version of method with streamed unary + virtual ::grpc::Status StreamedAllocate(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< ::stable::agones::dev::sdk::Empty,::stable::agones::dev::sdk::Empty>* server_unary_streamer) = 0; + }; + template class WithStreamedUnaryMethod_Shutdown : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithStreamedUnaryMethod_Shutdown() { - ::grpc::Service::MarkMethodStreamed(1, + ::grpc::Service::MarkMethodStreamed(2, new ::grpc::internal::StreamedUnaryHandler< ::stable::agones::dev::sdk::Empty, ::stable::agones::dev::sdk::Empty>(std::bind(&WithStreamedUnaryMethod_Shutdown::StreamedShutdown, this, std::placeholders::_1, std::placeholders::_2))); } ~WithStreamedUnaryMethod_Shutdown() override { @@ -730,7 +832,7 @@ class SDK final { void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithStreamedUnaryMethod_GetGameServer() { - ::grpc::Service::MarkMethodStreamed(3, + ::grpc::Service::MarkMethodStreamed(4, new ::grpc::internal::StreamedUnaryHandler< ::stable::agones::dev::sdk::Empty, ::stable::agones::dev::sdk::GameServer>(std::bind(&WithStreamedUnaryMethod_GetGameServer::StreamedGetGameServer, this, std::placeholders::_1, std::placeholders::_2))); } ~WithStreamedUnaryMethod_GetGameServer() override { @@ -750,7 +852,7 @@ class SDK final { void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithStreamedUnaryMethod_SetLabel() { - ::grpc::Service::MarkMethodStreamed(5, + ::grpc::Service::MarkMethodStreamed(6, new ::grpc::internal::StreamedUnaryHandler< ::stable::agones::dev::sdk::KeyValue, ::stable::agones::dev::sdk::Empty>(std::bind(&WithStreamedUnaryMethod_SetLabel::StreamedSetLabel, this, std::placeholders::_1, std::placeholders::_2))); } ~WithStreamedUnaryMethod_SetLabel() override { @@ -770,7 +872,7 @@ class SDK final { void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithStreamedUnaryMethod_SetAnnotation() { - ::grpc::Service::MarkMethodStreamed(6, + ::grpc::Service::MarkMethodStreamed(7, new ::grpc::internal::StreamedUnaryHandler< ::stable::agones::dev::sdk::KeyValue, ::stable::agones::dev::sdk::Empty>(std::bind(&WithStreamedUnaryMethod_SetAnnotation::StreamedSetAnnotation, this, std::placeholders::_1, std::placeholders::_2))); } ~WithStreamedUnaryMethod_SetAnnotation() override { @@ -784,14 +886,14 @@ class SDK final { // replace default version of method with streamed unary virtual ::grpc::Status StreamedSetAnnotation(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< ::stable::agones::dev::sdk::KeyValue,::stable::agones::dev::sdk::Empty>* server_unary_streamer) = 0; }; - typedef WithStreamedUnaryMethod_Ready > > > > StreamedUnaryService; + typedef WithStreamedUnaryMethod_Ready > > > > > StreamedUnaryService; template class WithSplitStreamingMethod_WatchGameServer : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service *service) {} public: WithSplitStreamingMethod_WatchGameServer() { - ::grpc::Service::MarkMethodStreamed(4, + ::grpc::Service::MarkMethodStreamed(5, new ::grpc::internal::SplitServerStreamingHandler< ::stable::agones::dev::sdk::Empty, ::stable::agones::dev::sdk::GameServer>(std::bind(&WithSplitStreamingMethod_WatchGameServer::StreamedWatchGameServer, this, std::placeholders::_1, std::placeholders::_2))); } ~WithSplitStreamingMethod_WatchGameServer() override { @@ -806,7 +908,7 @@ class SDK final { virtual ::grpc::Status StreamedWatchGameServer(::grpc::ServerContext* context, ::grpc::ServerSplitStreamer< ::stable::agones::dev::sdk::Empty,::stable::agones::dev::sdk::GameServer>* server_split_streamer) = 0; }; typedef WithSplitStreamingMethod_WatchGameServer SplitStreamedService; - typedef WithStreamedUnaryMethod_Ready > > > > > StreamedService; + typedef WithStreamedUnaryMethod_Ready > > > > > > StreamedService; }; } // namespace sdk diff --git a/sdks/cpp/include/agones/sdk.pb.h b/sdks/cpp/include/agones/sdk.pb.h index 993ddc12e2..14c3fc2043 100644 --- a/sdks/cpp/include/agones/sdk.pb.h +++ b/sdks/cpp/include/agones/sdk.pb.h @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC All Rights Reserved. +// Copyright 2019 Google LLC All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/sdks/cpp/include/google/api/annotations.pb.h b/sdks/cpp/include/google/api/annotations.pb.h index 86a29c868a..136e53f920 100644 --- a/sdks/cpp/include/google/api/annotations.pb.h +++ b/sdks/cpp/include/google/api/annotations.pb.h @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC All Rights Reserved. +// Copyright 2019 Google LLC All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/sdks/cpp/include/google/api/http.pb.h b/sdks/cpp/include/google/api/http.pb.h index 957a3b8247..3cb8cea531 100644 --- a/sdks/cpp/include/google/api/http.pb.h +++ b/sdks/cpp/include/google/api/http.pb.h @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC All Rights Reserved. +// Copyright 2019 Google LLC All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/sdks/cpp/src/agones/sdk.grpc.pb.cc b/sdks/cpp/src/agones/sdk.grpc.pb.cc index 9ee79a4b54..234b0aef17 100644 --- a/sdks/cpp/src/agones/sdk.grpc.pb.cc +++ b/sdks/cpp/src/agones/sdk.grpc.pb.cc @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC All Rights Reserved. +// Copyright 2019 Google LLC All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ namespace sdk { static const char* SDK_method_names[] = { "/stable.agones.dev.sdk.SDK/Ready", + "/stable.agones.dev.sdk.SDK/Allocate", "/stable.agones.dev.sdk.SDK/Shutdown", "/stable.agones.dev.sdk.SDK/Health", "/stable.agones.dev.sdk.SDK/GetGameServer", @@ -53,12 +54,13 @@ std::unique_ptr< SDK::Stub> SDK::NewStub(const std::shared_ptr< ::grpc::ChannelI SDK::Stub::Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel) : channel_(channel), rpcmethod_Ready_(SDK_method_names[0], ::grpc::internal::RpcMethod::NORMAL_RPC, channel) - , rpcmethod_Shutdown_(SDK_method_names[1], ::grpc::internal::RpcMethod::NORMAL_RPC, channel) - , rpcmethod_Health_(SDK_method_names[2], ::grpc::internal::RpcMethod::CLIENT_STREAMING, channel) - , rpcmethod_GetGameServer_(SDK_method_names[3], ::grpc::internal::RpcMethod::NORMAL_RPC, channel) - , rpcmethod_WatchGameServer_(SDK_method_names[4], ::grpc::internal::RpcMethod::SERVER_STREAMING, channel) - , rpcmethod_SetLabel_(SDK_method_names[5], ::grpc::internal::RpcMethod::NORMAL_RPC, channel) - , rpcmethod_SetAnnotation_(SDK_method_names[6], ::grpc::internal::RpcMethod::NORMAL_RPC, channel) + , rpcmethod_Allocate_(SDK_method_names[1], ::grpc::internal::RpcMethod::NORMAL_RPC, channel) + , rpcmethod_Shutdown_(SDK_method_names[2], ::grpc::internal::RpcMethod::NORMAL_RPC, channel) + , rpcmethod_Health_(SDK_method_names[3], ::grpc::internal::RpcMethod::CLIENT_STREAMING, channel) + , rpcmethod_GetGameServer_(SDK_method_names[4], ::grpc::internal::RpcMethod::NORMAL_RPC, channel) + , rpcmethod_WatchGameServer_(SDK_method_names[5], ::grpc::internal::RpcMethod::SERVER_STREAMING, channel) + , rpcmethod_SetLabel_(SDK_method_names[6], ::grpc::internal::RpcMethod::NORMAL_RPC, channel) + , rpcmethod_SetAnnotation_(SDK_method_names[7], ::grpc::internal::RpcMethod::NORMAL_RPC, channel) {} ::grpc::Status SDK::Stub::Ready(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::stable::agones::dev::sdk::Empty* response) { @@ -77,6 +79,22 @@ ::grpc::ClientAsyncResponseReader< ::stable::agones::dev::sdk::Empty>* SDK::Stub return ::grpc::internal::ClientAsyncResponseReaderFactory< ::stable::agones::dev::sdk::Empty>::Create(channel_.get(), cq, rpcmethod_Ready_, context, request, false); } +::grpc::Status SDK::Stub::Allocate(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::stable::agones::dev::sdk::Empty* response) { + return ::grpc::internal::BlockingUnaryCall(channel_.get(), rpcmethod_Allocate_, context, request, response); +} + +void SDK::Stub::experimental_async::Allocate(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty* request, ::stable::agones::dev::sdk::Empty* response, std::function f) { + return ::grpc::internal::CallbackUnaryCall(stub_->channel_.get(), stub_->rpcmethod_Allocate_, context, request, response, std::move(f)); +} + +::grpc::ClientAsyncResponseReader< ::stable::agones::dev::sdk::Empty>* SDK::Stub::AsyncAllocateRaw(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) { + return ::grpc::internal::ClientAsyncResponseReaderFactory< ::stable::agones::dev::sdk::Empty>::Create(channel_.get(), cq, rpcmethod_Allocate_, context, request, true); +} + +::grpc::ClientAsyncResponseReader< ::stable::agones::dev::sdk::Empty>* SDK::Stub::PrepareAsyncAllocateRaw(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::grpc::CompletionQueue* cq) { + return ::grpc::internal::ClientAsyncResponseReaderFactory< ::stable::agones::dev::sdk::Empty>::Create(channel_.get(), cq, rpcmethod_Allocate_, context, request, false); +} + ::grpc::Status SDK::Stub::Shutdown(::grpc::ClientContext* context, const ::stable::agones::dev::sdk::Empty& request, ::stable::agones::dev::sdk::Empty* response) { return ::grpc::internal::BlockingUnaryCall(channel_.get(), rpcmethod_Shutdown_, context, request, response); } @@ -175,29 +193,34 @@ SDK::Service::Service() { SDK_method_names[1], ::grpc::internal::RpcMethod::NORMAL_RPC, new ::grpc::internal::RpcMethodHandler< SDK::Service, ::stable::agones::dev::sdk::Empty, ::stable::agones::dev::sdk::Empty>( - std::mem_fn(&SDK::Service::Shutdown), this))); + std::mem_fn(&SDK::Service::Allocate), this))); AddMethod(new ::grpc::internal::RpcServiceMethod( SDK_method_names[2], + ::grpc::internal::RpcMethod::NORMAL_RPC, + new ::grpc::internal::RpcMethodHandler< SDK::Service, ::stable::agones::dev::sdk::Empty, ::stable::agones::dev::sdk::Empty>( + std::mem_fn(&SDK::Service::Shutdown), this))); + AddMethod(new ::grpc::internal::RpcServiceMethod( + SDK_method_names[3], ::grpc::internal::RpcMethod::CLIENT_STREAMING, new ::grpc::internal::ClientStreamingHandler< SDK::Service, ::stable::agones::dev::sdk::Empty, ::stable::agones::dev::sdk::Empty>( std::mem_fn(&SDK::Service::Health), this))); AddMethod(new ::grpc::internal::RpcServiceMethod( - SDK_method_names[3], + SDK_method_names[4], ::grpc::internal::RpcMethod::NORMAL_RPC, new ::grpc::internal::RpcMethodHandler< SDK::Service, ::stable::agones::dev::sdk::Empty, ::stable::agones::dev::sdk::GameServer>( std::mem_fn(&SDK::Service::GetGameServer), this))); AddMethod(new ::grpc::internal::RpcServiceMethod( - SDK_method_names[4], + SDK_method_names[5], ::grpc::internal::RpcMethod::SERVER_STREAMING, new ::grpc::internal::ServerStreamingHandler< SDK::Service, ::stable::agones::dev::sdk::Empty, ::stable::agones::dev::sdk::GameServer>( std::mem_fn(&SDK::Service::WatchGameServer), this))); AddMethod(new ::grpc::internal::RpcServiceMethod( - SDK_method_names[5], + SDK_method_names[6], ::grpc::internal::RpcMethod::NORMAL_RPC, new ::grpc::internal::RpcMethodHandler< SDK::Service, ::stable::agones::dev::sdk::KeyValue, ::stable::agones::dev::sdk::Empty>( std::mem_fn(&SDK::Service::SetLabel), this))); AddMethod(new ::grpc::internal::RpcServiceMethod( - SDK_method_names[6], + SDK_method_names[7], ::grpc::internal::RpcMethod::NORMAL_RPC, new ::grpc::internal::RpcMethodHandler< SDK::Service, ::stable::agones::dev::sdk::KeyValue, ::stable::agones::dev::sdk::Empty>( std::mem_fn(&SDK::Service::SetAnnotation), this))); @@ -213,6 +236,13 @@ ::grpc::Status SDK::Service::Ready(::grpc::ServerContext* context, const ::stabl return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } +::grpc::Status SDK::Service::Allocate(::grpc::ServerContext* context, const ::stable::agones::dev::sdk::Empty* request, ::stable::agones::dev::sdk::Empty* response) { + (void) context; + (void) request; + (void) response; + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); +} + ::grpc::Status SDK::Service::Shutdown(::grpc::ServerContext* context, const ::stable::agones::dev::sdk::Empty* request, ::stable::agones::dev::sdk::Empty* response) { (void) context; (void) request; diff --git a/sdks/cpp/src/agones/sdk.pb.cc b/sdks/cpp/src/agones/sdk.pb.cc index e91ad5f96f..97a0754c98 100644 --- a/sdks/cpp/src/agones/sdk.pb.cc +++ b/sdks/cpp/src/agones/sdk.pb.cc @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC All Rights Reserved. +// Copyright 2019 Google LLC All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -419,28 +419,30 @@ void AddDescriptorsImpl() { "state\030\001 \001(\t\022\017\n\007address\030\002 \001(\t\022<\n\005ports\030\003 " "\003(\0132-.stable.agones.dev.sdk.GameServer.S" "tatus.Port\032\"\n\004Port\022\014\n\004name\030\001 \001(\t\022\014\n\004port" - "\030\002 \001(\0052\307\005\n\003SDK\022V\n\005Ready\022\034.stable.agones." + "\030\002 \001(\0052\245\006\n\003SDK\022V\n\005Ready\022\034.stable.agones." "dev.sdk.Empty\032\034.stable.agones.dev.sdk.Em" - "pty\"\021\202\323\344\223\002\013\"\006/ready:\001*\022\\\n\010Shutdown\022\034.sta" + "pty\"\021\202\323\344\223\002\013\"\006/ready:\001*\022\\\n\010Allocate\022\034.sta" "ble.agones.dev.sdk.Empty\032\034.stable.agones" - ".dev.sdk.Empty\"\024\202\323\344\223\002\016\"\t/shutdown:\001*\022Z\n\006" - "Health\022\034.stable.agones.dev.sdk.Empty\032\034.s" - "table.agones.dev.sdk.Empty\"\022\202\323\344\223\002\014\"\007/hea" - "lth:\001*(\001\022e\n\rGetGameServer\022\034.stable.agone" - "s.dev.sdk.Empty\032!.stable.agones.dev.sdk." - "GameServer\"\023\202\323\344\223\002\r\022\013/gameserver\022o\n\017Watch" - "GameServer\022\034.stable.agones.dev.sdk.Empty" - "\032!.stable.agones.dev.sdk.GameServer\"\031\202\323\344" - "\223\002\023\022\021/watch/gameserver0\001\022e\n\010SetLabel\022\037.s" - "table.agones.dev.sdk.KeyValue\032\034.stable.a" - "gones.dev.sdk.Empty\"\032\202\323\344\223\002\024\032\017/metadata/l" - "abel:\001*\022o\n\rSetAnnotation\022\037.stable.agones" - ".dev.sdk.KeyValue\032\034.stable.agones.dev.sd" - "k.Empty\"\037\202\323\344\223\002\031\032\024/metadata/annotation:\001*" - "B\005Z\003sdkb\006proto3" + ".dev.sdk.Empty\"\024\202\323\344\223\002\016\"\t/allocate:\001*\022\\\n\010" + "Shutdown\022\034.stable.agones.dev.sdk.Empty\032\034" + ".stable.agones.dev.sdk.Empty\"\024\202\323\344\223\002\016\"\t/s" + "hutdown:\001*\022Z\n\006Health\022\034.stable.agones.dev" + ".sdk.Empty\032\034.stable.agones.dev.sdk.Empty" + "\"\022\202\323\344\223\002\014\"\007/health:\001*(\001\022e\n\rGetGameServer\022" + "\034.stable.agones.dev.sdk.Empty\032!.stable.a" + "gones.dev.sdk.GameServer\"\023\202\323\344\223\002\r\022\013/games" + "erver\022o\n\017WatchGameServer\022\034.stable.agones" + ".dev.sdk.Empty\032!.stable.agones.dev.sdk.G" + "ameServer\"\031\202\323\344\223\002\023\022\021/watch/gameserver0\001\022e" + "\n\010SetLabel\022\037.stable.agones.dev.sdk.KeyVa" + "lue\032\034.stable.agones.dev.sdk.Empty\"\032\202\323\344\223\002" + "\024\032\017/metadata/label:\001*\022o\n\rSetAnnotation\022\037" + ".stable.agones.dev.sdk.KeyValue\032\034.stable" + ".agones.dev.sdk.Empty\"\037\202\323\344\223\002\031\032\024/metadata" + "/annotation:\001*B\005Z\003sdkb\006proto3" }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - descriptor, 1775); + descriptor, 1869); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "sdk.proto", &protobuf_RegisterTypes); ::protobuf_google_2fapi_2fannotations_2eproto::AddDescriptors(); diff --git a/sdks/cpp/src/google/annotations.pb.cc b/sdks/cpp/src/google/annotations.pb.cc index 6dda02f432..6b876c585f 100644 --- a/sdks/cpp/src/google/annotations.pb.cc +++ b/sdks/cpp/src/google/annotations.pb.cc @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC All Rights Reserved. +// Copyright 2019 Google LLC All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/sdks/cpp/src/google/http.pb.cc b/sdks/cpp/src/google/http.pb.cc index 5c7c27011a..269184e644 100644 --- a/sdks/cpp/src/google/http.pb.cc +++ b/sdks/cpp/src/google/http.pb.cc @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC All Rights Reserved. +// Copyright 2019 Google LLC All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/sdks/go/sdk.go b/sdks/go/sdk.go index 9b01bb8cd0..abadc5269b 100644 --- a/sdks/go/sdk.go +++ b/sdks/go/sdk.go @@ -66,6 +66,12 @@ func (s *SDK) Ready() error { return errors.Wrap(err, "could not send Ready message") } +// Allocate self marks this gameserver as Allocated. +func (s *SDK) Allocate() error { + _, err := s.client.Allocate(s.ctx, &sdk.Empty{}) + return errors.Wrap(err, "could not mark self as Allocated") +} + // Shutdown marks the Game Server as ready to // shutdown func (s *SDK) Shutdown() error { diff --git a/sdks/go/sdk_test.go b/sdks/go/sdk_test.go index 1aa272dcd9..977aab2f6d 100644 --- a/sdks/go/sdk_test.go +++ b/sdks/go/sdk_test.go @@ -49,6 +49,10 @@ func TestSDK(t *testing.T) { assert.Nil(t, err) assert.True(t, sm.hm.healthy) + err = s.Allocate() + assert.NoError(t, err) + assert.True(t, sm.allocated) + err = s.Shutdown() assert.Nil(t, err) assert.True(t, sm.ready) @@ -126,6 +130,7 @@ var _ sdk.SDK_WatchGameServerClient = &watchMock{} type sdkMock struct { ready bool shutdown bool + allocated bool hm *healthMock wm *watchMock labels map[string]string @@ -155,6 +160,11 @@ func (m *sdkMock) Ready(ctx context.Context, e *sdk.Empty, opts ...grpc.CallOpti return e, nil } +func (m *sdkMock) Allocate(ctx context.Context, e *sdk.Empty, opts ...grpc.CallOption) (*sdk.Empty, error) { + m.allocated = true + return e, nil +} + func (m *sdkMock) Shutdown(ctx context.Context, e *sdk.Empty, opts ...grpc.CallOption) (*sdk.Empty, error) { m.shutdown = true return e, nil diff --git a/sdks/nodejs/lib/google/api/annotations_pb.js b/sdks/nodejs/lib/google/api/annotations_pb.js index a7bb8fb3a6..38da1442c0 100644 --- a/sdks/nodejs/lib/google/api/annotations_pb.js +++ b/sdks/nodejs/lib/google/api/annotations_pb.js @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC All Rights Reserved. +// Copyright 2019 Google LLC All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/sdks/nodejs/lib/google/api/http_pb.js b/sdks/nodejs/lib/google/api/http_pb.js index 6a3c74a3ab..3b024fd685 100644 --- a/sdks/nodejs/lib/google/api/http_pb.js +++ b/sdks/nodejs/lib/google/api/http_pb.js @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC All Rights Reserved. +// Copyright 2019 Google LLC All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/sdks/nodejs/lib/sdk_grpc_pb.js b/sdks/nodejs/lib/sdk_grpc_pb.js index 3ac7cf1a99..f9ba863bc4 100644 --- a/sdks/nodejs/lib/sdk_grpc_pb.js +++ b/sdks/nodejs/lib/sdk_grpc_pb.js @@ -68,6 +68,18 @@ var SDKService = exports.SDKService = { responseSerialize: serialize_stable_agones_dev_sdk_Empty, responseDeserialize: deserialize_stable_agones_dev_sdk_Empty, }, + // Call to self Allocation the GameServer + allocate: { + path: '/stable.agones.dev.sdk.SDK/Allocate', + requestStream: false, + responseStream: false, + requestType: sdk_pb.Empty, + responseType: sdk_pb.Empty, + requestSerialize: serialize_stable_agones_dev_sdk_Empty, + requestDeserialize: deserialize_stable_agones_dev_sdk_Empty, + responseSerialize: serialize_stable_agones_dev_sdk_Empty, + responseDeserialize: deserialize_stable_agones_dev_sdk_Empty, + }, // Call when the GameServer is shutting down shutdown: { path: '/stable.agones.dev.sdk.SDK/Shutdown', diff --git a/sdks/nodejs/lib/sdk_pb.js b/sdks/nodejs/lib/sdk_pb.js index 27b328c72d..ec088f7491 100644 --- a/sdks/nodejs/lib/sdk_pb.js +++ b/sdks/nodejs/lib/sdk_pb.js @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC All Rights Reserved. +// Copyright 2019 Google LLC All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/sdks/rust/src/grpc/sdk.rs b/sdks/rust/src/grpc/sdk.rs index c9ed979cdd..80f2beb2ae 100644 --- a/sdks/rust/src/grpc/sdk.rs +++ b/sdks/rust/src/grpc/sdk.rs @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC All Rights Reserved. +// Copyright 2019 Google LLC All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -2043,10 +2043,12 @@ static file_descriptor_proto_data: &'static [u8] = b"\ \x02\x20\x01(\tR\x07address\x12C\n\x05ports\x18\x03\x20\x03(\x0b2-.stabl\ e.agones.dev.sdk.GameServer.Status.PortR\x05ports\x1a.\n\x04Port\x12\x12\ \n\x04name\x18\x01\x20\x01(\tR\x04name\x12\x12\n\x04port\x18\x02\x20\x01\ - (\x05R\x04port2\xc7\x05\n\x03SDK\x12V\n\x05Ready\x12\x1c.stable.agones.d\ + (\x05R\x04port2\xa5\x06\n\x03SDK\x12V\n\x05Ready\x12\x1c.stable.agones.d\ ev.sdk.Empty\x1a\x1c.stable.agones.dev.sdk.Empty\"\x11\x82\xd3\xe4\x93\ - \x02\x0b\"\x06/ready:\x01*\x12\\\n\x08Shutdown\x12\x1c.stable.agones.dev\ + \x02\x0b\"\x06/ready:\x01*\x12\\\n\x08Allocate\x12\x1c.stable.agones.dev\ .sdk.Empty\x1a\x1c.stable.agones.dev.sdk.Empty\"\x14\x82\xd3\xe4\x93\x02\ + \x0e\"\t/allocate:\x01*\x12\\\n\x08Shutdown\x12\x1c.stable.agones.dev.sd\ + k.Empty\x1a\x1c.stable.agones.dev.sdk.Empty\"\x14\x82\xd3\xe4\x93\x02\ \x0e\"\t/shutdown:\x01*\x12Z\n\x06Health\x12\x1c.stable.agones.dev.sdk.E\ mpty\x1a\x1c.stable.agones.dev.sdk.Empty\"\x12\x82\xd3\xe4\x93\x02\x0c\"\ \x07/health:\x01*(\x01\x12e\n\rGetGameServer\x12\x1c.stable.agones.dev.s\ @@ -2058,7 +2060,7 @@ static file_descriptor_proto_data: &'static [u8] = b"\ \xd3\xe4\x93\x02\x14\x1a\x0f/metadata/label:\x01*\x12o\n\rSetAnnotation\ \x12\x1f.stable.agones.dev.sdk.KeyValue\x1a\x1c.stable.agones.dev.sdk.Em\ pty\"\x1f\x82\xd3\xe4\x93\x02\x19\x1a\x14/metadata/annotation:\x01*B\x05\ - Z\x03sdkJ\xa3!\n\x07\x12\x05\x0e\0\x80\x01\x01\n\xd1\x04\n\x01\x0c\x12\ + Z\x03sdkJ\xc8\"\n\x07\x12\x05\x0e\0\x89\x01\x01\n\xd1\x04\n\x01\x0c\x12\ \x03\x0e\0\x122\xc6\x04\x20Copyright\x202017\x20Google\x20LLC\x20All\x20\ Rights\x20Reserved.\n\n\x20Licensed\x20under\x20the\x20Apache\x20License\ ,\x20Version\x202.0\x20(the\x20\"License\");\n\x20you\x20may\x20not\x20u\ @@ -2073,155 +2075,163 @@ static file_descriptor_proto_data: &'static [u8] = b"\ ecific\x20language\x20governing\x20permissions\x20and\n\x20limitations\ \x20under\x20the\x20License.\n\n\x08\n\x01\x02\x12\x03\x10\x08\x1d\n\x08\ \n\x01\x08\x12\x03\x11\0\x1a\n\t\n\x02\x08\x0b\x12\x03\x11\0\x1a\n\t\n\ - \x02\x03\0\x12\x03\x13\x07%\nM\n\x02\x06\0\x12\x04\x16\0H\x01\x1aA\x20SD\ + \x02\x03\0\x12\x03\x13\x07%\nM\n\x02\x06\0\x12\x04\x16\0Q\x01\x1aA\x20SD\ K\x20service\x20to\x20be\x20used\x20in\x20the\x20GameServer\x20SDK\x20to\ \x20the\x20Pod\x20Sidecar\n\n\n\n\x03\x06\0\x01\x12\x03\x16\x08\x0b\n1\n\ \x04\x06\0\x02\0\x12\x04\x18\x04\x1d\x05\x1a#\x20Call\x20when\x20the\x20\ GameServer\x20is\x20ready\n\n\x0c\n\x05\x06\0\x02\0\x01\x12\x03\x18\x08\ \r\n\x0c\n\x05\x06\0\x02\0\x02\x12\x03\x18\x0f\x14\n\x0c\n\x05\x06\0\x02\ \0\x03\x12\x03\x18\x1f$\n\r\n\x05\x06\0\x02\0\x04\x12\x04\x19\x08\x1c\n\ - \n\x11\n\t\x06\0\x02\0\x04\xb0\xca\xbc\"\x12\x04\x19\x08\x1c\n\n9\n\x04\ - \x06\0\x02\x01\x12\x04\x1f\x04$\x05\x1a+\x20Call\x20when\x20the\x20GameS\ - erver\x20is\x20shutting\x20down\n\n\x0c\n\x05\x06\0\x02\x01\x01\x12\x03\ - \x1f\x08\x10\n\x0c\n\x05\x06\0\x02\x01\x02\x12\x03\x1f\x12\x17\n\x0c\n\ - \x05\x06\0\x02\x01\x03\x12\x03\x1f\"'\n\r\n\x05\x06\0\x02\x01\x04\x12\ - \x04\x20\x08#\n\n\x11\n\t\x06\0\x02\x01\x04\xb0\xca\xbc\"\x12\x04\x20\ - \x08#\n\nW\n\x04\x06\0\x02\x02\x12\x04&\x04+\x05\x1aI\x20Send\x20a\x20Em\ - pty\x20every\x20d\x20Duration\x20to\x20declare\x20that\x20this\x20GameSe\ - ver\x20is\x20healthy\n\n\x0c\n\x05\x06\0\x02\x02\x01\x12\x03&\x08\x0e\n\ - \x0c\n\x05\x06\0\x02\x02\x05\x12\x03&\x10\x16\n\x0c\n\x05\x06\0\x02\x02\ - \x02\x12\x03&\x17\x1c\n\x0c\n\x05\x06\0\x02\x02\x03\x12\x03&',\n\r\n\x05\ - \x06\0\x02\x02\x04\x12\x04'\x08*\x12\n\x11\n\t\x06\0\x02\x02\x04\xb0\xca\ - \xbc\"\x12\x04'\x08*\x12\n4\n\x04\x06\0\x02\x03\x12\x04-\x041\x05\x1a&\ - \x20Retrieve\x20the\x20current\x20GameServer\x20data\n\n\x0c\n\x05\x06\0\ - \x02\x03\x01\x12\x03-\x08\x15\n\x0c\n\x05\x06\0\x02\x03\x02\x12\x03-\x17\ - \x1c\n\x0c\n\x05\x06\0\x02\x03\x03\x12\x03-'1\n\r\n\x05\x06\0\x02\x03\ - \x04\x12\x04.\x080\n\n\x11\n\t\x06\0\x02\x03\x04\xb0\xca\xbc\"\x12\x04.\ - \x080\n\nJ\n\x04\x06\0\x02\x04\x12\x043\x047\x05\x1a<\x20Send\x20GameSer\ - ver\x20details\x20whenever\x20the\x20GameServer\x20is\x20updated\n\n\x0c\ - \n\x05\x06\0\x02\x04\x01\x12\x033\x08\x17\n\x0c\n\x05\x06\0\x02\x04\x02\ - \x12\x033\x19\x1e\n\x0c\n\x05\x06\0\x02\x04\x06\x12\x033)/\n\x0c\n\x05\ - \x06\0\x02\x04\x03\x12\x0330:\n\r\n\x05\x06\0\x02\x04\x04\x12\x044\x086\ - \n\n\x11\n\t\x06\0\x02\x04\x04\xb0\xca\xbc\"\x12\x044\x086\n\n@\n\x04\ - \x06\0\x02\x05\x12\x04:\x04?\x05\x1a2\x20Apply\x20a\x20Label\x20to\x20th\ - e\x20backing\x20GameServer\x20metadata\n\n\x0c\n\x05\x06\0\x02\x05\x01\ - \x12\x03:\x08\x10\n\x0c\n\x05\x06\0\x02\x05\x02\x12\x03:\x11\x19\n\x0c\n\ - \x05\x06\0\x02\x05\x03\x12\x03:$)\n\r\n\x05\x06\0\x02\x05\x04\x12\x04;\ - \x08>\x12\n\x11\n\t\x06\0\x02\x05\x04\xb0\xca\xbc\"\x12\x04;\x08>\x12\nE\ - \n\x04\x06\0\x02\x06\x12\x04B\x04G\x05\x1a7\x20Apply\x20a\x20Annotation\ - \x20to\x20the\x20backing\x20GameServer\x20metadata\n\n\x0c\n\x05\x06\0\ - \x02\x06\x01\x12\x03B\x08\x15\n\x0c\n\x05\x06\0\x02\x06\x02\x12\x03B\x16\ - \x1e\n\x0c\n\x05\x06\0\x02\x06\x03\x12\x03B).\n\r\n\x05\x06\0\x02\x06\ - \x04\x12\x04C\x08F\x12\n\x11\n\t\x06\0\x02\x06\x04\xb0\xca\xbc\"\x12\x04\ - C\x08F\x12\n\x18\n\x02\x04\0\x12\x04K\0L\x01\x1a\x0c\x20I\x20am\x20Empty\ - \n\n\n\n\x03\x04\0\x01\x12\x03K\x08\r\n\x1e\n\x02\x04\x01\x12\x04O\0R\ - \x01\x1a\x12\x20Key,\x20Value\x20entry\n\n\n\n\x03\x04\x01\x01\x12\x03O\ - \x08\x10\n\x0b\n\x04\x04\x01\x02\0\x12\x03P\x04\x13\n\r\n\x05\x04\x01\ - \x02\0\x04\x12\x04P\x04O\x12\n\x0c\n\x05\x04\x01\x02\0\x05\x12\x03P\x04\ - \n\n\x0c\n\x05\x04\x01\x02\0\x01\x12\x03P\x0b\x0e\n\x0c\n\x05\x04\x01\ - \x02\0\x03\x12\x03P\x11\x12\n\x0b\n\x04\x04\x01\x02\x01\x12\x03Q\x04\x15\ - \n\r\n\x05\x04\x01\x02\x01\x04\x12\x04Q\x04P\x13\n\x0c\n\x05\x04\x01\x02\ - \x01\x05\x12\x03Q\x04\n\n\x0c\n\x05\x04\x01\x02\x01\x01\x12\x03Q\x0b\x10\ - \n\x0c\n\x05\x04\x01\x02\x01\x03\x12\x03Q\x13\x14\n\xa3\x01\n\x02\x04\ - \x02\x12\x05W\0\x80\x01\x01\x1a\x95\x01\x20A\x20GameServer\x20Custom\x20\ - Resource\x20Definition\x20object\n\x20We\x20will\x20only\x20export\x20th\ - ose\x20resources\x20that\x20make\x20the\x20most\n\x20sense.\x20Can\x20al\ - ways\x20expand\x20to\x20more\x20as\x20needed.\n\n\n\n\x03\x04\x02\x01\ - \x12\x03W\x08\x12\n\x0b\n\x04\x04\x02\x02\0\x12\x03X\x04\x1f\n\r\n\x05\ - \x04\x02\x02\0\x04\x12\x04X\x04W\x14\n\x0c\n\x05\x04\x02\x02\0\x06\x12\ - \x03X\x04\x0e\n\x0c\n\x05\x04\x02\x02\0\x01\x12\x03X\x0f\x1a\n\x0c\n\x05\ - \x04\x02\x02\0\x03\x12\x03X\x1d\x1e\n\x0b\n\x04\x04\x02\x02\x01\x12\x03Y\ - \x04\x12\n\r\n\x05\x04\x02\x02\x01\x04\x12\x04Y\x04X\x1f\n\x0c\n\x05\x04\ - \x02\x02\x01\x06\x12\x03Y\x04\x08\n\x0c\n\x05\x04\x02\x02\x01\x01\x12\ - \x03Y\t\r\n\x0c\n\x05\x04\x02\x02\x01\x03\x12\x03Y\x10\x11\n\x0b\n\x04\ - \x04\x02\x02\x02\x12\x03Z\x04\x16\n\r\n\x05\x04\x02\x02\x02\x04\x12\x04Z\ - \x04Y\x12\n\x0c\n\x05\x04\x02\x02\x02\x06\x12\x03Z\x04\n\n\x0c\n\x05\x04\ - \x02\x02\x02\x01\x12\x03Z\x0b\x11\n\x0c\n\x05\x04\x02\x02\x02\x03\x12\ - \x03Z\x14\x15\n=\n\x04\x04\x02\x03\0\x12\x04]\x04i\x05\x1a/\x20represent\ - ation\x20of\x20the\x20K8s\x20ObjectMeta\x20resource\n\n\x0c\n\x05\x04\ - \x02\x03\0\x01\x12\x03]\x0c\x16\n\r\n\x06\x04\x02\x03\0\x02\0\x12\x03^\ - \x08\x18\n\x0f\n\x07\x04\x02\x03\0\x02\0\x04\x12\x04^\x08]\x18\n\x0e\n\ - \x07\x04\x02\x03\0\x02\0\x05\x12\x03^\x08\x0e\n\x0e\n\x07\x04\x02\x03\0\ - \x02\0\x01\x12\x03^\x0f\x13\n\x0e\n\x07\x04\x02\x03\0\x02\0\x03\x12\x03^\ - \x16\x17\n\r\n\x06\x04\x02\x03\0\x02\x01\x12\x03_\x08\x1d\n\x0f\n\x07\ - \x04\x02\x03\0\x02\x01\x04\x12\x04_\x08^\x18\n\x0e\n\x07\x04\x02\x03\0\ - \x02\x01\x05\x12\x03_\x08\x0e\n\x0e\n\x07\x04\x02\x03\0\x02\x01\x01\x12\ - \x03_\x0f\x18\n\x0e\n\x07\x04\x02\x03\0\x02\x01\x03\x12\x03_\x1b\x1c\n\r\ - \n\x06\x04\x02\x03\0\x02\x02\x12\x03`\x08\x17\n\x0f\n\x07\x04\x02\x03\0\ - \x02\x02\x04\x12\x04`\x08_\x1d\n\x0e\n\x07\x04\x02\x03\0\x02\x02\x05\x12\ - \x03`\x08\x0e\n\x0e\n\x07\x04\x02\x03\0\x02\x02\x01\x12\x03`\x0f\x12\n\ - \x0e\n\x07\x04\x02\x03\0\x02\x02\x03\x12\x03`\x15\x16\n\r\n\x06\x04\x02\ - \x03\0\x02\x03\x12\x03a\x08$\n\x0f\n\x07\x04\x02\x03\0\x02\x03\x04\x12\ - \x04a\x08`\x17\n\x0e\n\x07\x04\x02\x03\0\x02\x03\x05\x12\x03a\x08\x0e\n\ - \x0e\n\x07\x04\x02\x03\0\x02\x03\x01\x12\x03a\x0f\x1f\n\x0e\n\x07\x04\ - \x02\x03\0\x02\x03\x03\x12\x03a\"#\n\r\n\x06\x04\x02\x03\0\x02\x04\x12\ - \x03b\x08\x1d\n\x0f\n\x07\x04\x02\x03\0\x02\x04\x04\x12\x04b\x08a$\n\x0e\ - \n\x07\x04\x02\x03\0\x02\x04\x05\x12\x03b\x08\r\n\x0e\n\x07\x04\x02\x03\ - \0\x02\x04\x01\x12\x03b\x0e\x18\n\x0e\n\x07\x04\x02\x03\0\x02\x04\x03\ - \x12\x03b\x1b\x1c\n<\n\x06\x04\x02\x03\0\x02\x05\x12\x03d\x08%\x1a-\x20t\ - imestamp\x20is\x20in\x20Epoch\x20format,\x20unit:\x20seconds\n\n\x0f\n\ - \x07\x04\x02\x03\0\x02\x05\x04\x12\x04d\x08b\x1d\n\x0e\n\x07\x04\x02\x03\ - \0\x02\x05\x05\x12\x03d\x08\r\n\x0e\n\x07\x04\x02\x03\0\x02\x05\x01\x12\ - \x03d\x0e\x20\n\x0e\n\x07\x04\x02\x03\0\x02\x05\x03\x12\x03d#$\nK\n\x06\ - \x04\x02\x03\0\x02\x06\x12\x03f\x08%\x1a<\x20optional\x20deletion\x20tim\ - estamp\x20in\x20Epoch\x20format,\x20unit:\x20seconds\n\n\x0f\n\x07\x04\ - \x02\x03\0\x02\x06\x04\x12\x04f\x08d%\n\x0e\n\x07\x04\x02\x03\0\x02\x06\ - \x05\x12\x03f\x08\r\n\x0e\n\x07\x04\x02\x03\0\x02\x06\x01\x12\x03f\x0e\ - \x20\n\x0e\n\x07\x04\x02\x03\0\x02\x06\x03\x12\x03f#$\n\r\n\x06\x04\x02\ - \x03\0\x02\x07\x12\x03g\x08,\n\x0f\n\x07\x04\x02\x03\0\x02\x07\x04\x12\ - \x04g\x08f%\n\x0e\n\x07\x04\x02\x03\0\x02\x07\x06\x12\x03g\x08\x1b\n\x0e\ - \n\x07\x04\x02\x03\0\x02\x07\x01\x12\x03g\x1c'\n\x0e\n\x07\x04\x02\x03\0\ - \x02\x07\x03\x12\x03g*+\n\r\n\x06\x04\x02\x03\0\x02\x08\x12\x03h\x08'\n\ - \x0f\n\x07\x04\x02\x03\0\x02\x08\x04\x12\x04h\x08g,\n\x0e\n\x07\x04\x02\ - \x03\0\x02\x08\x06\x12\x03h\x08\x1b\n\x0e\n\x07\x04\x02\x03\0\x02\x08\ - \x01\x12\x03h\x1c\"\n\x0e\n\x07\x04\x02\x03\0\x02\x08\x03\x12\x03h%&\n\ - \x0c\n\x04\x04\x02\x03\x01\x12\x04k\x04t\x05\n\x0c\n\x05\x04\x02\x03\x01\ - \x01\x12\x03k\x0c\x10\n\r\n\x06\x04\x02\x03\x01\x02\0\x12\x03l\x08\x1a\n\ - \x0f\n\x07\x04\x02\x03\x01\x02\0\x04\x12\x04l\x08k\x12\n\x0e\n\x07\x04\ - \x02\x03\x01\x02\0\x06\x12\x03l\x08\x0e\n\x0e\n\x07\x04\x02\x03\x01\x02\ - \0\x01\x12\x03l\x0f\x15\n\x0e\n\x07\x04\x02\x03\x01\x02\0\x03\x12\x03l\ - \x18\x19\n\x0e\n\x06\x04\x02\x03\x01\x03\0\x12\x04n\x08s\t\n\x0e\n\x07\ - \x04\x02\x03\x01\x03\0\x01\x12\x03n\x10\x16\n\x0f\n\x08\x04\x02\x03\x01\ - \x03\0\x02\0\x12\x03o\x0c\x1e\n\x11\n\t\x04\x02\x03\x01\x03\0\x02\0\x04\ - \x12\x04o\x0cn\x18\n\x10\n\t\x04\x02\x03\x01\x03\0\x02\0\x05\x12\x03o\ - \x0c\x10\n\x10\n\t\x04\x02\x03\x01\x03\0\x02\0\x01\x12\x03o\x11\x19\n\ - \x10\n\t\x04\x02\x03\x01\x03\0\x02\0\x03\x12\x03o\x1c\x1d\n\x0f\n\x08\ - \x04\x02\x03\x01\x03\0\x02\x01\x12\x03p\x0c$\n\x11\n\t\x04\x02\x03\x01\ - \x03\0\x02\x01\x04\x12\x04p\x0co\x1e\n\x10\n\t\x04\x02\x03\x01\x03\0\x02\ - \x01\x05\x12\x03p\x0c\x11\n\x10\n\t\x04\x02\x03\x01\x03\0\x02\x01\x01\ - \x12\x03p\x12\x1f\n\x10\n\t\x04\x02\x03\x01\x03\0\x02\x01\x03\x12\x03p\"\ - #\n\x0f\n\x08\x04\x02\x03\x01\x03\0\x02\x02\x12\x03q\x0c'\n\x11\n\t\x04\ - \x02\x03\x01\x03\0\x02\x02\x04\x12\x04q\x0cp$\n\x10\n\t\x04\x02\x03\x01\ - \x03\0\x02\x02\x05\x12\x03q\x0c\x11\n\x10\n\t\x04\x02\x03\x01\x03\0\x02\ - \x02\x01\x12\x03q\x12\"\n\x10\n\t\x04\x02\x03\x01\x03\0\x02\x02\x03\x12\ - \x03q%&\n\x0f\n\x08\x04\x02\x03\x01\x03\0\x02\x03\x12\x03r\x0c*\n\x11\n\ - \t\x04\x02\x03\x01\x03\0\x02\x03\x04\x12\x04r\x0cq'\n\x10\n\t\x04\x02\ - \x03\x01\x03\0\x02\x03\x05\x12\x03r\x0c\x11\n\x10\n\t\x04\x02\x03\x01\ - \x03\0\x02\x03\x01\x12\x03r\x12%\n\x10\n\t\x04\x02\x03\x01\x03\0\x02\x03\ - \x03\x12\x03r()\n\x0c\n\x04\x04\x02\x03\x02\x12\x04v\x04\x7f\x05\n\x0c\n\ - \x05\x04\x02\x03\x02\x01\x12\x03v\x0c\x12\n\x0e\n\x06\x04\x02\x03\x02\ - \x03\0\x12\x04w\x08z\t\n\x0e\n\x07\x04\x02\x03\x02\x03\0\x01\x12\x03w\ - \x10\x14\n\x0f\n\x08\x04\x02\x03\x02\x03\0\x02\0\x12\x03x\x0c\x1c\n\x11\ - \n\t\x04\x02\x03\x02\x03\0\x02\0\x04\x12\x04x\x0cw\x16\n\x10\n\t\x04\x02\ - \x03\x02\x03\0\x02\0\x05\x12\x03x\x0c\x12\n\x10\n\t\x04\x02\x03\x02\x03\ - \0\x02\0\x01\x12\x03x\x13\x17\n\x10\n\t\x04\x02\x03\x02\x03\0\x02\0\x03\ - \x12\x03x\x1a\x1b\n\x0f\n\x08\x04\x02\x03\x02\x03\0\x02\x01\x12\x03y\x0c\ - \x1b\n\x11\n\t\x04\x02\x03\x02\x03\0\x02\x01\x04\x12\x04y\x0cx\x1c\n\x10\ - \n\t\x04\x02\x03\x02\x03\0\x02\x01\x05\x12\x03y\x0c\x11\n\x10\n\t\x04\ - \x02\x03\x02\x03\0\x02\x01\x01\x12\x03y\x12\x16\n\x10\n\t\x04\x02\x03\ - \x02\x03\0\x02\x01\x03\x12\x03y\x19\x1a\n\r\n\x06\x04\x02\x03\x02\x02\0\ - \x12\x03|\x08\x19\n\x0f\n\x07\x04\x02\x03\x02\x02\0\x04\x12\x04|\x08z\t\ - \n\x0e\n\x07\x04\x02\x03\x02\x02\0\x05\x12\x03|\x08\x0e\n\x0e\n\x07\x04\ - \x02\x03\x02\x02\0\x01\x12\x03|\x0f\x14\n\x0e\n\x07\x04\x02\x03\x02\x02\ - \0\x03\x12\x03|\x17\x18\n\r\n\x06\x04\x02\x03\x02\x02\x01\x12\x03}\x08\ - \x1b\n\x0f\n\x07\x04\x02\x03\x02\x02\x01\x04\x12\x04}\x08|\x19\n\x0e\n\ - \x07\x04\x02\x03\x02\x02\x01\x05\x12\x03}\x08\x0e\n\x0e\n\x07\x04\x02\ - \x03\x02\x02\x01\x01\x12\x03}\x0f\x16\n\x0e\n\x07\x04\x02\x03\x02\x02\ - \x01\x03\x12\x03}\x19\x1a\n\r\n\x06\x04\x02\x03\x02\x02\x02\x12\x03~\x08\ - \x20\n\x0e\n\x07\x04\x02\x03\x02\x02\x02\x04\x12\x03~\x08\x10\n\x0e\n\ - \x07\x04\x02\x03\x02\x02\x02\x06\x12\x03~\x11\x15\n\x0e\n\x07\x04\x02\ - \x03\x02\x02\x02\x01\x12\x03~\x16\x1b\n\x0e\n\x07\x04\x02\x03\x02\x02\ - \x02\x03\x12\x03~\x1e\x1fb\x06proto3\ + \n\x11\n\t\x06\0\x02\0\x04\xb0\xca\xbc\"\x12\x04\x19\x08\x1c\n\n6\n\x04\ + \x06\0\x02\x01\x12\x04\x20\x04%\x05\x1a(\x20Call\x20to\x20self\x20Alloca\ + tion\x20the\x20GameServer\n\n\x0c\n\x05\x06\0\x02\x01\x01\x12\x03\x20\ + \x08\x10\n\x0c\n\x05\x06\0\x02\x01\x02\x12\x03\x20\x11\x16\n\x0c\n\x05\ + \x06\0\x02\x01\x03\x12\x03\x20!&\n\r\n\x05\x06\0\x02\x01\x04\x12\x04!\ + \x08$\n\n\x11\n\t\x06\0\x02\x01\x04\xb0\xca\xbc\"\x12\x04!\x08$\n\n9\n\ + \x04\x06\0\x02\x02\x12\x04(\x04-\x05\x1a+\x20Call\x20when\x20the\x20Game\ + Server\x20is\x20shutting\x20down\n\n\x0c\n\x05\x06\0\x02\x02\x01\x12\x03\ + (\x08\x10\n\x0c\n\x05\x06\0\x02\x02\x02\x12\x03(\x12\x17\n\x0c\n\x05\x06\ + \0\x02\x02\x03\x12\x03(\"'\n\r\n\x05\x06\0\x02\x02\x04\x12\x04)\x08,\n\n\ + \x11\n\t\x06\0\x02\x02\x04\xb0\xca\xbc\"\x12\x04)\x08,\n\nW\n\x04\x06\0\ + \x02\x03\x12\x04/\x044\x05\x1aI\x20Send\x20a\x20Empty\x20every\x20d\x20D\ + uration\x20to\x20declare\x20that\x20this\x20GameSever\x20is\x20healthy\n\ + \n\x0c\n\x05\x06\0\x02\x03\x01\x12\x03/\x08\x0e\n\x0c\n\x05\x06\0\x02\ + \x03\x05\x12\x03/\x10\x16\n\x0c\n\x05\x06\0\x02\x03\x02\x12\x03/\x17\x1c\ + \n\x0c\n\x05\x06\0\x02\x03\x03\x12\x03/',\n\r\n\x05\x06\0\x02\x03\x04\ + \x12\x040\x083\x12\n\x11\n\t\x06\0\x02\x03\x04\xb0\xca\xbc\"\x12\x040\ + \x083\x12\n4\n\x04\x06\0\x02\x04\x12\x046\x04:\x05\x1a&\x20Retrieve\x20t\ + he\x20current\x20GameServer\x20data\n\n\x0c\n\x05\x06\0\x02\x04\x01\x12\ + \x036\x08\x15\n\x0c\n\x05\x06\0\x02\x04\x02\x12\x036\x17\x1c\n\x0c\n\x05\ + \x06\0\x02\x04\x03\x12\x036'1\n\r\n\x05\x06\0\x02\x04\x04\x12\x047\x089\ + \n\n\x11\n\t\x06\0\x02\x04\x04\xb0\xca\xbc\"\x12\x047\x089\n\nJ\n\x04\ + \x06\0\x02\x05\x12\x04<\x04@\x05\x1a<\x20Send\x20GameServer\x20details\ + \x20whenever\x20the\x20GameServer\x20is\x20updated\n\n\x0c\n\x05\x06\0\ + \x02\x05\x01\x12\x03<\x08\x17\n\x0c\n\x05\x06\0\x02\x05\x02\x12\x03<\x19\ + \x1e\n\x0c\n\x05\x06\0\x02\x05\x06\x12\x03<)/\n\x0c\n\x05\x06\0\x02\x05\ + \x03\x12\x03<0:\n\r\n\x05\x06\0\x02\x05\x04\x12\x04=\x08?\n\n\x11\n\t\ + \x06\0\x02\x05\x04\xb0\xca\xbc\"\x12\x04=\x08?\n\n@\n\x04\x06\0\x02\x06\ + \x12\x04C\x04H\x05\x1a2\x20Apply\x20a\x20Label\x20to\x20the\x20backing\ + \x20GameServer\x20metadata\n\n\x0c\n\x05\x06\0\x02\x06\x01\x12\x03C\x08\ + \x10\n\x0c\n\x05\x06\0\x02\x06\x02\x12\x03C\x11\x19\n\x0c\n\x05\x06\0\ + \x02\x06\x03\x12\x03C$)\n\r\n\x05\x06\0\x02\x06\x04\x12\x04D\x08G\x12\n\ + \x11\n\t\x06\0\x02\x06\x04\xb0\xca\xbc\"\x12\x04D\x08G\x12\nE\n\x04\x06\ + \0\x02\x07\x12\x04K\x04P\x05\x1a7\x20Apply\x20a\x20Annotation\x20to\x20t\ + he\x20backing\x20GameServer\x20metadata\n\n\x0c\n\x05\x06\0\x02\x07\x01\ + \x12\x03K\x08\x15\n\x0c\n\x05\x06\0\x02\x07\x02\x12\x03K\x16\x1e\n\x0c\n\ + \x05\x06\0\x02\x07\x03\x12\x03K).\n\r\n\x05\x06\0\x02\x07\x04\x12\x04L\ + \x08O\x12\n\x11\n\t\x06\0\x02\x07\x04\xb0\xca\xbc\"\x12\x04L\x08O\x12\n\ + \x18\n\x02\x04\0\x12\x04T\0U\x01\x1a\x0c\x20I\x20am\x20Empty\n\n\n\n\x03\ + \x04\0\x01\x12\x03T\x08\r\n\x1e\n\x02\x04\x01\x12\x04X\0[\x01\x1a\x12\ + \x20Key,\x20Value\x20entry\n\n\n\n\x03\x04\x01\x01\x12\x03X\x08\x10\n\ + \x0b\n\x04\x04\x01\x02\0\x12\x03Y\x04\x13\n\r\n\x05\x04\x01\x02\0\x04\ + \x12\x04Y\x04X\x12\n\x0c\n\x05\x04\x01\x02\0\x05\x12\x03Y\x04\n\n\x0c\n\ + \x05\x04\x01\x02\0\x01\x12\x03Y\x0b\x0e\n\x0c\n\x05\x04\x01\x02\0\x03\ + \x12\x03Y\x11\x12\n\x0b\n\x04\x04\x01\x02\x01\x12\x03Z\x04\x15\n\r\n\x05\ + \x04\x01\x02\x01\x04\x12\x04Z\x04Y\x13\n\x0c\n\x05\x04\x01\x02\x01\x05\ + \x12\x03Z\x04\n\n\x0c\n\x05\x04\x01\x02\x01\x01\x12\x03Z\x0b\x10\n\x0c\n\ + \x05\x04\x01\x02\x01\x03\x12\x03Z\x13\x14\n\xa3\x01\n\x02\x04\x02\x12\ + \x05`\0\x89\x01\x01\x1a\x95\x01\x20A\x20GameServer\x20Custom\x20Resource\ + \x20Definition\x20object\n\x20We\x20will\x20only\x20export\x20those\x20r\ + esources\x20that\x20make\x20the\x20most\n\x20sense.\x20Can\x20always\x20\ + expand\x20to\x20more\x20as\x20needed.\n\n\n\n\x03\x04\x02\x01\x12\x03`\ + \x08\x12\n\x0b\n\x04\x04\x02\x02\0\x12\x03a\x04\x1f\n\r\n\x05\x04\x02\ + \x02\0\x04\x12\x04a\x04`\x14\n\x0c\n\x05\x04\x02\x02\0\x06\x12\x03a\x04\ + \x0e\n\x0c\n\x05\x04\x02\x02\0\x01\x12\x03a\x0f\x1a\n\x0c\n\x05\x04\x02\ + \x02\0\x03\x12\x03a\x1d\x1e\n\x0b\n\x04\x04\x02\x02\x01\x12\x03b\x04\x12\ + \n\r\n\x05\x04\x02\x02\x01\x04\x12\x04b\x04a\x1f\n\x0c\n\x05\x04\x02\x02\ + \x01\x06\x12\x03b\x04\x08\n\x0c\n\x05\x04\x02\x02\x01\x01\x12\x03b\t\r\n\ + \x0c\n\x05\x04\x02\x02\x01\x03\x12\x03b\x10\x11\n\x0b\n\x04\x04\x02\x02\ + \x02\x12\x03c\x04\x16\n\r\n\x05\x04\x02\x02\x02\x04\x12\x04c\x04b\x12\n\ + \x0c\n\x05\x04\x02\x02\x02\x06\x12\x03c\x04\n\n\x0c\n\x05\x04\x02\x02\ + \x02\x01\x12\x03c\x0b\x11\n\x0c\n\x05\x04\x02\x02\x02\x03\x12\x03c\x14\ + \x15\n=\n\x04\x04\x02\x03\0\x12\x04f\x04r\x05\x1a/\x20representation\x20\ + of\x20the\x20K8s\x20ObjectMeta\x20resource\n\n\x0c\n\x05\x04\x02\x03\0\ + \x01\x12\x03f\x0c\x16\n\r\n\x06\x04\x02\x03\0\x02\0\x12\x03g\x08\x18\n\ + \x0f\n\x07\x04\x02\x03\0\x02\0\x04\x12\x04g\x08f\x18\n\x0e\n\x07\x04\x02\ + \x03\0\x02\0\x05\x12\x03g\x08\x0e\n\x0e\n\x07\x04\x02\x03\0\x02\0\x01\ + \x12\x03g\x0f\x13\n\x0e\n\x07\x04\x02\x03\0\x02\0\x03\x12\x03g\x16\x17\n\ + \r\n\x06\x04\x02\x03\0\x02\x01\x12\x03h\x08\x1d\n\x0f\n\x07\x04\x02\x03\ + \0\x02\x01\x04\x12\x04h\x08g\x18\n\x0e\n\x07\x04\x02\x03\0\x02\x01\x05\ + \x12\x03h\x08\x0e\n\x0e\n\x07\x04\x02\x03\0\x02\x01\x01\x12\x03h\x0f\x18\ + \n\x0e\n\x07\x04\x02\x03\0\x02\x01\x03\x12\x03h\x1b\x1c\n\r\n\x06\x04\ + \x02\x03\0\x02\x02\x12\x03i\x08\x17\n\x0f\n\x07\x04\x02\x03\0\x02\x02\ + \x04\x12\x04i\x08h\x1d\n\x0e\n\x07\x04\x02\x03\0\x02\x02\x05\x12\x03i\ + \x08\x0e\n\x0e\n\x07\x04\x02\x03\0\x02\x02\x01\x12\x03i\x0f\x12\n\x0e\n\ + \x07\x04\x02\x03\0\x02\x02\x03\x12\x03i\x15\x16\n\r\n\x06\x04\x02\x03\0\ + \x02\x03\x12\x03j\x08$\n\x0f\n\x07\x04\x02\x03\0\x02\x03\x04\x12\x04j\ + \x08i\x17\n\x0e\n\x07\x04\x02\x03\0\x02\x03\x05\x12\x03j\x08\x0e\n\x0e\n\ + \x07\x04\x02\x03\0\x02\x03\x01\x12\x03j\x0f\x1f\n\x0e\n\x07\x04\x02\x03\ + \0\x02\x03\x03\x12\x03j\"#\n\r\n\x06\x04\x02\x03\0\x02\x04\x12\x03k\x08\ + \x1d\n\x0f\n\x07\x04\x02\x03\0\x02\x04\x04\x12\x04k\x08j$\n\x0e\n\x07\ + \x04\x02\x03\0\x02\x04\x05\x12\x03k\x08\r\n\x0e\n\x07\x04\x02\x03\0\x02\ + \x04\x01\x12\x03k\x0e\x18\n\x0e\n\x07\x04\x02\x03\0\x02\x04\x03\x12\x03k\ + \x1b\x1c\n<\n\x06\x04\x02\x03\0\x02\x05\x12\x03m\x08%\x1a-\x20timestamp\ + \x20is\x20in\x20Epoch\x20format,\x20unit:\x20seconds\n\n\x0f\n\x07\x04\ + \x02\x03\0\x02\x05\x04\x12\x04m\x08k\x1d\n\x0e\n\x07\x04\x02\x03\0\x02\ + \x05\x05\x12\x03m\x08\r\n\x0e\n\x07\x04\x02\x03\0\x02\x05\x01\x12\x03m\ + \x0e\x20\n\x0e\n\x07\x04\x02\x03\0\x02\x05\x03\x12\x03m#$\nK\n\x06\x04\ + \x02\x03\0\x02\x06\x12\x03o\x08%\x1a<\x20optional\x20deletion\x20timesta\ + mp\x20in\x20Epoch\x20format,\x20unit:\x20seconds\n\n\x0f\n\x07\x04\x02\ + \x03\0\x02\x06\x04\x12\x04o\x08m%\n\x0e\n\x07\x04\x02\x03\0\x02\x06\x05\ + \x12\x03o\x08\r\n\x0e\n\x07\x04\x02\x03\0\x02\x06\x01\x12\x03o\x0e\x20\n\ + \x0e\n\x07\x04\x02\x03\0\x02\x06\x03\x12\x03o#$\n\r\n\x06\x04\x02\x03\0\ + \x02\x07\x12\x03p\x08,\n\x0f\n\x07\x04\x02\x03\0\x02\x07\x04\x12\x04p\ + \x08o%\n\x0e\n\x07\x04\x02\x03\0\x02\x07\x06\x12\x03p\x08\x1b\n\x0e\n\ + \x07\x04\x02\x03\0\x02\x07\x01\x12\x03p\x1c'\n\x0e\n\x07\x04\x02\x03\0\ + \x02\x07\x03\x12\x03p*+\n\r\n\x06\x04\x02\x03\0\x02\x08\x12\x03q\x08'\n\ + \x0f\n\x07\x04\x02\x03\0\x02\x08\x04\x12\x04q\x08p,\n\x0e\n\x07\x04\x02\ + \x03\0\x02\x08\x06\x12\x03q\x08\x1b\n\x0e\n\x07\x04\x02\x03\0\x02\x08\ + \x01\x12\x03q\x1c\"\n\x0e\n\x07\x04\x02\x03\0\x02\x08\x03\x12\x03q%&\n\ + \x0c\n\x04\x04\x02\x03\x01\x12\x04t\x04}\x05\n\x0c\n\x05\x04\x02\x03\x01\ + \x01\x12\x03t\x0c\x10\n\r\n\x06\x04\x02\x03\x01\x02\0\x12\x03u\x08\x1a\n\ + \x0f\n\x07\x04\x02\x03\x01\x02\0\x04\x12\x04u\x08t\x12\n\x0e\n\x07\x04\ + \x02\x03\x01\x02\0\x06\x12\x03u\x08\x0e\n\x0e\n\x07\x04\x02\x03\x01\x02\ + \0\x01\x12\x03u\x0f\x15\n\x0e\n\x07\x04\x02\x03\x01\x02\0\x03\x12\x03u\ + \x18\x19\n\x0e\n\x06\x04\x02\x03\x01\x03\0\x12\x04w\x08|\t\n\x0e\n\x07\ + \x04\x02\x03\x01\x03\0\x01\x12\x03w\x10\x16\n\x0f\n\x08\x04\x02\x03\x01\ + \x03\0\x02\0\x12\x03x\x0c\x1e\n\x11\n\t\x04\x02\x03\x01\x03\0\x02\0\x04\ + \x12\x04x\x0cw\x18\n\x10\n\t\x04\x02\x03\x01\x03\0\x02\0\x05\x12\x03x\ + \x0c\x10\n\x10\n\t\x04\x02\x03\x01\x03\0\x02\0\x01\x12\x03x\x11\x19\n\ + \x10\n\t\x04\x02\x03\x01\x03\0\x02\0\x03\x12\x03x\x1c\x1d\n\x0f\n\x08\ + \x04\x02\x03\x01\x03\0\x02\x01\x12\x03y\x0c$\n\x11\n\t\x04\x02\x03\x01\ + \x03\0\x02\x01\x04\x12\x04y\x0cx\x1e\n\x10\n\t\x04\x02\x03\x01\x03\0\x02\ + \x01\x05\x12\x03y\x0c\x11\n\x10\n\t\x04\x02\x03\x01\x03\0\x02\x01\x01\ + \x12\x03y\x12\x1f\n\x10\n\t\x04\x02\x03\x01\x03\0\x02\x01\x03\x12\x03y\"\ + #\n\x0f\n\x08\x04\x02\x03\x01\x03\0\x02\x02\x12\x03z\x0c'\n\x11\n\t\x04\ + \x02\x03\x01\x03\0\x02\x02\x04\x12\x04z\x0cy$\n\x10\n\t\x04\x02\x03\x01\ + \x03\0\x02\x02\x05\x12\x03z\x0c\x11\n\x10\n\t\x04\x02\x03\x01\x03\0\x02\ + \x02\x01\x12\x03z\x12\"\n\x10\n\t\x04\x02\x03\x01\x03\0\x02\x02\x03\x12\ + \x03z%&\n\x0f\n\x08\x04\x02\x03\x01\x03\0\x02\x03\x12\x03{\x0c*\n\x11\n\ + \t\x04\x02\x03\x01\x03\0\x02\x03\x04\x12\x04{\x0cz'\n\x10\n\t\x04\x02\ + \x03\x01\x03\0\x02\x03\x05\x12\x03{\x0c\x11\n\x10\n\t\x04\x02\x03\x01\ + \x03\0\x02\x03\x01\x12\x03{\x12%\n\x10\n\t\x04\x02\x03\x01\x03\0\x02\x03\ + \x03\x12\x03{()\n\r\n\x04\x04\x02\x03\x02\x12\x05\x7f\x04\x88\x01\x05\n\ + \x0c\n\x05\x04\x02\x03\x02\x01\x12\x03\x7f\x0c\x12\n\x10\n\x06\x04\x02\ + \x03\x02\x03\0\x12\x06\x80\x01\x08\x83\x01\t\n\x0f\n\x07\x04\x02\x03\x02\ + \x03\0\x01\x12\x04\x80\x01\x10\x14\n\x10\n\x08\x04\x02\x03\x02\x03\0\x02\ + \0\x12\x04\x81\x01\x0c\x1c\n\x13\n\t\x04\x02\x03\x02\x03\0\x02\0\x04\x12\ + \x06\x81\x01\x0c\x80\x01\x16\n\x11\n\t\x04\x02\x03\x02\x03\0\x02\0\x05\ + \x12\x04\x81\x01\x0c\x12\n\x11\n\t\x04\x02\x03\x02\x03\0\x02\0\x01\x12\ + \x04\x81\x01\x13\x17\n\x11\n\t\x04\x02\x03\x02\x03\0\x02\0\x03\x12\x04\ + \x81\x01\x1a\x1b\n\x10\n\x08\x04\x02\x03\x02\x03\0\x02\x01\x12\x04\x82\ + \x01\x0c\x1b\n\x13\n\t\x04\x02\x03\x02\x03\0\x02\x01\x04\x12\x06\x82\x01\ + \x0c\x81\x01\x1c\n\x11\n\t\x04\x02\x03\x02\x03\0\x02\x01\x05\x12\x04\x82\ + \x01\x0c\x11\n\x11\n\t\x04\x02\x03\x02\x03\0\x02\x01\x01\x12\x04\x82\x01\ + \x12\x16\n\x11\n\t\x04\x02\x03\x02\x03\0\x02\x01\x03\x12\x04\x82\x01\x19\ + \x1a\n\x0e\n\x06\x04\x02\x03\x02\x02\0\x12\x04\x85\x01\x08\x19\n\x11\n\ + \x07\x04\x02\x03\x02\x02\0\x04\x12\x06\x85\x01\x08\x83\x01\t\n\x0f\n\x07\ + \x04\x02\x03\x02\x02\0\x05\x12\x04\x85\x01\x08\x0e\n\x0f\n\x07\x04\x02\ + \x03\x02\x02\0\x01\x12\x04\x85\x01\x0f\x14\n\x0f\n\x07\x04\x02\x03\x02\ + \x02\0\x03\x12\x04\x85\x01\x17\x18\n\x0e\n\x06\x04\x02\x03\x02\x02\x01\ + \x12\x04\x86\x01\x08\x1b\n\x11\n\x07\x04\x02\x03\x02\x02\x01\x04\x12\x06\ + \x86\x01\x08\x85\x01\x19\n\x0f\n\x07\x04\x02\x03\x02\x02\x01\x05\x12\x04\ + \x86\x01\x08\x0e\n\x0f\n\x07\x04\x02\x03\x02\x02\x01\x01\x12\x04\x86\x01\ + \x0f\x16\n\x0f\n\x07\x04\x02\x03\x02\x02\x01\x03\x12\x04\x86\x01\x19\x1a\ + \n\x0e\n\x06\x04\x02\x03\x02\x02\x02\x12\x04\x87\x01\x08\x20\n\x0f\n\x07\ + \x04\x02\x03\x02\x02\x02\x04\x12\x04\x87\x01\x08\x10\n\x0f\n\x07\x04\x02\ + \x03\x02\x02\x02\x06\x12\x04\x87\x01\x11\x15\n\x0f\n\x07\x04\x02\x03\x02\ + \x02\x02\x01\x12\x04\x87\x01\x16\x1b\n\x0f\n\x07\x04\x02\x03\x02\x02\x02\ + \x03\x12\x04\x87\x01\x1e\x1fb\x06proto3\ "; static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { diff --git a/sdks/rust/src/grpc/sdk_grpc.rs b/sdks/rust/src/grpc/sdk_grpc.rs index 1acac86a17..bbe94c90b4 100644 --- a/sdks/rust/src/grpc/sdk_grpc.rs +++ b/sdks/rust/src/grpc/sdk_grpc.rs @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC All Rights Reserved. +// Copyright 2019 Google LLC All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -40,6 +40,13 @@ const METHOD_SDK_READY: ::grpcio::Method = resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, }; +const METHOD_SDK_ALLOCATE: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/stable.agones.dev.sdk.SDK/Allocate", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + const METHOD_SDK_SHUTDOWN: ::grpcio::Method = ::grpcio::Method { ty: ::grpcio::MethodType::Unary, name: "/stable.agones.dev.sdk.SDK/Shutdown", @@ -109,6 +116,22 @@ impl SdkClient { self.ready_async_opt(req, ::grpcio::CallOption::default()) } + pub fn allocate_opt(&self, req: &super::sdk::Empty, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_SDK_ALLOCATE, req, opt) + } + + pub fn allocate(&self, req: &super::sdk::Empty) -> ::grpcio::Result { + self.allocate_opt(req, ::grpcio::CallOption::default()) + } + + pub fn allocate_async_opt(&self, req: &super::sdk::Empty, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_SDK_ALLOCATE, req, opt) + } + + pub fn allocate_async(&self, req: &super::sdk::Empty) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.allocate_async_opt(req, ::grpcio::CallOption::default()) + } + pub fn shutdown_opt(&self, req: &super::sdk::Empty, opt: ::grpcio::CallOption) -> ::grpcio::Result { self.client.unary_call(&METHOD_SDK_SHUTDOWN, req, opt) } @@ -195,6 +218,7 @@ impl SdkClient { pub trait Sdk { fn ready(&self, ctx: ::grpcio::RpcContext, req: super::sdk::Empty, sink: ::grpcio::UnarySink); + fn allocate(&self, ctx: ::grpcio::RpcContext, req: super::sdk::Empty, sink: ::grpcio::UnarySink); fn shutdown(&self, ctx: ::grpcio::RpcContext, req: super::sdk::Empty, sink: ::grpcio::UnarySink); fn health(&self, ctx: ::grpcio::RpcContext, stream: ::grpcio::RequestStream, sink: ::grpcio::ClientStreamingSink); fn get_game_server(&self, ctx: ::grpcio::RpcContext, req: super::sdk::Empty, sink: ::grpcio::UnarySink); @@ -210,6 +234,10 @@ pub fn create_sdk(s: S) -> ::grpcio::Service { instance.ready(ctx, req, resp) }); let instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_SDK_ALLOCATE, move |ctx, req, resp| { + instance.allocate(ctx, req, resp) + }); + let instance = s.clone(); builder = builder.add_unary_handler(&METHOD_SDK_SHUTDOWN, move |ctx, req, resp| { instance.shutdown(ctx, req, resp) }); diff --git a/site/content/en/docs/Advanced/limiting-resources.md b/site/content/en/docs/Advanced/limiting-resources.md index de47c7ded1..05fb36ba2d 100644 --- a/site/content/en/docs/Advanced/limiting-resources.md +++ b/site/content/en/docs/Advanced/limiting-resources.md @@ -38,7 +38,7 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.7 + image: gcr.io/agones-images/udp-server:0.8 resources: limit: cpu: "250m" #this is our limit here diff --git a/site/content/en/docs/Advanced/scheduling-and-autoscaling.md b/site/content/en/docs/Advanced/scheduling-and-autoscaling.md index 6bc58665b1..532f741f2b 100644 --- a/site/content/en/docs/Advanced/scheduling-and-autoscaling.md +++ b/site/content/en/docs/Advanced/scheduling-and-autoscaling.md @@ -79,7 +79,7 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.7 + image: gcr.io/agones-images/udp-server:0.8 ``` This is the *default* Fleet scheduling strategy. It is designed for dynamic Kubernetes environments, wherein you wish @@ -134,7 +134,7 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.7 + image: gcr.io/agones-images/udp-server:0.8 ``` This Fleet scheduling strategy is designed for static Kubernetes environments, such as when you are running Kubernetes diff --git a/site/content/en/docs/Advanced/service-accounts.md b/site/content/en/docs/Advanced/service-accounts.md index c3fb24ab71..6b6b6c2220 100644 --- a/site/content/en/docs/Advanced/service-accounts.md +++ b/site/content/en/docs/Advanced/service-accounts.md @@ -39,7 +39,7 @@ spec: serviceAccountName: my-special-service-account # a custom service account containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.7 + image: gcr.io/agones-images/udp-server:0.8 ``` If a service account is configured, the mounted key is not overwritten, as it assumed that you want to have full control diff --git a/site/content/en/docs/Getting Started/create-fleet.md b/site/content/en/docs/Getting Started/create-fleet.md index 24dbb776e8..b9d09837fd 100644 --- a/site/content/en/docs/Getting Started/create-fleet.md +++ b/site/content/en/docs/Getting Started/create-fleet.md @@ -111,7 +111,7 @@ Spec: Creation Timestamp: Spec: Containers: - Image: gcr.io/agones-images/udp-server:0.7 + Image: gcr.io/agones-images/udp-server:0.8 Name: simple-udp Resources: Status: @@ -346,7 +346,7 @@ status: creationTimestamp: null spec: containers: - - image: gcr.io/agones-images/udp-server:0.7 + - image: gcr.io/agones-images/udp-server:0.8 name: simple-udp resources: {} status: diff --git a/site/content/en/docs/Getting Started/create-gameserver.md b/site/content/en/docs/Getting Started/create-gameserver.md index 437eb234c1..c031c6c4d6 100644 --- a/site/content/en/docs/Getting Started/create-gameserver.md +++ b/site/content/en/docs/Getting Started/create-gameserver.md @@ -107,7 +107,7 @@ Spec: Creation Timestamp: Spec: Containers: - Image: gcr.io/agones-images/udp-server:0.7 + Image: gcr.io/agones-images/udp-server:0.8 Name: simple-udp Resources: Limits: diff --git a/site/content/en/docs/Guides/Client SDKs/_index.md b/site/content/en/docs/Guides/Client SDKs/_index.md index 496049d5d2..34ab550dce 100644 --- a/site/content/en/docs/Guides/Client SDKs/_index.md +++ b/site/content/en/docs/Guides/Client SDKs/_index.md @@ -106,6 +106,19 @@ specifically at the `message GameServer`. For language specific documentation, have a look at the respective source (linked above), and the {{< ghlink href="examples" >}}examples{{< /ghlink >}}. +{{% feature publishVersion="0.10.0" %}} + +### Allocate() + +With some matchmakers and game matching strategies, it can be important for game servers to mark themselves as `Allocated`. +For those scenarios, this SDK functionality exists. + +> Note: Using a [GameServerAllocation]({{< ref "/docs/Reference/fleet.md#gameserver-allocation-specification" >}}) is preferred in all other scenarios, +as it gives Agones control over how packed `GameServers` are scheduled within a cluster, whereas with `Allocate()` you +relinquish control to an external service which likely doesn't have as much information as Agones. + +{{% /feature %}} + ## Writing your own SDK If there isn't a SDK for the language and platform you are looking for, you have several options: diff --git a/site/content/en/docs/Guides/Client SDKs/rest.md b/site/content/en/docs/Guides/Client SDKs/rest.md index 1f2b62f9ea..0e64cd66b1 100644 --- a/site/content/en/docs/Guides/Client SDKs/rest.md +++ b/site/content/en/docs/Guides/Client SDKs/rest.md @@ -147,4 +147,23 @@ Response: {"result":{"object_meta":{"name":"local","namespace":"default","uid":"1234","resource_version":"v1","generation":"1","creation_timestamp":"1533766607","annotations":{"annotation":"true"},"labels":{"islocal":"true"}},"status":{"state":"Ready","address":"127.0.0.1","ports":[{"name":"default","port":7777}]}}} {"result":{"object_meta":{"name":"local","namespace":"default","uid":"1234","resource_version":"v1","generation":"1","creation_timestamp":"1533766607","annotations":{"annotation":"true"},"labels":{"islocal":"true"}},"status":{"state":"Ready","address":"127.0.0.1","ports":[{"name":"default","port":7777}]}}} {"result":{"object_meta":{"name":"local","namespace":"default","uid":"1234","resource_version":"v1","generation":"1","creation_timestamp":"1533766607","annotations":{"annotation":"true"},"labels":{"islocal":"true"}},"status":{"state":"Ready","address":"127.0.0.1","ports":[{"name":"default","port":7777}]}}} -``` \ No newline at end of file +``` + +{{% feature publishVersion="0.10.0" %}} + +### Allocate + +With some matchmakers and game matching strategies, it can be important for game servers to mark themselves as `Allocated`. +For those scenarios, this SDK functionality exists. + +> Note: Using a [GameServerAllocation]({{< ref "/docs/Reference/fleet.md#gameserver-allocation-specification" >}}) is preferred in all other scenarios, +as it gives Agones control over how packed `GameServers` are scheduled within a cluster, whereas with `Allocate()` you +relinquish control to an external service which likely doesn't have as much information as Agones. + +#### Example + +```bash +$ curl -d "{}" -H "Content-Type: application/json" -X POST http://localhost:59358/allocate +``` + +{{% /feature %}} \ No newline at end of file diff --git a/site/content/en/docs/Guides/access-api.md b/site/content/en/docs/Guides/access-api.md index 1946ac3b51..c1c84a610e 100644 --- a/site/content/en/docs/Guides/access-api.md +++ b/site/content/en/docs/Guides/access-api.md @@ -90,7 +90,7 @@ func main() { Spec: v1alpha1.GameServerSpec{ Template: corev1.PodTemplateSpec{ Spec: corev1.PodSpec{ - Containers: []corev1.Container{{Name: "udp-server", Image: "gcr.io/agones-images/udp-server:0.7"}}, + Containers: []corev1.Container{{Name: "udp-server", Image: "gcr.io/agones-images/udp-server:0.8"}}, }, }, }, @@ -178,7 +178,7 @@ $ curl http://localhost:8001/apis/stable.agones.dev/v1alpha1/namespaces/default/ "kind": "GameServer", "metadata": { "annotations": { - "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"stable.agones.dev/v1alpha1\",\"kind\":\"GameServer\",\"metadata\":{\"annotations\":{},\"name\":\"simple-udp\",\"namespace\":\"default\"},\"spec\":{\"containerPort\":7654,\"hostPort\":7777,\"portPolicy\":\"static\",\"template\":{\"spec\":{\"containers\":[{\"image\":\"gcr.io/agones-images/udp-server:0.7\",\"name\":\"simple-udp\"}]}}}}\n" + "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"stable.agones.dev/v1alpha1\",\"kind\":\"GameServer\",\"metadata\":{\"annotations\":{},\"name\":\"simple-udp\",\"namespace\":\"default\"},\"spec\":{\"containerPort\":7654,\"hostPort\":7777,\"portPolicy\":\"static\",\"template\":{\"spec\":{\"containers\":[{\"image\":\"gcr.io/agones-images/udp-server:0.8\",\"name\":\"simple-udp\"}]}}}}\n" }, "clusterName": "", "creationTimestamp": "2018-03-02T21:41:05Z", @@ -210,7 +210,7 @@ $ curl http://localhost:8001/apis/stable.agones.dev/v1alpha1/namespaces/default/ "spec": { "containers": [ { - "image": "gcr.io/agones-images/udp-server:0.7", + "image": "gcr.io/agones-images/udp-server:0.8", "name": "simple-udp", "resources": {} } @@ -317,7 +317,7 @@ $ curl -d '{"apiVersion":"stable.agones.dev/v1alpha1","kind":"FleetAllocation"," "spec": { "containers": [ { - "image": "gcr.io/agones-images/udp-server:0.7", + "image": "gcr.io/agones-images/udp-server:0.8", "name": "simple-udp", "resources": {} } diff --git a/test/e2e/gameserver_test.go b/test/e2e/gameserver_test.go index 98484574b8..f59f9bd5e6 100644 --- a/test/e2e/gameserver_test.go +++ b/test/e2e/gameserver_test.go @@ -245,6 +245,37 @@ func TestDevelopmentGameServerLifecycle(t *testing.T) { assert.Equal(t, readyGs.Status.State, v1alpha1.GameServerStateReady) } +func TestGameServerSelfAllocate(t *testing.T) { + t.Parallel() + gs := defaultGameServer() + readyGs, err := framework.CreateGameServerAndWaitUntilReady(defaultNs, gs) + if err != nil { + t.Fatalf("Could not get a GameServer ready: %v", err) + } + defer framework.AgonesClient.StableV1alpha1().GameServers(defaultNs).Delete(readyGs.ObjectMeta.Name, nil) // nolint: errcheck + + assert.Equal(t, readyGs.Status.State, v1alpha1.GameServerStateReady) + reply, err := e2eframework.SendGameServerUDP(readyGs, "ALLOCATE") + + if err != nil { + t.Fatalf("Could not message GameServer: %v", err) + } + + assert.Equal(t, "ACK: ALLOCATE\n", reply) + + // the label is set in a queue, so it may take a moment + err = wait.PollImmediate(time.Second, 10*time.Second, func() (bool, error) { + gs, err = framework.AgonesClient.StableV1alpha1().GameServers(defaultNs).Get(readyGs.ObjectMeta.Name, metav1.GetOptions{}) + if err != nil { + return true, err + } + + return gs.Status.State == v1alpha1.GameServerStateAllocated, nil + }) + + assert.NoError(t, err) +} + func defaultGameServer() *v1alpha1.GameServer { gs := &v1alpha1.GameServer{ObjectMeta: metav1.ObjectMeta{GenerateName: "udp-server", Namespace: defaultNs}, Spec: v1alpha1.GameServerSpec{ diff --git a/test/e2e/main_test.go b/test/e2e/main_test.go index e49a3675e2..39c88a057b 100644 --- a/test/e2e/main_test.go +++ b/test/e2e/main_test.go @@ -34,8 +34,8 @@ func TestMain(m *testing.M) { usr, _ := user.Current() kubeconfig := flag.String("kubeconfig", filepath.Join(usr.HomeDir, "/.kube/config"), "kube config path, e.g. $HOME/.kube/config") - gsimage := flag.String("gameserver-image", "gcr.io/agones-images/udp-server:0.7", - "gameserver image to use for those tests, gcr.io/agones-images/udp-server:0.7") + gsimage := flag.String("gameserver-image", "gcr.io/agones-images/udp-server:0.8", + "gameserver image to use for those tests, gcr.io/agones-images/udp-server:0.8") pullSecret := flag.String("pullsecret", "", "optional secret to be used for pulling the gameserver and/or Agones SDK sidecar images") stressTestLevel := flag.Int("stress", 0, "enable stress test at given level 0-100")