syntax = "proto3";
option go_package = "./pb";

package pb;

import "models/model_reverse_proxy.proto";
import "models/rpc_messages.proto";

service ReverseProxyService {
	// 创建反向代理
	rpc createReverseProxy (CreateReverseProxyRequest) returns (CreateReverseProxyResponse);

	// 查找反向代理
	rpc findEnabledReverseProxy (FindEnabledReverseProxyRequest) returns (FindEnabledReverseProxyResponse);

	// 查找反向代理配置
	rpc findEnabledReverseProxyConfig (FindEnabledReverseProxyConfigRequest) returns (FindEnabledReverseProxyConfigResponse);

	// 修改反向代理的调度算法
	rpc updateReverseProxyScheduling (UpdateReverseProxySchedulingRequest) returns (RPCSuccess);

	// 修改主要源站信息
	rpc updateReverseProxyPrimaryOrigins (UpdateReverseProxyPrimaryOriginsRequest) returns (RPCSuccess);

	// 修改备用源站信息
	rpc updateReverseProxyBackupOrigins (UpdateReverseProxyBackupOriginsRequest) returns (RPCSuccess);

	// 修改反向代理设置
	rpc updateReverseProxy (UpdateReverseProxyRequest) returns (RPCSuccess);
}

// 创建反向代理
message CreateReverseProxyRequest {
	bytes schedulingJSON = 1;
	bytes primaryOriginsJSON = 2;
	bytes backupOriginsJSON = 3;
}

message CreateReverseProxyResponse {
	int64 reverseProxyId = 1;
}

// 查找反向代理
message FindEnabledReverseProxyRequest {
	int64 reverseProxyId = 1;
}

message FindEnabledReverseProxyResponse {
	ReverseProxy reverseProxy = 1;
}

// 查找反向代理配置
message FindEnabledReverseProxyConfigRequest {
	int64 reverseProxyId = 1;
}

message FindEnabledReverseProxyConfigResponse {
	bytes reverseProxyJSON = 1;
}

// 修改反向代理调度算法
message UpdateReverseProxySchedulingRequest {
	int64 reverseProxyId = 1;
	bytes schedulingJSON = 2;
}

// 修改主要源站信息
message UpdateReverseProxyPrimaryOriginsRequest {
	int64 reverseProxyId = 1;
	bytes originsJSON = 2;
}

// 修改备用源站信息
message UpdateReverseProxyBackupOriginsRequest {
	int64 reverseProxyId = 1;
	bytes originsJSON = 2;
}

// 修改反向代理设置
message UpdateReverseProxyRequest {
	int64 reverseProxyId = 1;
	int32 requestHostType = 6;
	string requestHost = 2;
	string requestURI = 3;
	string stripPrefix = 4;
	bool autoFlush = 5;
	repeated string addHeaders = 7;
	bytes connTimeoutJSON = 8;
	bytes readTimeoutJSON = 9;
	bytes idleTimeoutJSON = 10;
	int32 maxConns = 11;
	int32 maxIdleConns = 12;
	bytes proxyProtocolJSON = 13;
}