@@ -555,15 +555,18 @@ schedulingProfiles:
555555var _ framework.Filter = & test1 {}
556556
557557type test1 struct {
558+ tn plugins.TypedName
558559 Threshold int `json:"threshold"`
559560}
560561
561- func (f * test1 ) Type () string {
562- return test1Type
562+ func newTest1 () * test1 {
563+ return & test1 {
564+ tn : plugins.TypedName {Type : test1Type , Name : "test-1" },
565+ }
563566}
564567
565- func (f * test1 ) Name () string {
566- return "test-1"
568+ func (f * test1 ) TypedName () plugins. TypedName {
569+ return f . tn
567570}
568571
569572// Filter filters out pods that doesn't meet the filter criteria.
@@ -575,14 +578,18 @@ func (f *test1) Filter(_ context.Context, _ *types.CycleState, _ *types.LLMReque
575578var _ framework.Scorer = & test2 {}
576579var _ framework.PostCycle = & test2 {}
577580
578- type test2 struct {}
581+ type test2 struct {
582+ tn plugins.TypedName
583+ }
579584
580- func (f * test2 ) Type () string {
581- return test2Type
585+ func newTest2 () * test2 {
586+ return & test2 {
587+ tn : plugins.TypedName {Type : test2Type , Name : "test-2" },
588+ }
582589}
583590
584- func (f * test2 ) Name () string {
585- return "test-2"
591+ func (m * test2 ) TypedName () plugins. TypedName {
592+ return m . tn
586593}
587594
588595func (m * test2 ) Score (_ context.Context , _ * types.CycleState , _ * types.LLMRequest , _ []types.Pod ) map [types.Pod ]float64 {
@@ -594,14 +601,18 @@ func (m *test2) PostCycle(_ context.Context, _ *types.CycleState, _ *types.Profi
594601// compile-time type validation
595602var _ framework.Picker = & testPicker {}
596603
597- type testPicker struct {}
604+ type testPicker struct {
605+ tn plugins.TypedName
606+ }
598607
599- func (p * testPicker ) Type () string {
600- return testPickerType
608+ func newTestPicker () * testPicker {
609+ return & testPicker {
610+ tn : plugins.TypedName {Type : testPickerType , Name : "test-picker" },
611+ }
601612}
602613
603- func (p * testPicker ) Name () string {
604- return "test-picker"
614+ func (p * testPicker ) TypedName () plugins. TypedName {
615+ return p . tn
605616}
606617
607618func (p * testPicker ) Pick (_ context.Context , _ * types.CycleState , _ []* types.ScoredPod ) * types.ProfileRunResult {
@@ -611,14 +622,18 @@ func (p *testPicker) Pick(_ context.Context, _ *types.CycleState, _ []*types.Sco
611622// compile-time type validation
612623var _ framework.ProfileHandler = & testProfileHandler {}
613624
614- type testProfileHandler struct {}
625+ type testProfileHandler struct {
626+ tn plugins.TypedName
627+ }
615628
616- func (p * testProfileHandler ) Type () string {
617- return testProfileHandlerType
629+ func newTestProfileHandler () * testProfileHandler {
630+ return & testProfileHandler {
631+ tn : plugins.TypedName {Type : testProfileHandlerType , Name : "test-profile-handler" },
632+ }
618633}
619634
620- func (p * testProfileHandler ) Name () string {
621- return "test-profile-handler"
635+ func (p * testProfileHandler ) TypedName () plugins. TypedName {
636+ return p . tn
622637}
623638
624639func (p * testProfileHandler ) Pick (_ context.Context , _ * types.CycleState , _ * types.LLMRequest , _ map [string ]* framework.SchedulerProfile , _ map [string ]* types.ProfileRunResult ) map [string ]* framework.SchedulerProfile {
@@ -631,28 +646,28 @@ func (p *testProfileHandler) ProcessResults(_ context.Context, _ *types.CycleSta
631646
632647func registerTestPlugins () {
633648 plugins .Register (test1Type ,
634- func (name string , parameters json.RawMessage , handle plugins.Handle ) (plugins.Plugin , error ) {
635- result := test1 {}
636- err := json .Unmarshal (parameters , & result )
637- return & result , err
649+ func (_ string , parameters json.RawMessage , _ plugins.Handle ) (plugins.Plugin , error ) {
650+ result := newTest1 ()
651+ err := json .Unmarshal (parameters , result )
652+ return result , err
638653 },
639654 )
640655
641656 plugins .Register (test2Type ,
642- func (name string , parameters json.RawMessage , handle plugins.Handle ) (plugins.Plugin , error ) {
643- return & test2 {} , nil
657+ func (_ string , _ json.RawMessage , _ plugins.Handle ) (plugins.Plugin , error ) {
658+ return newTest2 () , nil
644659 },
645660 )
646661
647662 plugins .Register (testPickerType ,
648- func (name string , parameters json.RawMessage , handle plugins.Handle ) (plugins.Plugin , error ) {
649- return & testPicker {} , nil
663+ func (_ string , _ json.RawMessage , _ plugins.Handle ) (plugins.Plugin , error ) {
664+ return newTestPicker () , nil
650665 },
651666 )
652667
653668 plugins .Register (testProfileHandlerType ,
654- func (name string , parameters json.RawMessage , handle plugins.Handle ) (plugins.Plugin , error ) {
655- return & testProfileHandler {} , nil
669+ func (_ string , _ json.RawMessage , _ plugins.Handle ) (plugins.Plugin , error ) {
670+ return newTestProfileHandler () , nil
656671 },
657672 )
658673}
0 commit comments