yuluo-yx commented on code in PR #11: URL: https://github.com/apache/hertzbeat-collector-go/pull/11#discussion_r2330425279
########## internal/collector/common/dispatcher/time_wheel.go: ########## @@ -0,0 +1,223 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package dispatcher + +import ( + "context" + "fmt" + "sync" + "time" + + jobtypes "hertzbeat.apache.org/hertzbeat-collector-go/internal/collector/common/types/job" + "hertzbeat.apache.org/hertzbeat-collector-go/internal/util/logger" +) + +// TimeDispatch manages time-based job scheduling using a hashed wheel timer +type TimeDispatch struct { + logger logger.Logger + wheelTimer HashedWheelTimer + commonDispatcher MetricsTaskDispatcher + cyclicTasks sync.Map // map[int64]*jobtypes.Timeout for cyclic jobs + tempTasks sync.Map // map[int64]*jobtypes.Timeout for one-time jobs + ctx context.Context Review Comment: 同上,ctx 不应该作为结构体的属性 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
