@@ -90,25 +90,25 @@ func (s ServerID) String() string {
90
90
}
91
91
92
92
// compile-time type validation
93
- var _ types.StateData = & schedulingContextState {}
93
+ var _ types.StateData = & SchedulingContextState {}
94
94
95
- // This is the state of this plugin to be used during a scheduling cycle.
96
- type schedulingContextState struct {
95
+ // SchedulingContextState is the state of this plugin to be used during a scheduling cycle.
96
+ type SchedulingContextState struct {
97
97
// PrefixHashes is a list of prefix hashes of the request prompt broken into blocks.
98
98
PrefixHashes []BlockHash
99
99
// A map of server to its longest prefix cache match length.
100
100
PrefixCacheServers map [ServerID ]int
101
101
}
102
102
103
- func (s * schedulingContextState ) Clone () types.StateData {
103
+ func (s * SchedulingContextState ) Clone () types.StateData {
104
104
prefixHashes := make ([]BlockHash , len (s .PrefixHashes ))
105
105
copy (prefixHashes , s .PrefixHashes )
106
106
prefixCacheServers := make (map [ServerID ]int , len (s .PrefixCacheServers ))
107
107
for key , value := range s .PrefixCacheServers {
108
108
prefixCacheServers [key ] = value
109
109
}
110
110
111
- return & schedulingContextState {
111
+ return & SchedulingContextState {
112
112
PrefixHashes : prefixHashes ,
113
113
PrefixCacheServers : prefixCacheServers ,
114
114
}
@@ -171,7 +171,7 @@ func (m *Plugin) Score(ctx context.Context, cycleState *types.CycleState, reques
171
171
loggerTrace := log .FromContext (ctx ).V (logutil .TRACE )
172
172
// pre score step, hashing prompt and find longest prefix match.
173
173
hashes := hashPrompt (ctx , request , m .HashBlockSize , m .MaxPrefixBlocksToMatch )
174
- state := & schedulingContextState {
174
+ state := & SchedulingContextState {
175
175
PrefixHashes : hashes ,
176
176
PrefixCacheServers : m .matchLongestPrefix (ctx , hashes ),
177
177
}
@@ -235,15 +235,15 @@ func (m *Plugin) matchLongestPrefix(ctx context.Context, hashes []BlockHash) map
235
235
return res
236
236
}
237
237
238
- // getPrefixState returns the cycle state as a schedulingContextState .
239
- func (m * Plugin ) getPrefixState (cycleState * types.CycleState ) (* schedulingContextState , error ) {
238
+ // getPrefixState returns the cycle state as a SchedulingContextState .
239
+ func (m * Plugin ) getPrefixState (cycleState * types.CycleState ) (* SchedulingContextState , error ) {
240
240
prefixStateKey := types .StateKey (m .Type ())
241
241
state , err := cycleState .Read (prefixStateKey )
242
242
if err != nil {
243
243
return nil , fmt .Errorf ("failed reading %q from CycleState: %w" , prefixStateKey , err )
244
244
}
245
245
246
- prefixSchedulingState , ok := state .(* schedulingContextState )
246
+ prefixSchedulingState , ok := state .(* SchedulingContextState )
247
247
if ! ok {
248
248
return nil , fmt .Errorf ("invalid Prefix state, got type %T" , state )
249
249
}
0 commit comments