use struct2json and import autoscaler

This commit is contained in:
Rongsong Shen 2025-12-05 18:02:06 +08:00
parent 7b5f280ae5
commit 5036d77f04
62 changed files with 6628 additions and 10 deletions

View file

@ -0,0 +1,58 @@
#ifndef _SCALER_H_
#define _SCALER_H_
#include <pthread.h>
#include <stdlib.h>
#include <time.h>
#include <basiclib/list.h>
#include "config.h"
#include "htab.h"
#include "mylock.h"
#include "scaler/types.h"
#include "xce/types.h"
#include "xlist.h"
#include "zarray.h"
// in seconds
#define DEFAULT_CHECK_INTERVAL 30
typedef struct {
char providers_file[XCE_MAXPATH_LEN];
int check_interval;
} scaler_conf_t;
typedef struct {
zarray_t array;
htab_t tab;
mylock_t lock;
} scaler_obj_mgr_t;
typedef struct demand_list {
xcelist_t* list;
mylock_t lock;
pthread_cond_t cond;
} scaler_demand_queue_t;
typedef struct {
scaler_conf_t configs;
scaler_obj_mgr_t providers;
scaler_obj_mgr_t templates;
scaler_obj_mgr_t requests;
scaler_obj_mgr_t instances;
scaler_demand_queue_t demands;
mylock_t lock;
pthread_t threads[2];
int running;
#define SCALER_MENU_CHANGED 0x1
int flag;
} autoscaler_context_t;
extern autoscaler_context_t g_scaler_ctx;
extern int scaler_init(char* providers_file);
extern int scaler_start();
extern void* scaler_monitor(void* arg);
extern void* scaler_demand_handler(void* arg);
extern int publish_scaler_demand(scaler_demand_array_t* demands);
#endif