func (scw *snapCleanupWorker) removeItem() *snapCleanupRequest {
	scw.Mutex.Lock()
	defer scw.Mutex.Unlock()
	if len(scw.Queue) == 0 {
		return nil
	}
	reqx := heap.Pop(&scw.Queue)
	req := reqx.(snapCleanupRequest)
	return &req
}
removeItem removes the top priority item so it can be worked on
package service
import (
	"container/heap"
	"context"
	"fmt"
	"sort"
	"strings"
	"sync"
	"time"
	pmax "github.com/dell/gopowermax"
	types "github.com/dell/gopowermax/types/v90"
	log "github.com/sirupsen/logrus"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
)
const (
	TempSnap       = "CSI_TEMP_SNAP"
	Defined        = "Defined"
	Link           = "Link"
	Unlink         = "Unlink"
	Rename         = "Rename"
	MaxUnlinkCount = 5
)
var cleanupStarted = false
var licenseCached = false
var symmRepCapabilities *types.SymReplicationCapabilities
var mutex sync.Mutex
var snapCleaner *snapCleanupWorker
type SnapSession struct {
	Source     string
	Name       string
	Generation int64
	Expired    bool
	Target     []types.SnapTarget
}
type snapCleanupWorker struct {
	PollingInterval time.Duration
	Mutex           sync.Mutex
	Queue           snapCleanupQueue
	MaxRetries      int
}
type snapCleanupRequest struct {
	symmetrixID string
	snapshotID  string
	volumeID    string
	requestID   string
	retries     int
}
type snapCleanupQueue []*snapCleanupRequest
func (q snapCleanupQueue) Len() int {
	return len(q)
}
func (q snapCleanupQueue) Less(i, j int) bool {
	return false
}
func (q snapCleanupQueue) Swap(i, j int) {
	q[i], q[j] = q[j], q[i]
}
func (q *snapCleanupQueue) Push(x interface{}) {
	req := x.(*snapCleanupRequest)
	n := len(*q)
	*q = append(*q, req)
	heap.Fix(q, n)
}
func (q *snapCleanupQueue) Pop() interface{} {
	old := *q
	n := len(old)
	req := old[n-1]
	*q = old[0 : n-1]
	return *req
}
func (req *snapCleanupRequest) fields() map[string]interface{} {
	fields := map[string]interface{}{
		"SymmetrixID": req.symmetrixID,
		"SnapshotID":  req.snapshotID,
		"VolumeID":    req.volumeID,
		"RequestID":   req.requestID,
	}
	return fields
}
func (scw *snapCleanupWorker) getQueueLen() int {
	scw.Mutex.Lock()
	defer scw.Mutex.Unlock()
	return len(scw.Queue)
}
func (scw *snapCleanupWorker) requestCleanup(req *snapCleanupRequest) {
	fields := req.fields()
	scw.Mutex.Lock()
	defer scw.Mutex.Unlock()
	for i := range scw.Queue {
		if scw.Queue[i].snapshotID == req.snapshotID && scw.Queue[i].symmetrixID == req.symmetrixID {
			log.Warningf("Snapshot ID: %s already present in the deletion queue", req.snapshotID)
			return
		}
	}
	heap.Push(&scw.Queue, req)
	log.WithFields(fields).Debug("Queued for Deletion")
}
func (scw *snapCleanupWorker) queueForRetry(req *snapCleanupRequest) {
	scw.Mutex.Lock()
	defer scw.Mutex.Unlock()
	heap.Push(&scw.Queue, req)
}