EvanLjp commented on a change in pull request #10: URL: https://github.com/apache/skywalking-satellite/pull/10#discussion_r545723958
########## File path: plugins/queue/mmap/queue.go ########## @@ -0,0 +1,192 @@ +// Licensed to 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. Apache Software Foundation (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 mmap + +import ( + "bytes" + "context" + "fmt" + "os" + "sync" + + "github.com/grandecola/mmap" + + "github.com/apache/skywalking-satellite/internal/pkg/event" + "github.com/apache/skywalking-satellite/internal/pkg/log" + "github.com/apache/skywalking-satellite/plugins/queue/api" + "github.com/apache/skywalking-satellite/plugins/queue/mmap/meta" +) + +// Queue is a memory mapped queue to store the input data. +type Queue struct { + sync.Mutex + // config + SegmentSize int `mapstructure:"segment_size"` // The size of each segment. The unit is byte. + MaxInMemSegments int `mapstructure:"max_in_mem_segments"` // The max num of segments in memory. + QueueCapacitySegments int `mapstructure:"queue_capacity_segments"` // The capacity of Queue = segment_size * queue_capacity_segments. + FlushPeriod int `mapstructure:"flush_period"` // The period flush time. The unit is ms. + FlushCeilingNum int `mapstructure:"flush_ceiling_num"` // The max number in one flush time. + MaxEventSize int `mapstructure:"max_event_size"` // The max size of the input event. + QueueDir string `mapstructure:"queue_dir"` // Contains all files in the queue. + + // running components + meta *meta.Metadata // The metadata file. + segments []*mmap.File // The data files. Review comment: the flush in only in one goroutine, so I remove the lock ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
