缓存策略支持全局的缓存条件

This commit is contained in:
GoEdgeLab
2021-05-24 19:07:33 +08:00
parent e02d95f51a
commit f037195b02
3 changed files with 216 additions and 79 deletions

View File

@@ -758,6 +758,62 @@ func (x *FindEnabledHTTPCachePolicyResponse) GetHttpCachePolicy() *HTTPCachePoli
return nil
}
// 设置缓存策略的默认条件
type UpdateHTTPCachePolicyRefsRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
HttpCachePolicyId int64 `protobuf:"varint,1,opt,name=httpCachePolicyId,proto3" json:"httpCachePolicyId,omitempty"`
RefsJSON []byte `protobuf:"bytes,2,opt,name=refsJSON,proto3" json:"refsJSON,omitempty"`
}
func (x *UpdateHTTPCachePolicyRefsRequest) Reset() {
*x = UpdateHTTPCachePolicyRefsRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_service_http_cache_policy_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UpdateHTTPCachePolicyRefsRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdateHTTPCachePolicyRefsRequest) ProtoMessage() {}
func (x *UpdateHTTPCachePolicyRefsRequest) ProtoReflect() protoreflect.Message {
mi := &file_service_http_cache_policy_proto_msgTypes[13]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use UpdateHTTPCachePolicyRefsRequest.ProtoReflect.Descriptor instead.
func (*UpdateHTTPCachePolicyRefsRequest) Descriptor() ([]byte, []int) {
return file_service_http_cache_policy_proto_rawDescGZIP(), []int{13}
}
func (x *UpdateHTTPCachePolicyRefsRequest) GetHttpCachePolicyId() int64 {
if x != nil {
return x.HttpCachePolicyId
}
return 0
}
func (x *UpdateHTTPCachePolicyRefsRequest) GetRefsJSON() []byte {
if x != nil {
return x.RefsJSON
}
return nil
}
var File_service_http_cache_policy_proto protoreflect.FileDescriptor
var file_service_http_cache_policy_proto_rawDesc = []byte{
@@ -857,61 +913,73 @@ var file_service_http_cache_policy_proto_rawDesc = []byte{
0x3d, 0x0a, 0x0f, 0x68, 0x74, 0x74, 0x70, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69,
0x63, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x62, 0x2e, 0x48, 0x54,
0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x0f, 0x68,
0x74, 0x74, 0x70, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x32, 0xce,
0x06, 0x0a, 0x16, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69,
0x63, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x7a, 0x0a, 0x1f, 0x66, 0x69, 0x6e,
0x64, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x43,
0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x12, 0x2a, 0x2e, 0x70,
0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64,
0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65,
0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69,
0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50,
0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5c, 0x0a, 0x15, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48,
0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x20,
0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61,
0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x21, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50,
0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, 0x15, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54,
0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x20, 0x2e, 0x70,
0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68,
0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e,
0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x49,
0x0a, 0x15, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68,
0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x20, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x65, 0x6c,
0x65, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69,
0x63, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x52,
0x50, 0x43, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x65, 0x0a, 0x20, 0x63, 0x6f, 0x75,
0x6e, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50,
0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x12, 0x2b, 0x2e,
0x70, 0x62, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c,
0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63,
0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x62, 0x2e,
0x52, 0x50, 0x43, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x71, 0x0a, 0x1c, 0x6c, 0x69, 0x73, 0x74, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48,
0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73,
0x12, 0x27, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65,
0x64, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69,
0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x70, 0x62, 0x2e, 0x4c,
0x69, 0x73, 0x74, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61,
0x74, 0x74, 0x70, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x22, 0x6c,
0x0a, 0x20, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68,
0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x66, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x12, 0x2c, 0x0a, 0x11, 0x68, 0x74, 0x74, 0x70, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50,
0x6f, 0x6c, 0x69, 0x63, 0x79, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x11, 0x68,
0x74, 0x74, 0x70, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x49, 0x64,
0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x66, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x02, 0x20, 0x01,
0x28, 0x0c, 0x52, 0x08, 0x72, 0x65, 0x66, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x32, 0xa1, 0x07, 0x0a,
0x16, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79,
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x7a, 0x0a, 0x1f, 0x66, 0x69, 0x6e, 0x64, 0x41,
0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63,
0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x12, 0x2a, 0x2e, 0x70, 0x62, 0x2e,
0x46, 0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54,
0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64,
0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61,
0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x7d, 0x0a, 0x20, 0x66, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c,
0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63,
0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x2b, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e,
0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68,
0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e,
0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f,
0x6c, 0x69, 0x63, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x6b, 0x0a, 0x1a, 0x66, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65,
0x64, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79,
0x12, 0x25, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65,
0x64, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e,
0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68,
0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42,
0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x6e, 0x73, 0x65, 0x12, 0x5c, 0x0a, 0x15, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54,
0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x20, 0x2e, 0x70,
0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68,
0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21,
0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61,
0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x49, 0x0a, 0x15, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x43,
0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x20, 0x2e, 0x70, 0x62, 0x2e,
0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50,
0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x70,
0x62, 0x2e, 0x52, 0x50, 0x43, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x49, 0x0a, 0x15,
0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50,
0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x20, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74,
0x65, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43,
0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x65, 0x0a, 0x20, 0x63, 0x6f, 0x75, 0x6e, 0x74,
0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61,
0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x12, 0x2b, 0x2e, 0x70, 0x62,
0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64,
0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65,
0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50,
0x43, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x71,
0x0a, 0x1c, 0x6c, 0x69, 0x73, 0x74, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54,
0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x12, 0x27,
0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48,
0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73,
0x74, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68,
0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x7d, 0x0a, 0x20, 0x66, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64,
0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x43,
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x2b, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x45,
0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50,
0x6f, 0x6c, 0x69, 0x63, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62,
0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69,
0x63, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x6b, 0x0a, 0x1a, 0x66, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48,
0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x25,
0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48,
0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x45,
0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50,
0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x51, 0x0a,
0x19, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65,
0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x66, 0x73, 0x12, 0x24, 0x2e, 0x70, 0x62, 0x2e,
0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50,
0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x66, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73,
0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -926,7 +994,7 @@ func file_service_http_cache_policy_proto_rawDescGZIP() []byte {
return file_service_http_cache_policy_proto_rawDescData
}
var file_service_http_cache_policy_proto_msgTypes = make([]protoimpl.MessageInfo, 13)
var file_service_http_cache_policy_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
var file_service_http_cache_policy_proto_goTypes = []interface{}{
(*FindAllEnabledHTTPCachePoliciesRequest)(nil), // 0: pb.FindAllEnabledHTTPCachePoliciesRequest
(*FindAllEnabledHTTPCachePoliciesResponse)(nil), // 1: pb.FindAllEnabledHTTPCachePoliciesResponse
@@ -941,13 +1009,14 @@ var file_service_http_cache_policy_proto_goTypes = []interface{}{
(*FindEnabledHTTPCachePolicyConfigResponse)(nil), // 10: pb.FindEnabledHTTPCachePolicyConfigResponse
(*FindEnabledHTTPCachePolicyRequest)(nil), // 11: pb.FindEnabledHTTPCachePolicyRequest
(*FindEnabledHTTPCachePolicyResponse)(nil), // 12: pb.FindEnabledHTTPCachePolicyResponse
(*HTTPCachePolicy)(nil), // 13: pb.HTTPCachePolicy
(*RPCSuccess)(nil), // 14: pb.RPCSuccess
(*RPCCountResponse)(nil), // 15: pb.RPCCountResponse
(*UpdateHTTPCachePolicyRefsRequest)(nil), // 13: pb.UpdateHTTPCachePolicyRefsRequest
(*HTTPCachePolicy)(nil), // 14: pb.HTTPCachePolicy
(*RPCSuccess)(nil), // 15: pb.RPCSuccess
(*RPCCountResponse)(nil), // 16: pb.RPCCountResponse
}
var file_service_http_cache_policy_proto_depIdxs = []int32{
13, // 0: pb.FindAllEnabledHTTPCachePoliciesResponse.cachePolicies:type_name -> pb.HTTPCachePolicy
13, // 1: pb.FindEnabledHTTPCachePolicyResponse.httpCachePolicy:type_name -> pb.HTTPCachePolicy
14, // 0: pb.FindAllEnabledHTTPCachePoliciesResponse.cachePolicies:type_name -> pb.HTTPCachePolicy
14, // 1: pb.FindEnabledHTTPCachePolicyResponse.httpCachePolicy:type_name -> pb.HTTPCachePolicy
0, // 2: pb.HTTPCachePolicyService.findAllEnabledHTTPCachePolicies:input_type -> pb.FindAllEnabledHTTPCachePoliciesRequest
2, // 3: pb.HTTPCachePolicyService.createHTTPCachePolicy:input_type -> pb.CreateHTTPCachePolicyRequest
4, // 4: pb.HTTPCachePolicyService.updateHTTPCachePolicy:input_type -> pb.UpdateHTTPCachePolicyRequest
@@ -956,16 +1025,18 @@ var file_service_http_cache_policy_proto_depIdxs = []int32{
7, // 7: pb.HTTPCachePolicyService.listEnabledHTTPCachePolicies:input_type -> pb.ListEnabledHTTPCachePoliciesRequest
9, // 8: pb.HTTPCachePolicyService.findEnabledHTTPCachePolicyConfig:input_type -> pb.FindEnabledHTTPCachePolicyConfigRequest
11, // 9: pb.HTTPCachePolicyService.findEnabledHTTPCachePolicy:input_type -> pb.FindEnabledHTTPCachePolicyRequest
1, // 10: pb.HTTPCachePolicyService.findAllEnabledHTTPCachePolicies:output_type -> pb.FindAllEnabledHTTPCachePoliciesResponse
3, // 11: pb.HTTPCachePolicyService.createHTTPCachePolicy:output_type -> pb.CreateHTTPCachePolicyResponse
14, // 12: pb.HTTPCachePolicyService.updateHTTPCachePolicy:output_type -> pb.RPCSuccess
14, // 13: pb.HTTPCachePolicyService.deleteHTTPCachePolicy:output_type -> pb.RPCSuccess
15, // 14: pb.HTTPCachePolicyService.countAllEnabledHTTPCachePolicies:output_type -> pb.RPCCountResponse
8, // 15: pb.HTTPCachePolicyService.listEnabledHTTPCachePolicies:output_type -> pb.ListEnabledHTTPCachePoliciesResponse
10, // 16: pb.HTTPCachePolicyService.findEnabledHTTPCachePolicyConfig:output_type -> pb.FindEnabledHTTPCachePolicyConfigResponse
12, // 17: pb.HTTPCachePolicyService.findEnabledHTTPCachePolicy:output_type -> pb.FindEnabledHTTPCachePolicyResponse
10, // [10:18] is the sub-list for method output_type
2, // [2:10] is the sub-list for method input_type
13, // 10: pb.HTTPCachePolicyService.updateHTTPCachePolicyRefs:input_type -> pb.UpdateHTTPCachePolicyRefsRequest
1, // 11: pb.HTTPCachePolicyService.findAllEnabledHTTPCachePolicies:output_type -> pb.FindAllEnabledHTTPCachePoliciesResponse
3, // 12: pb.HTTPCachePolicyService.createHTTPCachePolicy:output_type -> pb.CreateHTTPCachePolicyResponse
15, // 13: pb.HTTPCachePolicyService.updateHTTPCachePolicy:output_type -> pb.RPCSuccess
15, // 14: pb.HTTPCachePolicyService.deleteHTTPCachePolicy:output_type -> pb.RPCSuccess
16, // 15: pb.HTTPCachePolicyService.countAllEnabledHTTPCachePolicies:output_type -> pb.RPCCountResponse
8, // 16: pb.HTTPCachePolicyService.listEnabledHTTPCachePolicies:output_type -> pb.ListEnabledHTTPCachePoliciesResponse
10, // 17: pb.HTTPCachePolicyService.findEnabledHTTPCachePolicyConfig:output_type -> pb.FindEnabledHTTPCachePolicyConfigResponse
12, // 18: pb.HTTPCachePolicyService.findEnabledHTTPCachePolicy:output_type -> pb.FindEnabledHTTPCachePolicyResponse
15, // 19: pb.HTTPCachePolicyService.updateHTTPCachePolicyRefs:output_type -> pb.RPCSuccess
11, // [11:20] is the sub-list for method output_type
2, // [2:11] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
@@ -1135,6 +1206,18 @@ func file_service_http_cache_policy_proto_init() {
return nil
}
}
file_service_http_cache_policy_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateHTTPCachePolicyRefsRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@@ -1142,7 +1225,7 @@ func file_service_http_cache_policy_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_service_http_cache_policy_proto_rawDesc,
NumEnums: 0,
NumMessages: 13,
NumMessages: 14,
NumExtensions: 0,
NumServices: 1,
},
@@ -1184,6 +1267,8 @@ type HTTPCachePolicyServiceClient interface {
FindEnabledHTTPCachePolicyConfig(ctx context.Context, in *FindEnabledHTTPCachePolicyConfigRequest, opts ...grpc.CallOption) (*FindEnabledHTTPCachePolicyConfigResponse, error)
// 查找单个缓存策略信息
FindEnabledHTTPCachePolicy(ctx context.Context, in *FindEnabledHTTPCachePolicyRequest, opts ...grpc.CallOption) (*FindEnabledHTTPCachePolicyResponse, error)
// 设置缓存策略的默认条件
UpdateHTTPCachePolicyRefs(ctx context.Context, in *UpdateHTTPCachePolicyRefsRequest, opts ...grpc.CallOption) (*RPCSuccess, error)
}
type hTTPCachePolicyServiceClient struct {
@@ -1266,6 +1351,15 @@ func (c *hTTPCachePolicyServiceClient) FindEnabledHTTPCachePolicy(ctx context.Co
return out, nil
}
func (c *hTTPCachePolicyServiceClient) UpdateHTTPCachePolicyRefs(ctx context.Context, in *UpdateHTTPCachePolicyRefsRequest, opts ...grpc.CallOption) (*RPCSuccess, error) {
out := new(RPCSuccess)
err := c.cc.Invoke(ctx, "/pb.HTTPCachePolicyService/updateHTTPCachePolicyRefs", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// HTTPCachePolicyServiceServer is the server API for HTTPCachePolicyService service.
type HTTPCachePolicyServiceServer interface {
// 获取所有可用策略
@@ -1284,6 +1378,8 @@ type HTTPCachePolicyServiceServer interface {
FindEnabledHTTPCachePolicyConfig(context.Context, *FindEnabledHTTPCachePolicyConfigRequest) (*FindEnabledHTTPCachePolicyConfigResponse, error)
// 查找单个缓存策略信息
FindEnabledHTTPCachePolicy(context.Context, *FindEnabledHTTPCachePolicyRequest) (*FindEnabledHTTPCachePolicyResponse, error)
// 设置缓存策略的默认条件
UpdateHTTPCachePolicyRefs(context.Context, *UpdateHTTPCachePolicyRefsRequest) (*RPCSuccess, error)
}
// UnimplementedHTTPCachePolicyServiceServer can be embedded to have forward compatible implementations.
@@ -1314,6 +1410,9 @@ func (*UnimplementedHTTPCachePolicyServiceServer) FindEnabledHTTPCachePolicyConf
func (*UnimplementedHTTPCachePolicyServiceServer) FindEnabledHTTPCachePolicy(context.Context, *FindEnabledHTTPCachePolicyRequest) (*FindEnabledHTTPCachePolicyResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method FindEnabledHTTPCachePolicy not implemented")
}
func (*UnimplementedHTTPCachePolicyServiceServer) UpdateHTTPCachePolicyRefs(context.Context, *UpdateHTTPCachePolicyRefsRequest) (*RPCSuccess, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateHTTPCachePolicyRefs not implemented")
}
func RegisterHTTPCachePolicyServiceServer(s *grpc.Server, srv HTTPCachePolicyServiceServer) {
s.RegisterService(&_HTTPCachePolicyService_serviceDesc, srv)
@@ -1463,6 +1562,24 @@ func _HTTPCachePolicyService_FindEnabledHTTPCachePolicy_Handler(srv interface{},
return interceptor(ctx, in, info, handler)
}
func _HTTPCachePolicyService_UpdateHTTPCachePolicyRefs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdateHTTPCachePolicyRefsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HTTPCachePolicyServiceServer).UpdateHTTPCachePolicyRefs(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/pb.HTTPCachePolicyService/UpdateHTTPCachePolicyRefs",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HTTPCachePolicyServiceServer).UpdateHTTPCachePolicyRefs(ctx, req.(*UpdateHTTPCachePolicyRefsRequest))
}
return interceptor(ctx, in, info, handler)
}
var _HTTPCachePolicyService_serviceDesc = grpc.ServiceDesc{
ServiceName: "pb.HTTPCachePolicyService",
HandlerType: (*HTTPCachePolicyServiceServer)(nil),
@@ -1499,6 +1616,10 @@ var _HTTPCachePolicyService_serviceDesc = grpc.ServiceDesc{
MethodName: "findEnabledHTTPCachePolicy",
Handler: _HTTPCachePolicyService_FindEnabledHTTPCachePolicy_Handler,
},
{
MethodName: "updateHTTPCachePolicyRefs",
Handler: _HTTPCachePolicyService_UpdateHTTPCachePolicyRefs_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "service_http_cache_policy.proto",

View File

@@ -30,6 +30,9 @@ service HTTPCachePolicyService {
// 查找单个缓存策略信息
rpc findEnabledHTTPCachePolicy (FindEnabledHTTPCachePolicyRequest) returns (FindEnabledHTTPCachePolicyResponse);
// 设置缓存策略的默认条件
rpc updateHTTPCachePolicyRefs (UpdateHTTPCachePolicyRefsRequest) returns (RPCSuccess);
}
// 获取所有可用策略
@@ -105,4 +108,10 @@ message FindEnabledHTTPCachePolicyRequest {
message FindEnabledHTTPCachePolicyResponse {
HTTPCachePolicy httpCachePolicy = 1;
}
// 设置缓存策略的默认条件
message UpdateHTTPCachePolicyRefsRequest {
int64 httpCachePolicyId = 1;
bytes refsJSON = 2;
}

View File

@@ -6,7 +6,7 @@ import (
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
)
// 缓存策略配置
// HTTPCachePolicy 缓存策略配置
type HTTPCachePolicy struct {
Id int64 `yaml:"id" json:"id"`
IsOn bool `yaml:"isOn" json:"isOn"` // 是否开启
@@ -21,14 +21,14 @@ type HTTPCachePolicy struct {
MinLife *shared.TimeDuration `yaml:"minLife" json:"minLife"` // 最小有效期 TODO 需要实现
MaxLife *shared.TimeDuration `yaml:"maxLife" json:"maxLife"` // 最大有效期 TODO 需要实现
CacheRefs []*HTTPCacheRef `yaml:"cacheRefs" json:"cacheRefs"` // 缓存配置
capacity int64
maxSize int64
}
// 校验
// Init 校验
func (this *HTTPCachePolicy) Init() error {
var err error
if this.Capacity != nil {
this.capacity = this.Capacity.Bytes()
}
@@ -37,20 +37,27 @@ func (this *HTTPCachePolicy) Init() error {
this.maxSize = this.MaxSize.Bytes()
}
return err
for _, cacheRef := range this.CacheRefs {
err := cacheRef.Init()
if err != nil {
return err
}
}
return nil
}
// 容量
// CapacityBytes 容量
func (this *HTTPCachePolicy) CapacityBytes() int64 {
return this.capacity
}
// 单个缓存最大尺寸
// MaxSizeBytes 单个缓存最大尺寸
func (this *HTTPCachePolicy) MaxSizeBytes() int64 {
return this.maxSize
}
// 对比Policy是否有变化
// IsSame 对比Policy是否有变化
func (this *HTTPCachePolicy) IsSame(anotherPolicy *HTTPCachePolicy) bool {
policyJSON1, err := json.Marshal(this)
if err != nil {