agonesfx

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AgonesSDKModule = fx.Provide(
	func(
		l *zap.Logger,
		aSetting AgonesSettingsParams,
	) (out SDKResult, err error) {
		if deploy := utility.ParseDeployments(aSetting.AgonesDeployment); deploy.IsProd() {
			a, err := CreateAgones()
			if err != nil {
				return out, err
			}
			out.SDK = a
		} else {
			a, err := CreateMock()
			if err != nil {
				return out, err
			}
			out.SDK = a
		}
		return
	},
)

AgonesSDKModule is a fx module that provides an Agones sdk(deployment==prod)/mock Agones sdk(deployment!=prod)

View Source
var AllocateClientModule = fx.Provide(
	func(
		sSetting AgonesSettingsParams,
	) (out AllocateResult, err error) {
		if utility.ParseDeployments(sSetting.AgonesDeployment).IsProd() {
			if cli, e := NewAllocateClient(sSetting); e != nil {
				err = e
			} else {
				out.AllocateClient = cli
			}
		} else {
			if cli, e := NewAllocateClientMock(sSetting.MockAllocateUrl); err != nil {
				err = e
			} else {
				out.AllocateClient = cli
			}
		}
		return
	},
)

AllocateClientModule is a fx module that provides an AllocateClient

View Source
var SettingsModule = fx.Provide(
	func() (out AgonesSettingsResult, err error) {
		err = out.LoadFromEnv()
		return
	},
)

Functions

func CreateAgones

func CreateAgones() (aiface.IAgones, error)

CreateAgones deploy local agones sdk server

func CreateMock

func CreateMock() (aiface.IAgones, error)

CreateMock create an empty agones sdk,it will not do anything This is used for local/debugging

func NewAllocateClient

func NewAllocateClient(sSetting AgonesSettingsParams) (allocation.AllocationServiceClient, error)

NewAllocateClient creates a new AllocateClient, requires a host and security settings. Agones need security settings(mTls) to connect to the allocator server. https://agones.dev/site/docs/advanced/allocator-service/#client-certificate

func NewAllocateClientMock

func NewAllocateClientMock(url []string) (allocation.AllocationServiceClient, error)

NewAllocateClientMock creates a new AllocateClientMock, requires a mock hosts to random.

Types

type AgonesSettingsParams added in v0.0.30

type AgonesSettingsParams struct {
	fx.In

	// agones deployment (local/dev/prod)
	AgonesDeployment string `name:"AgonesDeployment"`
	// mock allocate url(only for non-prod deployment)
	MockAllocateUrl []string `name:"MockAllocateUrl"`
	// allocate service url(only for prod deployment)
	AllocateServiceUrl string `name:"AllocateServiceUrl"`
	ClientCert         string `name:"AllocateClientCert"`
	ClientKey          string `name:"AllocateClientKey"`
	ServerCaCert       string `name:"AllocateServerCaCert"`
}

type AgonesSettingsResult added in v0.0.30

type AgonesSettingsResult struct {
	fx.Out
	// agones deployment (local/dev/prod)
	AgonesDeployment string `name:"AgonesDeployment" envconfig:"AGONES_DEPLOYMENT" default:"local"`
	// mock allocate url(only for non-prod deployment)
	MockAllocateUrl []string `name:"MockAllocateUrl" envconfig:"MOCK_ALLOCATE_URL" default:"localhost:8888"`
	// allocate service url(only for prod deployment)
	AllocateServiceUrl string `name:"AllocateServiceUrl" envconfig:"ALLOCATE_SERVICE_URL"  default:""`
	ClientCert         string `name:"AllocateClientCert" envconfig:"ALLOCATE_CLIENT_CERT" default:"./configs/agones/tls.crt"`
	ClientKey          string `name:"AllocateClientKey" envconfig:"ALLOCATE_CLIENT_KEY" default:"./configs/agones/tls.key"`
	ServerCaCert       string `name:"AllocateServerCaCert" envconfig:"ALLOCATE_SERVER_CA_CERT" default:"./configs/agones/ca.crt"`
}

func (*AgonesSettingsResult) LoadFromEnv added in v0.0.30

func (g *AgonesSettingsResult) LoadFromEnv() (err error)

type AllocateParams

type AllocateParams struct {
	fx.In

	AllocateClient allocation.AllocationServiceClient `name:"AllocateClient"`
}

type AllocateResult

type AllocateResult struct {
	fx.Out

	AllocateClient allocation.AllocationServiceClient `name:"AllocateClient"`
}

type SDKParams

type SDKParams struct {
	fx.In

	SDK aiface.IAgones `name:"AgonesSDK" `
}

type SDKResult

type SDKResult struct {
	fx.Out

	SDK aiface.IAgones `name:"AgonesSDK" `
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL