Content Staging in Drupal 8

Preview:

DESCRIPTION

Drupal 8 has made significant improvements towards the ability to stage configuration. But what about content staging? Has it gotten easier in Drupal 8? This session is targeted towards site builders where we will continue to explore the content staging solution that is being built for Drupal 8 and that was initially presented in Austin. It's a solution that brings vast improvements to sites owners that need to stage or replicate content across sites. Further, site builders will learn how this solution also applies to broader and sometimes more exciting use cases - content sharing and filtered replication across networks of sites and applications. The recorded video is available here: https://amsterdam2014.drupal.org/session/content-staging-drupal-8-continued

Citation preview

ADVANCED SITE BUILDING

CONTENT STAGINGIN DRUPAL 8

DICK OLSSON TWITTER: @dickolsson

What is content staging?

What we want from the solution

How it's (being) built for Drupal 8

Reusable protocols

Headless Drupal

AGENDA

Dick Olsson

Digital Engineering Manager at Pfizer

dixon_ on drupal.org

@dickolsson on Twitter

Web technologist

Drupal contributor

WHO AM I?

WHAT ISCONTENT STAGING?

SIMPLE WORKFLOW

ProdStage

SECURE PUBLISHING

ProdStage

Corporate firewall

MERGE WORKFLOW

Stage

Edit 1

Edit 2

Edit 3

Prod

HUB/SPOKE WORKFLOW

Editorial BD

A

C

RING MODEL

BD

A

C

Content staging

Content sharing

Replication

Syndication

IT'S SORT OF...

WHAT WE WANT

We don't want to build just a “content staging” system.

We need a generic and loosely coupled “content replication” framework capable of arbitrarily moving content between system.

WHAT WE WANT

Learning from the Drupal 7 implementations of UUID, Deploy and WF Tools modules.

WHAT WE WANT

Revisions everywhere

Conflict detection

Easier dependency management

Ad-hoc / Continuous replication

Bi-directional replication

REST API

WHAT WE WANT

HOW IT'S BUILT

Contrib:

Multiversion

Relaxed Web Services

Deploy

Core:

Serialization

Restful Web Services

Entity API

HOW IT'S BUILT

Tracks update sequences in order to make dependency management a lot easier.

Provides revision support for all content entities.

Tracks revision trees in a way similar to Git to support conflict detection.

multiversion.module

Revisions are not tracked with a UUID. A hash calculated from the actual changes is better.

This way it's easier for each server to detect conflicts without deep inspection or asking the

network.<?php

md5($this->serialize(array( $deleted, $sequence_id, $old_rev, $normalized_entity), 'json'));

multiversion.module

{ id: [{value: 1}], uuid: [{value: aabbcc}] _revs_info: [ {rev: 2-gghhii}, {rev: 1-ddeeff} ], _local_seq: 1, _deleted: 0,}

multiversion.module

CRAP instead of CRUD.

Entities are never deleted. This is needed in order to replicate deletions while also being

able to handle conflicts. Much like Git.

A “compaction” job can be run on cron to purge old revisions if needed.

multiversion.module

<?phpnamespace Drupal\multiversion\Entity;

class SqlContentEntityStorage extends [...] {

use SqlContentEntityTrait; //...}

multiversion.module

<?phpnamespace Drupal\multiversion\Entity;

class SequenceIndex implements SequenceIndexInterface {

function _construct(KeyValueFactoryInterface $kv) {} // ...}

multiversion.module

<?phpnamespace Drupal\multiversion\Entity;

class ConflictManager implements ConflictManagerIf { // ...}

class CompactionManager implements CompactionManagerIf { // ...}

multiversion.module

Provides a Restful/Relaxed JSON API.

Endpoints for all content entities and file attachments.

Endpoints for comparing revisions, starting/stopping replications and other

administrative tasks.

Drush plugin for running replications.

relaxed.module

<?phpnamespace Drupal\relaxed\Plugin\rest\resource;

/** * @RestResource( * id = “relaxed:doc” * ) */class DocResource extends ResourceBase { //...}

relaxed.module

<?phpnamespace Drupal\relaxed\Plugin\rest\resource;

/** * @RestResource( * id = “relaxed:_bulk_docs” * ) */class BulkDocsResource extends ResourceBase { //...}

relaxed.module

<?phpnamespace Drupal\relaxed\Plugin\rest\resource;

/** * @RestResource( * id = “relaxed:_changes” * ) */class ChangesResource extends ResourceBase { //...}

relaxed.module

<?phpnamespace Drupal\relaxed\Plugin\rest\resource;

/** * @RestResource( * id = “relaxed:_revs_diff” * ) */class RevsDiffResource extends ResourceBase { //...}

relaxed.module

A simple UI to manage replications and conflicts

deploy.module

1. Identify source and target by UUID

2. Get the current checkpoint from target site

3. GET /_changes?since=N from source site

4. Pass result to /_revs_diff on target site

5. Collect all missing revisions from source site

6. POST /_bulk_docs on target

7. Save new checkpoint on target site

HOW REPLICATION WORKS

DEMO

DEMO

:-(

The revision and conflict detection model is taken from both Git and CouchDB.

The replication protocol along with the API spec is taken from CouchDB.

REUSABLE PROTOCOLS

Reusing API specifications lends the framework to unexpected use cases and

that otherwise would not be possible

(CouchDB, PouchDB, TouchDB etc).

REUSABLE PROTOCOLS

HEADLESS DRUPAL

AngularJS

PouchDB Replication

Not straight port of the Drupal 7 modules.

Loosely coupled system will cover more use cases and lend itself to unexpected

ones as well.

Implementing battle tested protocols.

CONCLUSIONS

Andrei Jechiu (jeqq on drupal.org for working to these modules.

SPECIAL THANKS

FRIDAY CODE SPRINT

Follow @drupalmentoringhttps://amsterdam2014.drupal.org/sprints

Help improve Drupal: Sprint with the community on Friday.

- We have tasks for every skill set. - Mentors are available for new contributors.- An optional Friday morning workshop will help you set up community tools.

WHAT DID YOU THINK?

EVAULATE THIS SESSION - AMSTERDAM2014.DRUPAL.ORG/SCHEDULE

THANK YOU!

DRUPAL: dixon_ TWITTER: @dickolsson

Recommended