Comments (2)
Some guidance would be helpful, but I've started coding for the Wanderer component. I'm not sure if I'm heading in the right direction.
from agones.
// Wanderer component
package main
import (
"bytes"
"encoding/json"
"log"
"net/http"
"time"
)
type Config struct {
// Define configuration struct
}
func main() {
// Define the Agones API endpoint
agonesEndpoint := "http://agones-api.example.com/config"
// Implement logic to trigger configuration changes
for {
// Generate random configuration changes
config := generateRandomConfig()
// Convert configuration to JSON
configJSON, err := json.Marshal(config)
if err != nil {
log.Println("Error marshalling configuration:", err)
continue
}
// Perform configuration change request to Agones API
_, err = http.Post(agonesEndpoint, "application/json", bytes.NewBuffer(configJSON))
if err != nil {
log.Println("Error sending configuration request:", err)
continue
}
log.Println("Configuration change successful:", config)
// Sleep for a defined interval before next configuration change
time.Sleep(30 * time.Minute)
}
}
func generateRandomConfig() Config {
// Implement logic to generate random configuration changes
return Config{}
}
// Producer component
package main
import (
"agones.dev/agones"
"context"
"log"
"time"
)
func main() {
// Initialize Agones SDK client
client, err := agones.NewClient()
if err != nil {
log.Fatal("Error initializing Agones client:", err)
}
// Continuously scale Fleets and allocate GameServers
for {
// Scale Fleets
err := scaleFleets(client)
if err != nil {
log.Println("Error scaling Fleets:", err)
}
// Allocate GameServers
err = allocateGameServers(client)
if err != nil {
log.Println("Error allocating GameServers:", err)
}
// Sleep for a defined interval before next action
time.Sleep(1 * time.Minute)
}
}
func scaleFleets(client *agones.Client) error {
// Implement logic to scale Fleets
return nil
}
func allocateGameServers(client *agones.Client) error {
// Implement logic to allocate GameServers
return nil
}
// Monitor component
package main
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"log"
"net/http"
)
func main() {
// Register Prometheus metrics
requestDuration := prometheus.NewSummaryVec(
prometheus.SummaryOpts{
Name: "http_request_duration_seconds",
Help: "HTTP request duration in seconds.",
},
[]string{"handler", "method"},
)
prometheus.MustRegister(requestDuration)
// Define HTTP handler to expose metrics
http.Handle("/metrics", promhttp.Handler())
// Start HTTP server to expose metrics
log.Fatal(http.ListenAndServe(":8080", nil))
}
from agones.
Related Issues (20)
- Refactor simple-game-server
- `make gen-all-sdk-grpc` is ineffective for nodejs HOT 9
- [Docs] Single source of truth for example yaml files HOT 2
- Fleet autoscaler scale down delay HOT 1
- metadata.finalizers: "agones.dev": prefer a domain-qualified finalizer name to avoid accidental conflicts with other finalizer writer HOT 1
- Implement Count functions in SDKServer, and write e2e tests HOT 1
- sdkserver: add functionality to remove game server annotations
- sdkserver: add functionality to set multiple game server annotations at once HOT 3
- [e2e] Document the best path for making changes to simple-game-server for e2e tests HOT 1
- Add runAsUser, runAsGroup, and allowPrivilegeEscalation to helm chart for Agones containers HOT 8
- Release 1.41.0 HOT 1
- Fix connection-draining flakes in TestAllocatorAfterDeleteReplica / /TestGameServerCreationRightAfterDeletingOneExtensionsPod
- Update Node.js Page to Reflect that Counters and Lists is Implemented
- `make build-images` fails with no REGISTRY variable set HOT 1
- Add AppEngine cleanup to appropriate CloudBuild scripts.
- Distributed defaults to using ListSortedGameServersPriorities when CountsAndLists is enabled HOT 2
- https and CORS for agones-ping http service HOT 1
- Using portPolicy None results in a gameserver's port being 0 HOT 5
- Beta: UpdateList using Agones 1.41 rest API doesn't update the data in the selected list HOT 12
- UpdateList REST Documentation is for Local SDK Server not SDK Server
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from agones.