Skip to content

Latest commit

 

History

History
95 lines (71 loc) · 4.94 KB

6.1.md

File metadata and controls

95 lines (71 loc) · 4.94 KB

6.1 Dashboard

In the context of Go, the landing page is often called the dashboard. The dashboard presents the user with a view of all the pipelines that he/she is authorized to view. The dashboard contains the below listed functional areas:

  • Personalise
  • Search
  • Pipeline Group(s) & Pipeline(s)

6.1.1 Personalise

A user can blacklist the set of pipelines that he/she does not wish to view on the dashboard. This blacklisting is stored as a comma-separated list in the database under the table named pipelineselections. The table is tied to a user via the userid column.

                             +------------------------+
                             |   PIPELINESELECTIONS   |
                             |------------------------|
                             |                        |
                             |          id            |
                             |                        |
                             |   unselectedpipelines  |
                             |                        |
                             |       lastupdate       |
                             |                        |
                             |        userid          |
                             |                        |
                             +------------------------+

In case of anonymous access, every user share the dashboard configuration and every personalise operation overwrites the previous value.

6.1.2 Search

Client side search is achieved using Javascript and DOM manipulation. The file named jquery.listsearch.js has the implementation.

6.1.3 Pipeline Group(s)

Pipeline groups were meant to provide logical grouping of pipelines that might share a similar purpose. With reference to domain, com.thoughtworks.go.config.PipelineConfigs represents the entity. Group information are not persisted in the database and its only purpose is to achive grouping among the different pipelines in the system. Apart from grouping, it also allows finer grained permission model (com.thoughtworks.go.config.Authorization) that authorizes access to the group.

You can read more about the dashboard layout in the user docs.

6.1.4 Pipeline(s) and Ordering of pipeline instances

Pipelines have two representations with reference to Go. There is the pipeline configuration represented by com.thoughtworks.go.config.PipelineConfig, and an instance of a pipeline run represented by com.thoughtworks.go.domain.Pipeline.

Each pipeline run that shows up on the dashboard are ordered based on a certain logic. In Go, we use two distinct ordering methods:

  • Schedule order: Chronological order in which pipelines are scheduled.
  • Natural order: Chronological order of pipelines based on material modification time, i.e., based on your check-in time.

The natural order of a pipeline instance is persisted along with other pipeline instance details. In Go domain, com.thoughtworks.go.domain.Pipeline represent a pipeline instance. Natural order computation is performed by

    com.thoughtworks.go.domain.PipelineTimelineEntry
    
    private double calculateNaturalOrder() {
        double previous = 0.0;
        if (insertedAfter != null) {
            previous = insertedAfter.naturalOrder;
        }
        if (insertedBefore != null) {
            return (previous + insertedBefore.naturalOrder) / 2.0;
        } else {
            return previous + 1.0;
        }
    }

6.1.5 Active Pipelines

Any pipeline instance which

  • is the latest run of that pipeline configuration
  • has a stage instance which has not been completed yet

is categorised as an active pipeline in Go. Because the number of pipeline instances increases over time, querying the PIPELINE table might be a slow operation over time. To help speed up the dashboard load, we prime the cache with all active pipelines data during startup. An instance model ( com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) is used to represent the model data that is used by the dashboard to render.

Loading of all active pipelines can be traced from com.thoughtworks.go.server.dao.PipelineSqlMapDao#loadActivePipelines method.

    public PipelineInstanceModels loadActivePipelines() {
        String cacheKey = activePipelinesCacheKey();
        Map<String, TreeSet<Long>> result = (Map<String, TreeSet<Long>>) goCache.get(cacheKey);
        if (result == null) {
            synchronized (cacheKey) {
                result = (Map<String, TreeSet<Long>>) goCache.get(cacheKey);
                if (result == null) {
                    List<PipelineInstanceModel> pipelines = getAllPIMs();
                    result = groupPipelineInstanceIdsByPipelineName(pipelines);
                    goCache.put(cacheKey, result);
                }
            }
        }
        return convertToPipelineInstanceModels(result);
    }