package dialer import ( "fmt" "time" "github.com/daeuniverse/dae/pkg/config_parser" ) const ( AnnotationKey_AddLatency = "add_latency" ) type Annotation struct { AddLatency time.Duration } func NewAnnotation(annotation []*config_parser.Param) (*Annotation, error) { var anno Annotation for _, param := range annotation { switch param.Key { case AnnotationKey_AddLatency: latency, err := time.ParseDuration(param.Val) if err != nil { return nil, fmt.Errorf("incorrect latency format: %w", err) } // Only the first setting is valid. if anno.AddLatency == 0 { anno.AddLatency = latency } default: return nil, fmt.Errorf("unknown filter annotation: %v", param.Key) } } return &anno, nil }