The Modern Developer's Guide To

Transcription

The Modern Developer's Guide To

Contents1Microservices and the Salesforce1 Platform2Microservice Fundamentals2.1 Automatic Microservices2.2 Process-Driven Microservices2.3 Custom Microservices2.4 Elements of Good Microservice Design3Types of Microservices3.1 Data Object Microservices3.1.1 Native Salesforce Objects3.1.2 External Data Objects3.1.3 Automatic Microservices3.2 Custom Microservices3.2.1 Using Any Language and Deployment via Heroku3.2.2 Using Annotated Object-oriented lasses and Methods Written in Apex3.2.3 Action-based Microservices3.3 Process-Driven Microservices3.3.1 An automatic data object microservice3.3.2 A visual process created using Lightning Process Builder4Summary

1. Microservices and the Salesforce1 PlatformWhat is a microservice anyway? Almost overnight microservices havebecome the hottest trend in development patterns. But is it simplythe latest incarnation of SOA - an architectural approach fordevelopers to promote good design?To most developers, microservices falls somewhere in between SOA and modern design as a way to promotediscrete, decoupled code. The modern developer, however, is more attuned to the needs of the business.They understand the need to ship solutions and deliver business value fast. This can't be achieved byspending time on architecture, or infrastructure.The Salesforce1 PlatformThe Salesforce1 Platform solves this problem by providing a multitenantPlatform as a Service offering with robust role-based security, managedinfrastructure, automatic API and service versioning.It also provides visual toolingfor rapid app development anddata management.The result is the ability todeliver robust microservices- driven by business need incredibly fast.Salesforce.com The Modern Developers Guide To Microservices1

2. Microservice FundamentalsBy eliminating the need to spend time on infrastructure, the moderndeveloper can approach microservices and app development via threefundamental approaches:2.1 AutomaticMicroservices2.2 Process-drivenMicroservices2.3 CustomMicroservicesUtilizing the intuitive visual toolsProcess driven microservicesDevelopers can code customprovided by the Salesforce1leverage both automatic andlogic, data transformation, callsPlatform, business users and acustom microservices as theto external systems, and managedevelopers can createentry point for executingtransactions utilizing anydatabases and business actionsprocesses defined using Processlanguage without the need forwith a few clicks and have theseBuilder, a core feature of thecomplicated middleware, andfeatures automatically exposedSaleforce1 Platform. Processexpose these as micro services.as microservices. Thesedriven microservices promoteThe diagram below provides anservices exposed to thirdgood design by encapsulatingexample architectural depictionparty developers as REST-object creation and updates inof micro services on thebased endpoints.discrete microservices.Salesforce1 PlatformSalesforce.com The Modern Developers Guide To Microservices2

2.4 Elements of atformmRegardless of which approach to microservices you take - data object-based, or custom, microservices developers must build upon the learnings of SOA - decoupled services which provide access to information but eliminate the complexity often associated with delivering course-grained services designed to support allpossible consumers of data. In order to achieve this, modern microservices should adhere to the followingelements of design:1Microservices should fulfill a single function2Microservices should represent discrete data entities, or business function, but not both in the sameservices (per #1)3Microservices should not require the introduction of specialized middleware4Custom microservices should be written in the most efficient language for the task and not constrained byrequiring the use of a single environment.5Microservices should access data in a consistent fashion, therefor promoting loose coupling and design bycontract patterns.Salesforce.com The Modern Developers Guide To Microservices3

3. Types of MicroservicesIn this section you can get a better understanding of Data ObjectMicroservices, Custom Microservices and Process Driven Microservices andtheir fundamental differences.3.1 Data Object MicroservicesThe primary function for data object microservices is the exposition of a single data type (order, customer,product, etc). Traditional enterprise systems often aggregate data from multiple sources - cloud-based apps,on-premises systems, ERPs, and so on. The result is developers spend time integrating data within themicroservice implementation which impacts maintainability. The Salesforce1 Platform solves this problem byrepresenting data entities as objects for developers to access via programatic and declarative tools. Theseobjects, provide a consistent interface for interacting with data regardless of the origination point. Thefollowing object types are supported:3.1.1 Native Salesforce ObjectsNative Salesforce objects are data entities either provided bysalesforce.com - Accounts, Contacts, Leads, Campaigns, and otherentities utilized by salesforce.com products - or created by customersusing declarative tools such as the Schema Builder.There’s no need to understand database designor administration.Salesforce provided objects are referred to as standard objects, andcustomer provided objects are custom objects.Salesforce.com The Modern Developers Guide To Microservices4

3.1.2 External Data ObjectsUnlike traditional approaches to integration which relied on ETL(Extract-Transform-Load) strategies in order to access data fromonpremises applications, Lightning Connect, a new feature of theSalesforce1 Platform provides an oData-based approach to validatean sync data at run-time. The data is represented as a data objectreferred to as an external objects. Once the external data objectstructure is synchronized, these objects functional identical to nativesalesforce objects.3.1.3 Automatic MicroservicesData objects on the Salesforce1 Platform are much more than structured data types. Data objects providesupport for relationships, formulaic fields, geo-location of addresses, and full API access to perform CRUDoperations. These APIs are automatically exposed to developers building apps on the Salesforce1 Platform usingsalesforce languages and frameworks such as Apex, Visualforce and Lightning components, or any popularJavaScript frameworks including Angular, Ionic, Backbone, and more. Further, the platform automatically exposesthese data objects as REST-based microservices for developers to connect from anywhere.Salesforce.com The Modern Developers Guide To Microservices5

3.2 Custom MicroservicesDevelopers often have the need to create custom microservices. These services may retrieve informationfrom the data objects described above and perform some additional logic, enrich data with additionalcloud-based services, or perform operations which require transactional control and rollback support. (atypical short-coming of WS* based microservices) The Salesforce1 Platform support custom microservices viatwo strategies:3.2.1 Using Any Language andDeployment via Heroku3.2.2 Using Annotated Object-OrientedClasses and Methods Written in ApexDevelopers can leverage their preferred language,Apex, provides a full featured Java-like languagewrite custom microservices and deploy these viadesigned for multi-tenancy. It provides efficient dataHeroku. Further, with Heroku Connect, databinding, powerful programatic constructs, inherentis seamlessly synchronized to Salesforce withoutroles and profile-based security, and transactionalthe need to include integration logic withcontrols. Developers can create microservices inthe microservice.Apex and add simple annotations to define RESTfulendpoints.@RestResource(urlMapping '/Account/*')global with sharing class MyRestResource {@HttpGetglobal static Account doGet() {RestRequest req RestContext.request;RestResponse res RestContext.response;String accountId f('/') 1);Account result [SELECT Id, Name, Phone, Website FROMAccount WHERE Id :accountId];return result;}The result is discrete, loosely coupled microserviceswhich can independently maintained.#!/usr/bin/env rubyrequire 'sinatra'require './orderPrice'@HttpPostglobal static String doPost(String name,String phone, String website) {Account account new Account();account.Name name;account.phone phone;account.website website;insert account;return account.Id;}oPrice orderPrice.newpost '/price' doreq JSON.parse(request.body.read)args req['params'].unshift(req['method'])result oPrice.send *argsSalesforce.com The Modern Developers Guide To Microservices}6

3.2.3 Action-based MicroservicesUnlike traditional approaches to Service Orientated Architecture which was primarily a tool forarchitects and developers, the Salesforce1 Platform also empowers business users to rapidlycreate action-based microservices without writing a single line of code.Ac Quictio knsLogSubmCheckit ExpcallenseinThese services, designed to enable users to perform quick actions on-to-go, are automatically surfaced withthe Salesforce1 mobile app, and are also available to any developer building apps connecting to theSalesforce1 Platform.Salesforce.com The Modern Developers Guide To Microservices7

3.3 Process-Driven MicroservicesPerhaps the most progressive microservice is the notion of process-driven microservices. These servicestypically consist of the following aspects:3.3.1 An automatic data object microservice:This service implements a discrete endpoint for CRUD operations on a particular data entity, order for example.It contains no logic pertaining to business processing or transformation logic. Business users can create thesemicroservices using Schema Builder, or developers can create them using the custom microservice strategydescribed above.3.3.2 A visual process created using Lightning Process BuilderLightning Process Builder, part of the Salesforce1 Platform offers a visual tool for designing business processes.These processes include an entry point triggered by the creation or update of a data object, typically via aautomatic microservice.By designing discrete, loosely coupledmicroservices, the process driven pattern offers abest-practice to highly scalable design:Business users can easily create and modifyprocesses using Process Builder, and even createdata object microservices using Schema Builder,or allow developers the freedom to createcustom microservices.Regardless of how a data object is accessedand updated, the loosely coupled nature ofprocess driven microservices ensures theprocess shall execute as designed.Salesforce.com The Modern Developers Guide To Microservices8

4. SummaryThe Salesforce1 Platform provides a variety of strategies to create automaticmicroservices. Business users can quickly create data objects, includingon-premises based oData data sources, which are automatically exposedas fully managed services.Developers can code custom microservices using simple annotations, or use anylanguage such as Node.js, Ruby, or Java.Regardless of your preferred approach, infrastructure and security is managed foryou. The result is the ability to focus on delivering business value incredibly fast.

THE CUSTOMER SUCCESS PLATFORMSALES SERVICE MARKETING COMMUNITY ANALYTICS APPS

Microservices and the Salesforce1 Platform Microservice Fundamentals 2.1 Automatic Microservices 2.2 Process-Driven Microservices 2.3 Custom Microservices 2.4 Elements of Good Microservice Design Types of Microservices 3.1 Data Object Microservices 3.1.1 Native Salesforce Objects