5.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)

5.1.1 Personalise

The user has the ability to customize their front page view by selecting which pipelines are visible. By default, the console shows all newly created pipelines to the user (that the user has permission to see). This behavior is useful for administrators. The user can modify this behavior by unchecking the "Show newly created pipelines" checkbox in the Personalize tab.

A user can blacklist the set of pipelines that he/she does not wish to view on the dashboard.

The blacklisting feature is implemented in the pipelineselections table in the database. Here, the selection is either a whitelist (i.e. pipelines that should be displayed) or a blacklist (i.e. pipelines that should not be displayed). This is toggled based on the isBlacklist column of the table.

By default, all users have isBlacklist set to true. Thus when new pipelines are created, all users see them (since they are not added by default to any blacklists). If a user has opted out of "Showing newly created pipelines", then isBlacklist is set to false. Then, that user will only see pipelines that show up in their whitelist and newly created pipelines will not be in that whitelist. All pipelines created by a user, however, will automatically be added to their own whitelist.

The whitelist is calculated the first time by inverting the blacklist (ALL viewable pipelines - blacklist = whitelist).

                             +------------------------+
                             |   PIPELINESELECTIONS   |
                             |------------------------|
                             |                        |
                             |          id            |
                             |                        |
                             |       selections       |
                             |                        |
                             |       lastUpdate       |
                             |                        |
                             |        userId          |
                             |                        |
                             |      isBlacklist       |
                             |                        |
                             +------------------------+

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

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

5.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.

5.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;
        }
    }

5.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);
    }

results matching ""

    No results matching ""