agonesfx

package
v0.0.29 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 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,
		appSetting mfx.AppParams,
	) (out SDKResult, err error) {
		if deploy := utility.ParseDeployments(appSetting.Deployment); 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(
		params mfx.AppParams,
		sSetting AllocateSettingsParams,
	) (out AllocateResult, err error) {
		if utility.ParseDeployments(params.Deployment).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 AllocateSettingsModule = fx.Provide(
	func() (out AllocateSettingsResult, err error) {
		err = out.LoadFromEnv()
		return
	},
)

Functions

func CreateAgones

func CreateAgones() (siface.IAgones, error)

CreateAgones deploy local agones sdk server

func CreateMock

func CreateMock() (siface.IAgones, error)

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

func NewAllocateClient

func NewAllocateClient(sSetting AllocateSettingsParams) (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)

Types

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 AllocateSettingsParams

type AllocateSettingsParams struct {
	fx.In

	AllocateServiceUrl string `name:"AllocateServiceUrl"`
	ClientCert         string `name:"AllocateClientCert"`
	ClientKey          string `name:"AllocateClientKey"`
	ServerCaCert       string `name:"AllocateServerCaCert"`

	MockAllocateUrl string `name:"MockAllocateUrl"`
}

type AllocateSettingsResult

type AllocateSettingsResult struct {
	fx.Out

	AllocateServiceUrl string `name:"AllocateServiceUrl" envconfig:"ALLOCATE_SERVICE_URL"  default:""`
	ClientCert         string `name:"AllocateClientCert" envconfig:"ALLOCATE_CLIENT_CERT" default:"./configs/x509/agones/tls.crt"`
	ClientKey          string `name:"AllocateClientKey" envconfig:"ALLOCATE_CLIENT_KEY" default:"./configs/x509/agones/tls.key"`
	ServerCaCert       string `name:"AllocateServerCaCert" envconfig:"ALLOCATE_SERVER_CA_CERT" default:"./configs/x509/agones/ca.crt"`

	MockAllocateUrl string `name:"MockAllocateUrl" envconfig:"MOCK_ALLOCATE_URL" default:"localhost:8888"`
}

func (*AllocateSettingsResult) LoadFromEnv

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

type SDKParams

type SDKParams struct {
	fx.In

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

type SDKResult

type SDKResult struct {
	fx.Out

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

Jump to

Keyboard shortcuts

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