github.com/wfusion/gofusion@v1.1.14/test/cache/cases/types.go (about)

     1  package cases
     2  
     3  import (
     4  	"context"
     5  	"reflect"
     6  
     7  	"github.com/wfusion/gofusion/common/utils"
     8  	"github.com/wfusion/gofusion/common/utils/serialize"
     9  	"github.com/wfusion/gofusion/test/internal/mock"
    10  )
    11  
    12  var (
    13  	// randomObjCallbackType FIXME: should not be deleted to avoid compiler optimized
    14  	randomObjCallbackType = reflect.TypeOf(randomObjCallback)
    15  	// commonObjCallbackType FIXME: should not be deleted to avoid compiler optimized
    16  	commonObjCallbackType = reflect.TypeOf(commonObjCallback)
    17  )
    18  
    19  const (
    20  	local                         = "local"
    21  	localWithoutLog               = "local_without_log"
    22  	localWithCallback             = "local_with_cb"
    23  	localWithSerialize            = "local_with_serialize"
    24  	localWithSerializeAndCompress = "local_with_serialize_and_compress"
    25  	localWithZstdCompress         = "local_with_zstd_compress"
    26  	localWithZlibCompress         = "local_with_zlib_compress"
    27  	localWithS2Compress           = "local_with_s2_compress"
    28  	localWithGzipCompress         = "local_with_gzip_compress"
    29  	localWithDeflateCompress      = "local_with_deflate_compress"
    30  
    31  	redis                    = "redis"
    32  	redisJson                = "redis_json"
    33  	redisWithZstdCompress    = "redis_with_zstd_compress"
    34  	redisWithZlibCompress    = "redis_with_zlib_compress"
    35  	redisWithS2Compress      = "redis_with_s2_compress"
    36  	redisWithGzipCompress    = "redis_with_gzip_compress"
    37  	redisWithDeflateCompress = "redis_with_deflate_compress"
    38  )
    39  
    40  func randomObjCallback(ctx context.Context, missed []string) (
    41  	rs map[string]*mock.RandomObj, opts []utils.OptionExtender) {
    42  	valList := mock.GenObjListBySerializeAlgo(serialize.AlgorithmGob, len(missed)).([]*mock.RandomObj)
    43  	rs = make(map[string]*mock.RandomObj, len(missed))
    44  	for idx, mis := range missed {
    45  		rs[mis] = valList[idx]
    46  	}
    47  	return
    48  }
    49  
    50  func commonObjCallback(ctx context.Context, missed []string) (
    51  	rs map[string]*mock.CommonObj, opts []utils.OptionExtender) {
    52  	valList := mock.GenObjListBySerializeAlgo(serialize.AlgorithmJson, len(missed)).([]*mock.CommonObj)
    53  	rs = make(map[string]*mock.CommonObj, len(missed))
    54  	for idx, mis := range missed {
    55  		rs[mis] = valList[idx]
    56  	}
    57  	return
    58  }