-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: wip! add axis package for timeline generation * style: lint * feat(timeline): wip! update masking model * feat(timeline): wip! activate mask * feat(timeline): wip! generate valid dates * style: lint * feat(timeline): add constraints * feat(timeline): update json schema * chore: update docker-compose commands * feat(timeline): add error handling * feat(timeline): set max retry + onError reject or nullify * docs(timeline): update changelog * feat(timeline): default value * feat(timeline): fix unit test * test(timeline): add venom tests * docs(timeline): update readme * docs(timeline): fix readme * fix(timeline): nil pointer exception * fix(timeline): nil pointer exception * docs(timeline): fix bullet alignment
- Loading branch information
1 parent
7206233
commit 1b6d7f6
Showing
12 changed files
with
977 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Copyright (C) 2024 CGI France | ||
// | ||
// This file is part of PIMO. | ||
// | ||
// PIMO is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// PIMO is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with PIMO. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package axis | ||
|
||
type ConstraintBehavior int | ||
|
||
const ( | ||
Reject ConstraintBehavior = iota | ||
Nullify | ||
Replace | ||
// Default | ||
) | ||
|
||
type Constraint interface { | ||
Validate(value int64, points map[string]*int64) bool | ||
Behavior() ConstraintBehavior | ||
} | ||
|
||
type constraint struct { | ||
behavior ConstraintBehavior | ||
reference string | ||
} | ||
|
||
func (c constraint) Behavior() ConstraintBehavior { | ||
return c.behavior | ||
} | ||
|
||
func LowerThan(reference string, behavior ConstraintBehavior) Constraint { | ||
return lowerThan{ | ||
constraint: constraint{ | ||
behavior: behavior, | ||
reference: reference, | ||
}, | ||
} | ||
} | ||
|
||
type lowerThan struct { | ||
constraint | ||
} | ||
|
||
func (lt lowerThan) Validate(value int64, points map[string]*int64) bool { | ||
ref := points[lt.reference] | ||
|
||
if ref == nil { | ||
return true | ||
} | ||
|
||
return value < *ref | ||
} | ||
|
||
func GreaterThan(reference string, behavior ConstraintBehavior) Constraint { | ||
return greaterThan{ | ||
constraint: constraint{ | ||
behavior: behavior, | ||
reference: reference, | ||
}, | ||
} | ||
} | ||
|
||
type greaterThan struct { | ||
constraint | ||
} | ||
|
||
func (gt greaterThan) Validate(value int64, points map[string]*int64) bool { | ||
ref := points[gt.reference] | ||
|
||
if ref == nil { | ||
return true | ||
} | ||
|
||
return value > *ref | ||
} |
Oops, something went wrong.