You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
424 B
22 lines
424 B
package simulation |
|
|
|
import "math/rand" |
|
|
|
type CDNLogic struct{} |
|
|
|
func (c CDNLogic) Tick(props map[string]any, queue []*Request, tick int) ([]*Request, bool) { |
|
hitRate := AsFloat64("hitRate") |
|
var output []*Request |
|
|
|
for _, req := range queue { |
|
if rand.Float64() < hitRate { |
|
continue |
|
} |
|
|
|
reqCopy := *req |
|
reqCopy.Path = append(reqCopy.Path, "target-0") |
|
output = append(output, &reqCopy) |
|
} |
|
|
|
return output, true |
|
}
|
|
|