EvanLjp commented on a change in pull request #22: URL: https://github.com/apache/skywalking-satellite/pull/22#discussion_r567250640
########## File path: plugins/queue/memory/queue.go ########## @@ -0,0 +1,121 @@ +// 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 memory + +import ( + "fmt" + "sync/atomic" + + "github.com/apache/skywalking-satellite/internal/pkg/config" + "github.com/apache/skywalking-satellite/internal/satellite/event" + "github.com/apache/skywalking-satellite/plugins/queue/api" + "github.com/apache/skywalking-satellite/protocol/gen-codes/satellite/protocol" +) + +const ( + Name = "memory-queue" + // discard strategy + lostOldestOne = "LOST_THE_OLDEST_ONE" + lostNewOne = "LOST_THE_NEW_ONE" +) + +type Queue struct { + config.CommonFields + // config + EventBufferSize int64 `mapstructure:"event_buffer_size"` // The maximum buffer event size. + DiscardStrategy string `mapstructure:"discard_strategy"` // The discard strategy. + + // components + queue []*protocol.Event + // The position continuously increasing, but don't worry, it can run for another 1067519911 days at 10W OPS. + readPos int64 + writePos int64 + count int64 +} + +func (q *Queue) Name() string { + return Name +} + +func (q *Queue) Description() string { + return "this is a memory queue to buffer the input event." +} + +func (q *Queue) DefaultConfig() string { + return ` +# The maximum buffer event size. +event_buffer_size: 5000 +# The discard strategy when facing the full condition. +# There are 2 strategies, which are LOST_THE_OLDEST_ONE and LOST_THE_NEW_ONE. +discard_strategy: LOST_THE_OLDEST_ONE Review comment: thx ########## File path: plugins/queue/memory/queue.go ########## @@ -0,0 +1,121 @@ +// 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 memory + +import ( + "fmt" + "sync/atomic" + + "github.com/apache/skywalking-satellite/internal/pkg/config" + "github.com/apache/skywalking-satellite/internal/satellite/event" + "github.com/apache/skywalking-satellite/plugins/queue/api" + "github.com/apache/skywalking-satellite/protocol/gen-codes/satellite/protocol" +) + +const ( + Name = "memory-queue" + // discard strategy + lostOldestOne = "LOST_THE_OLDEST_ONE" + lostNewOne = "LOST_THE_NEW_ONE" +) + +type Queue struct { + config.CommonFields + // config + EventBufferSize int64 `mapstructure:"event_buffer_size"` // The maximum buffer event size. + DiscardStrategy string `mapstructure:"discard_strategy"` // The discard strategy. + + // components + queue []*protocol.Event + // The position continuously increasing, but don't worry, it can run for another 1067519911 days at 10W OPS. + readPos int64 + writePos int64 + count int64 +} + +func (q *Queue) Name() string { + return Name +} + +func (q *Queue) Description() string { + return "this is a memory queue to buffer the input event." +} + +func (q *Queue) DefaultConfig() string { + return ` +# The maximum buffer event size. +event_buffer_size: 5000 +# The discard strategy when facing the full condition. +# There are 2 strategies, which are LOST_THE_OLDEST_ONE and LOST_THE_NEW_ONE. +discard_strategy: LOST_THE_OLDEST_ONE Review comment: fixed ---------------------------------------------------------------- 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]
