Closed muzarski closed 9 months ago
v2:
ParamWrapper
-> GenericParam
ParamWrapperImpl
-> TypedParam
Param
-> ParamImpl
ParamImpl
implementations in the commentsv3: rebased on top of master
@piodul should I squash some of the commits (e.g. porting fields from ParamImpl
implementations to TypedParam
) before mergning?
@piodul should I squash some of the commits (e.g. porting fields from
ParamImpl
implementations toTypedParam
) before mergning?
No, I think the commits are fine as they are right now.
Motivation
Before the changes, a lot of common logic (and fields) would be repeated in implementations of
Param
trait. I found it annoying when implementing yet another type of parameters (DistributionParam
- https://github.com/scylladb/cql-stress/pull/48) to repeat the same boilerplate code.Simple examples:
required
,prefix
,satisfied
,desc
fields used by bothSimpleParam
andMultiParam
Param
trait - the exact same implementations for both types of parametersprefix
.This PR introduces a new generic type
ParamWrapperImpl<P: Param>
which wraps theParam
implementations. The logic shared between all of the types of parameters is extracted to the wrapping type.Changes
ParamWrapperImpl<P: Param>
type which wraps the common logic of the parametersParamWrapper
trait implemented (once) by all of the genericParamWrapperImpl
types. This trait is needed so we can store bothParamWrapperImpl<SimpleParam>
andParamWrapperImpl<MultiParam>
in common collections used by the parser.Param
implementations toParamWrapperImpl
ParamCell
type used by the parser fromRc<RefCell<dyn Param>>
toRc<RefCell<dyn ParamWrapper>>
. Adjusted usages of the type.Notes
Please review this PR before https://github.com/scylladb/cql-stress/pull/48, since the options implemented in the mentioned PR base on the changes introduced by this PR.