Documentation ¶
Overview ¶
Package git contains the management of changes' pipelines as git abstractions It's the main actor on performing CRUD actions over remote
Index ¶
- func AreCompatible(chg, otherChg *Change) bool
- func Overrides(chg, otherChg *Change) bool
- type Branch
- type Change
- func (chg *Change) Equals(otherChg *Change) bool
- func (chg *Change) FromMap(Map map[string]interface{}) error
- func (chg *Change) GetId() int64
- func (chg *Change) SQLColumns() []string
- func (chg *Change) SQLTable() string
- func (chg *Change) SetId(id int64)
- func (chg *Change) SetOption(key integrity.OptionKey, val interface{}) error
- func (chg *Change) SetValue(val interface{}) (err error)
- func (chg *Change) ToMap() map[string]interface{}
- func (chg *Change) Validate() (err error)
- func (chg *Change) Value() interface{}
- type Collaborator
- type Commit
- func Comm(ctx context.Context, db *sqlx.DB, branchName integrity.BranchName) ([]*Commit, error)
- func CommitById(ctx context.Context, db *sqlx.DB, id int64) (*Commit, error)
- func CommitFromCloser(body io.ReadCloser) (comm *Commit, err error)
- func CommitFromMap(Map map[string]interface{}) (comm *Commit, err error)
- func NewCommit(changes []*Change) *Commit
- func (comm *Commit) Branch(ctx context.Context, db *sqlx.DB) (*Branch, error)
- func (comm *Commit) ColumnNames() (colNames []integrity.ColumnName)
- func (comm *Commit) FetchChanges(ctx context.Context, db *sqlx.DB) (err error)
- func (comm *Commit) GetId() int64
- func (comm *Commit) GroupBy(strategy changesMatcher) (grpChanges [][]*Change)
- func (comm *Commit) Options() (opts Options, err error)
- func (comm *Commit) SQLColumns() []string
- func (comm *Commit) SQLTable() string
- func (comm *Commit) SetId(id int64)
- func (comm *Commit) TableName() (tableName integrity.TableName, err error)
- func (comm *Commit) ToMap() map[string]interface{}
- func (comm *Commit) Type() (commType integrity.CRUD, err error)
- func (comm *Commit) Unmarshal(data interface{}, format string) error
- type Community
- type History
- type Index
- func (idx *Index) Add(ctx context.Context, db *sqlx.DB, chg *Change) error
- func (idx *Index) Commit(ctx context.Context, db *sqlx.DB) ([]*Commit, error)
- func (idx *Index) FetchChanges(ctx context.Context, db *sqlx.DB) (err error)
- func (idx *Index) FetchUncommittedChanges(ctx context.Context, db *sqlx.DB) (err error)
- func (idx *Index) GetId() int64
- func (idx *Index) Rm(ctx context.Context, db *sqlx.DB, chg *Change) error
- func (idx *Index) SQLColumns() []string
- func (idx *Index) SQLTable() string
- func (idx *Index) SetId(id int64)
- type Member
- type Options
- type Owner
- func (own *Owner) Create(ctx context.Context, comm *Commit) (*Commit, error)
- func (own *Owner) Delegate(ctx context.Context, community *Community, schName integrity.SchemaName, ...) (*PullRequest, error)
- func (own *Owner) Delete(ctx context.Context, comm *Commit) (*Commit, error)
- func (own *Owner) Merge(ctx context.Context, pR *PullRequest)
- func (own *Owner) Orchestrate(ctx context.Context, community *Community, schName integrity.SchemaName, ...)
- func (own *Owner) Retrieve(ctx context.Context, comm *Commit) (*Commit, error)
- func (own *Owner) ReviewPRCommit(sch *schema.Schema, pR *PullRequest, commIdx int, delegationWg *sync.WaitGroup)
- func (own *Owner) Update(ctx context.Context, comm *Commit) (*Commit, error)
- func (own *Owner) WaitAndClose() error
- type PullRequest
- type Result
- type Team
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AreCompatible ¶
AreCompatible checks if two changes could be joint to perform any action
Types ¶
type Branch ¶
type Branch struct { Id int64 `json:"id,omitempty"` Name string `json:"name,omitempty"` Credentials credentials Index *Index `json:"index,omitempty"` IndexId int64 `json:"index_id,omitempty"` }
Branch is the state-manager around indices
func BranchByName ¶
func BranchByName(ctx context.Context, db *sqlx.DB, branchName integrity.BranchName) (*Branch, error)
BranchByName finds a branch in the DB given its name
func NewBranchWithIndex ¶
func NewBranchWithIndex(ctx context.Context, db *sqlx.DB, name integrity.BranchName) (*Branch, error)
NewBranchWithIndex safety creates a new Branch entity and assigns a new index_id to it Notice it persists on the db and assigns the inserted id
func (*Branch) FetchIndex ¶
FetchIndex retrieves the Index by .IndexId and assigns it to .Index field
func (*Branch) SQLColumns ¶
SQLColumns returns the SQLColumns each field represent on db Notice the returned slice is the list of struct tags of exported fields It's done to avoid reflection
Testing: tested by using reflection at Columns_Test to check being the tags
func (*Branch) SQLTable ¶
SQLTable returns the sql SQLTable name of the entity
Testing: tested by using naming conventions. See internal/name pkg
type Change ¶
type Change struct { Id int64 `json:"id,omitempty"` TableName integrity.TableName `json:"table_name,omitempty"` ColumnName integrity.ColumnName `json:"column_name,omitempty"` StringValue string `json:"string_value,omitempty"` IntValue int `json:"int_value,omitempty"` Float32Value float32 `json:"float_32_value,omitempty"` Float64Value float64 `json:"float_64_value,omitempty"` BytesValue []byte `json:"bytes_value,omitempty"` EntityId integrity.Id `json:"entity_id,omitempty"` ValueType integrity.ValueType `json:"value_type,omitempty"` Type integrity.CRUD `json:"type,omitempty"` Options Options `json:"options,omitempty"` IndexId int64 `json:"index_id,omitempty"` CommitId int64 `json:"commit_id,omitempty"` }
A Change represents every purposed/lookup for difference
func Add ¶
func Add( ctx context.Context, db *sqlx.DB, entityId integrity.Id, tableName integrity.TableName, columnName integrity.ColumnName, branchName integrity.BranchName, val interface{}, Type integrity.CRUD, opts Options, ) (*Change, error)
Add wraps change adding from the inferred index
func NewChange ¶
func NewChange( entityId integrity.Id, tableName integrity.TableName, columnName integrity.ColumnName, val interface{}, Type integrity.CRUD, opts Options, ) (*Change, error)
NewChange safety creates a new Change entity Notice it doesn't saves it on the db
func Rm ¶
func Rm( ctx context.Context, db *sqlx.DB, entityId integrity.Id, tableName integrity.TableName, columnName integrity.ColumnName, branchName integrity.BranchName, val interface{}, Type integrity.CRUD, opts Options, ) (*Change, error)
Rm wraps change removal from the inferred index
func (*Change) Equals ¶
Equals checks if the given change will trigger the exactly same action as itself skips comparison in case of Id matching (and Id exists for both of 'em)
func (*Change) FromMap ¶
FromMap decodes the commit from its map version Notice that FromMap() is reciprocal to ToMap(), so it doesn't assign a table
func (*Change) SQLColumns ¶
SQLColumns returns the SQLColumns each field represent on db Notice the returned slice is the list of struct tags of exported fields It's done to avoid reflection
Testing: tested by using reflection at Columns_Test to check being the tags
func (*Change) SQLTable ¶
SQLTable returns the sql SQLTable name of the entity
Testing: tested by using naming conventions. See internal/name pkg
func (*Change) SetOption ¶
SetOption assigns the given key to the given value. Returns an error if the key is not allowed for any option
func (*Change) SetValue ¶
SetValue performs type assertion over the given value and sets the value over the given change In case of failure on all the possible type assertions, returns an error Notice that SetValue will ALWAYS tearDown the value set up before
func (*Change) ToMap ¶
ToMap retrieves a map with the minimum required -not validable- data id est: {column_name: value}
type Collaborator ¶
type Collaborator interface { Init(context.Context) error Create(context.Context, *Commit) (*Commit, error) Retrieve(context.Context, *Commit) (*Commit, error) Update(context.Context, *Commit) (*Commit, error) Delete(context.Context, *Commit) (*Commit, error) }
Collaborator is any agent which performs transactions
type Commit ¶
type Commit struct { Id int64 `json:"id,omitempty"` Changes []*Change `json:"changes,omitempty"` Reviewer Collaborator `json:"reviewer,omitempty"` BranchId int64 `json:"branch_id,omitempty"` Merged bool `json:"merged,omitempty"` Errored bool `json:"errored,omitempty"` }
Commit is the git-like representation of a group of a ready-to-deliver signed changes
func CommitById ¶
CommitById finds a commit in the DB given its id
func CommitFromCloser ¶
func CommitFromCloser(body io.ReadCloser) (comm *Commit, err error)
CommitFromCloser takes a io.ReadCloser as the guideline of a new commit
func CommitFromMap ¶
CommitFromMap decodes the commit from its map version Notice that Commit.FromMap() is reciprocal to ToMap(), so it doesn't assign a table
func (*Commit) ColumnNames ¶
func (comm *Commit) ColumnNames() (colNames []integrity.ColumnName)
ColumnNames retrieves all ColumnName for each change
func (*Commit) FetchChanges ¶
FetchChanges retrieves the changes from DB by its .ChangeIds and assigns them to .Changes field
func (*Commit) GroupBy ¶
GroupBy splits the commit's changes by the given comparator criteria See that strategy MUST define an equivalence relation (reflexive, transitive, symmetric)
func (*Commit) Options ¶
Options checks the unification of the changes' Options, and returns an error if there are not shared Returns the representative Options of the changes
func (*Commit) SQLColumns ¶
SQLColumns returns the SQLColumns each field represent on db Notice the returned slice is the list of struct tags of exported fields It's done to avoid reflection
Testing: tested by using reflection at Columns_Test to check being the tags
func (*Commit) SQLTable ¶
SQLTable returns the sql SQLTable name of the entity
Testing: tested by using naming conventions. See internal/name pkg
func (*Commit) TableName ¶
TableName checks the unification of the changes' TableNames, and returns an error if there are != 1 TableName Returns the representative tableName of the changes
func (*Commit) ToMap ¶
ToMap returns a map with the content of the commit, omitting unnecessary fields It takes every change.ToMap and merges onto the resultant map
type Index ¶
Index is the git-like representation of a group of a NON-ready-to-deliver changes
func (*Index) Add ¶
add will attach the given change to the index changes In case the change is invalid or is duplicated, it returns an error Its reciprocal to idx.Rm() -excepting for the generated id, obviously-
func (*Index) FetchChanges ¶
FetchChanges retrieves the changes from DB by its .ChangeIds and assigns them to .Changes field
func (*Index) FetchUncommittedChanges ¶
FetchUncommittedChanges retrieves the changes from DB by its .ChangeIds and assigns them to .Changes field It filters committed changes in query
func (*Index) Rm ¶
Rm deletes the given change This action is irreversible Its reciprocal to idx.Add() -excepting for the generated Id, obviously-
func (*Index) SQLColumns ¶
SQLColumns returns the SQLColumns each field represent on db Notice the returned slice is the list of struct tags of exported fields It's done to avoid reflection
Testing: tested by using reflection at Columns_Test to check being the tags
type Member ¶
type Member struct { AssignedTable integrity.TableName `json:"assigned_table,omitempty"` Collab Collaborator `json:"collab,omitempty"` }
A Member is a Collaborator which has a table assigned
type Options ¶
Options is a bunch of key-value pairs which must must be in accordance to the OptionKeys of the table that it belongs to. Options is a design error, and in future releases it should be rethinked.
type Owner ¶
type Owner struct { Project *schema.Planisphere Summary chan *Result Waiter *sync.WaitGroup // contains filtered or unexported fields }
Owner is the agent which coordinates any given action Notice that an Owner is a Collaborator The unique difference between an owner and a lower-level collaborator is that it stores any result of collaborator actions inside the .Summary
func NewOwner ¶
func NewOwner(project *schema.Planisphere) (*Owner, error)
NewOwner returns a new instance of Owner, with needed initialization and validation
func (*Owner) Delegate ¶
func (own *Owner) Delegate( ctx context.Context, community *Community, schName integrity.SchemaName, pR *PullRequest, ) (*PullRequest, error)
Delegate creates a PullRequest and assigns a reviewer to the given commit
func (*Owner) Merge ¶
func (own *Owner) Merge(ctx context.Context, pR *PullRequest)
Merge performs the needed actions in order to merge the pullRequest
func (*Owner) Orchestrate ¶
func (own *Owner) Orchestrate( ctx context.Context, community *Community, schName integrity.SchemaName, pR *PullRequest, )
Orchestrate sends the order to all the collaborators available to execute the needed actions in order to achieve the commitment, creating a new PullRequest and then merging it
func (*Owner) ReviewPRCommit ¶
func (own *Owner) ReviewPRCommit(sch *schema.Schema, pR *PullRequest, commIdx int, delegationWg *sync.WaitGroup)
ReviewPRCommit wraps schema validations to a specified commit of the given PullRequest
func (*Owner) WaitAndClose ¶
WaitAndClose will wait for the Owner WaitGroup to be done and close the Owner.Summary It closes an orchestration (Owner.Orchestrate())
type PullRequest ¶
type PullRequest struct { Id int64 `json:"id,omitempty"` Team *Team `json:"team,omitempty"` Commits []*Commit `json:"commits,omitempty"` }
A PullRequest connects a group of Commits with a team
func NewPullRequest ¶
func NewPullRequest(commits []*Commit) *PullRequest
func Orchestrate ¶
func Orchestrate( ctx context.Context, db *sqlx.DB, project *schema.Planisphere, branchName integrity.BranchName, schemaName integrity.SchemaName, community *Community, ) (*PullRequest, error)
func (*PullRequest) AssignTeam ¶
func (pR *PullRequest) AssignTeam(community *Community, schName integrity.SchemaName) error
AssignTeam looks up for a team given a schemaName and a community Notice that it cleans up the current Team
func (*PullRequest) GetId ¶
func (pR *PullRequest) GetId() int64
GetId wraps the id retrieval to implement Storable interface
func (*PullRequest) SQLColumns ¶
func (pR *PullRequest) SQLColumns() []string
SQLColumns returns the SQLColumns each field represent on db Notice the returned slice is the list of struct tags of exported fields It's done to avoid reflection
Testing: tested by using reflection at Columns_Test to check being the tags
func (*PullRequest) SQLTable ¶
func (pR *PullRequest) SQLTable() string
SQLTable returns the sql SQLTable name of the entity
Testing: tested by using naming conventions. See internal/name pkg
func (*PullRequest) SetId ¶
func (pR *PullRequest) SetId(id int64)
SetId wraps the id assignation to implement Storable interface
type Result ¶
type Result struct { CommitId int64 `json:"commit_id,omitempty"` Error error `json:"error,omitempty"` }
Result is a commitment result
type Team ¶
type Team struct { AssignedSchema integrity.SchemaName `json:"assigned_schema,omitempty"` Members []*Member `json:"members,omitempty"` }
A Team is a group of Members which work for the same AssignedSchema