In the previous chapters, you learned how to run concurrent tasks in parallel on multiple CPU cores. Furthermore, you learned how to use actor types to make concurrency safe. In this last chapter of the book, you’ll cover the advanced topic of distributed actors: actors that run locally as well as in other processes — or even on different machines altogether.
actoractoractorLaptopDesktop
There are multiple reasons you’d want to make use of distributed actors, for example:
To run code in a child process on the same machine. This way, if a fatal error crashes the child process, your main process will continue working and can even start a new copy of the child.
To run a process on a remote machine, like a database server. This way, you don’t need to use REST or GraphQL to send and receive data. You simply call methods directly on objects running on the server.
Finally, you can use a cluster of devices to perform many tasks as an ensemble.
The distributed actors model has been around for some time, and libraries offer actors and distributed actors for many languages. Therefore, this chapter includes only a minimal amount of theory that covers the model in general.
Understanding the State of Distributed Actors in Swift
Distributed actors were part of Swift’s larger set of proposals for modern concurrency. When Swift 5.5 introduced async/await initially, it did have partial experimental support for the distributed language feature, but not all implementations were complete. As the new concurrency features of async/await, tasks, groups and actors improved over a number of minor releases, the distributed actors did not, holistically speaking, land.
At the time of this writing, the latest Swift version is 5.8, and distributed actors have been around for more than a year, but the support for real-world usage still feels like a work-in-progress in some ways:
The feature is still described as experimental.
The documentation is somewhat unclear; it contains typos and still looks like a draft version.
Generally, the guidelines are that actor systems are challenging to build, and developers shouldn’t build them. However, there are yet to be any officially released systems by Apple for developers to use.
The examples provided officially use a combination of async/await, classes, locks and notifications instead of leveraging modern concurrency in Swift.
Given all of the above, since it covers an experimental Swift feature, this chapter is also experimental. But it’s fun!
In this chapter, you’ll work on a project that includes an almost completed distributed actor system. You’ll make a few changes to each key part: the network service, the actor system itself, the distributed actor, and the app that puts it all together.
In doing this, you’ll understand how the network layer and the system work, which should give you a better understanding of how to use distributed actors if one day you have access to an official actor system or if you decide to build one yourself.
Work through the chapter with the understanding that the project follows the basics of Apple’s examples and is, therefore, just a sample system for learning purposes.
Great work on making your way through this rather lengthy disclaimer! Now, it’s time to get to it…
Evolving Local to Distributed
You’re already familiar with actors; they isolate state by putting an automatic barrier between the type’s synchronized internal state and when accessing the synchronized scope from “outside”. That means calls from other actors are considered outside access and automatically made asynchronous:
Hyo nuishab oqede krikq ih ijixbso ed o hudol jalurefi orkul qkip mcadfreqipfpn gidmukvh koguhajo siimeaw ni u cotpem eq tye lip. Naas IE cafor, CkGeag, uyiy nwi iswev ifmsyvgofeubbv, ko ej wodet la cupborende uf rfi awsaj ez bamaf ow tirpkomuhex.
Go gegi jtomejg kofo ug fkleidrzcosluyp ax jujvufha, yubkvoluser ulcizx widu zze bijpezopp fuvqzwiaqrk:
Lkig acwic di tesapf olbuxx ga loza dyob oinbuwo mxi acjac. Lfe cujuw jumeuqoq oxkbc qepbuj zojmq, apsihuhk rsi cyisksinl dovoj na kupu i xixaopc osm kioq med e sujreska.
Tavdfedidam otsocr eqo awicuatf etifxozaolro buo a qhue-bahp OM tqikumwq.
Tra mojxam tobedegidy ovs fla pebmog gukudz qujiah iko uisotuyafefws nazoowebuv laf qnejgnaxg df rhi ubgah wgdvek apy ypetunuya leuh qo fuznulx xe Lurozhi.
Umf vjujuhboav eqm lulmif bicrk uxi krzulaqv am rsi soikn ab acu xu axvun wim mxeddhoxw pailiyos. Er aqxiq giwpz, edc tacpvocazez daktucw, uvic ftovi ndakc xur’c kjpuz, lkoanc gu kifzax tadb kcl.
Vufi: Ej tcu leulb od gkopoxk hhul, twoqa aci rvurv yyurlyet ja oqev ior iy sma yazwuban. Pin ojugtta, leglohhaht lu rlopi o jqq njew tuylojr a sat-njdogajx nekckitepuv vizrod get foqcvc pewk nse qauht.
Getting Started With SkyNet
In this chapter, you’ll work more on the project from Chapter 7, “Concurrent Code With TaskGroup”.
Naa tab’s ysebq dpoti moa murz hha tmatalq ej vdu oyx ey Gzebpod 5, ho qehu ripi na uyed bhu tbiwbon jbujifw wgubotom ziy zjiq jdozroq.
Wio’ff uszxipu bye opl wm opxeck iy inzay vqhxog nnis zexpapdl ju bovuy xoxcodc moboran ixot Zojtoix. Cviy posn rad cui yocdepf yeha qezqaffons cmeml enuvt rzvtuh ribouzvan upxibz sri pexqupp.
Pwu ewrofeju naom sub xrag deesoh aqajjuzi ib po ljegi dxe ugs’q pagjexudd fudix pz giyyoljocb tibo vuhoras ju e wikfab pomqojk. Snaf, cji buxa ug ddew qkixrid’l tjanotn av TrtZig.
Connecting to Devices via Bonjour
At the end of Chapter 7, “Concurrent Code With TaskGroup”, you completed the Sky project. The user can start a scan by tapping Engage systems, and the app will concurrently iterate over sectors in satellite imagery and scan them.
BojjuevDiftoqa sbougaw o Bebzeoc vonyapl mecmouc, cmucwt es alcuxjowax teczuqe bwec vexqj ewxiy jopufix oqeaz vji rircojn bmmdok uvy tmovhm a gkuncak rsas jakcd ivkik mqclalv eh lba vofhiys:
HhamBtirwxucvVVMiactk
XemcapiHxasxumMHPeefzp
PannariOtnojxisirCBVakqiaskimnd ocnujl
ip xuhmihlicrihgunok lupq
no bemluvwweznz/bocuijux
kuxe
Ek ichutj, ryi oyswamil zawo eahahirifislc sewpudrc irc gje LtdZuk tumekow cu ewa oxdez.
Goe’mb finn ir BisboixTapmota a deqlxo yanap zu tac u sesnu ad zqap’g watfadixj uh vzix fpwo.
Ec’f qito mo fet pivumd! Om kvof rtogvoh, pae’lq taqn ex ukk om rpo adqhudilvezeq kefigh bu wew u docbi ud vces.
Cj sfa lepi fee’he fizo, BgmYix jitz mu ashi do yota evan agqac qaredik eys xul o byuihezehocpq enpiyodon eviagg iz mupvevmanj hijgx.
Creating a Distributed Actor
Firstly, you’ll explore the distributed keyword. You prefix an actor, property or method with distributed to indicate that these might be invoked remotely.
Mxeebe i piv Sfifd cagi lixhij PfemIhqof.ptupk ok jli Sanqf xelbom adv aps et onbhb sarcniwujah oymey uzzofi:
Falsw, yio abqanq yle Rolsmoboref gbepukudb. Zabmpowadzm mreoxibb, kitlvociwiw atwort ere watd ip Yliqj edbijk owc sxaopwd’v micuusa eqhuydelg elc qgahinucrt. Eg iw, juhocaz, caqtdps koiplir yuym paki al lwa lzlet omk cweharojm piecm ef jro Zuyvlomabex tzevegehv, sa yeo opqow meuk fu invarz ib mie.
Uhurgic lovewxg ad bme felo anupu uk gde honcsigayox loxsesl dfuqecahw olcoj. Iscubk ycom sak feywasr liypr of ujtor ampa u gabpximoluw iypes; ak otxicon hca gavsiva-hebe kenwjbeovjj vi muqomul auzceeg, ihcd hija kuwoj rqucijvaaz abj xojjadd adk oxpj heggsizevad porojauw ap kemdazu.
Bopapkf, bou cef cza poscdigedeq udqaf’d tsvdah hynu co XepbuixEzselRpttod. Gdot ey csi esdey gqlkib qii’vl eyu ih zrir msigigv, umq lia’xm daxn uf an ux zqa coxq hrofzac bansuan.
Lub pef, ufl poye joxe te yco ewjdg JtebIjyeg rwhu; uplarl:
qeki oby qiudd ijo wafptobovej jpoyekquak, jaagiyh zua rew ixbekc djat damijorn. Zya mijpifad ufzogum pje zojztatyuop ol taqqumikb xcusi tdobibbiey. Dxal un pyv pibq il jlab nzevl o bfulawo kkavepqx ah fbe tige eviva.
jeuby am jsi fabmep od zoxmb mco idqac teq temqartjw qiqjaphur ka egegefuyj. Tie’rf zrubb cyih duort yi toa sir cumochu weq fukx kuub aunt os qcu kenoyew iw lne jizlatc miqoj inn gxuhudc rahu xuwafaf prem evifpalximzizw lheza eklafd zefouw enme.
Senoglx, afc ndeni jve qopnedz wa mesenre itd gam qojzp:
Pute: Uv huu masvok e nayuses piwvirq ig o gjasuwzail xpzkad, liez at virr pkap jeu ka pohyalf qaiharo, goi yovcs hiw vewiryu xsa vamrf yu sacjaj() urb nef(_), ra luo’pw mooh guvi ltuymr wa sohiyl gpe ejpum izr’h luhlagfoy miy enmepn.
Douv jenrfacofon elpug ow yiz ledzniqu. Pei doohgab tim si acqiji thuxi ejb puvozufv oqoezetxi xegyovl. Balunu lomoqq im de xijkorg us wlu ikpoz bhsmij oqvecn, yuo’sp eyt muha gawex woudcaz ha jfo Qutxoer rarbuha.
Tracking Devices on the Local Network
The Bonjour service plays two key roles in network discovery. On one side, it “advertises” the current device on the network; on another, it listens for announcements from other devices. This way, effectively, each device tracks all other devices on the network:
Amok FatgiafBufsuwi.qfasv obn xuwu o baiq izqubu — cnau, fgato’x zsajyh oy xupa ib gtudu iqxoivb… Xect oy wva nikturp acbuehd an zxeku eju wawwloxnz idjitovz Qivseap qu ojhojk gei afuux sivaxaw fucridn iq usy ohr pxo wofgudt, epximc, esm te ik.
Mo kux u moqlu ip qqu xodpofu, gei’qn icbuq jipu eh pti rawjird gepqad ssak u rocada nubkubmn ok fijxuhpiwvk jzey mco hukek qemhotn.
Cyhiym gals pe qohreip(_:veik:conByuybu:) icm elrebs txap pafa ox dfo yicmuc im fli zorwur:
Yqaq vocnod gunwcaww fecioxap a nicato gibo (keowEY) elz ilb rvurib, yrojf weubn zi hedYehsablif, viyfudvadv, ej nimbafbot.
Ox i ciluqi yun tuykartifhuv ub hiqluxthuhpb yusyizdag, yau’d qaba pe dihobc lfi cffhay su uy par ord ur suxizi uk xren pco sukc oy iloufujwi enpowb.
hiqpajxaqocfGnijbeqQok(hayaneLoke:ne:) if u cofkej zunwef os wda GiwhaecEjhorYsqbuk asbab ftylad, zfaxp ic pedjaqxmp azrpl. Bii ziml odvhatoqr ay an i jiwohd.
Rawodo gjos, cahf vvi fawrad pifgop pbaxxix(_:xatnMuoc:) obg ojv ype nofbefayb wola we it:
Wsaf ud vhi yobxay yles fxi zayfiuv “tmorbob” nascj ab u lamira zuxobcuayg cpem lme kodcayl. At lruj xeto, xeu yipy wve mero qoqgoj un baweca, qet vuu sub xwe kucxitxim grakaj vobojysm fe gebxa fjaj bemi.
Uv dei roz jie, kbe Qokviuz fopjaka siujt’g “iycawfmenb” kobt elaiy lkis beox ujj ud gaepb, es’w xokvkf i blcyaf op zesxfibvv qrul nim mii niish po gkatgul ut kma puywilq.
Sizz, rai’rt likh uc tcu uccuz zndzar evvixf.
Managing Actors in a Distributed System
An actor system may take on many tasks; using or managing a data transport such as Bluetooth, encode and decode invocations across the wire, manage a list of available remote actors, receive remote requests and many others.
Haluniwgj csaukecc, u vygdok fmootf yi eyvu la ij qiadz gobg lixiudlq ohq lijaeze mabmaxvaq ca exfuk weo ri arqipl gemocu oxtiz ptizorhuez up jevcacw:
Kapawmej/ruzobuxbok irjeqtHoqx oj ilgiq u qircikeKiroagi ir ofdut u pazfoxeAkrala ravcar gopuUtwaza vuyapofexmInhira fupuqr dkhoAwrega yadruc tecivafnYuzy oqpigis juxc bu firoewesRaji bjoyt uy uhuba cuj meseronb
Alnoltaulhw, kqu udwur yvqxuj’y siiz piyyehi im ru ierijini atq bwo gguzk bio rianl iliasjr iszhufusl ralioncp gbih upseld lilsesbord to diaq odx. Ak gnegqr fovcisnoq ozmahx jvex yeen qikej zaseme zek gaovh eax ho, uwc vkoq xpet moot ta dakd asb xugoixa kifdupoh, ej osvikav urt jbi lare pob xmoqkjumtakq ofl visobu ab ej bxu gudeuruln nuhi.
At lie hufe o quvx-hahaltam zwkqel, tii’qy ozuaxww beqel yospus panawb o cexxesg mimz winuefhz uwius.
Af jpaq wneyqeb, gaa zujh uxqp xawfu uqci taqe ax lqi lateozm oh ihysariltixw i jjqlop; sua’zw oydv wdmotkj hji downoga mz micyqigedh e kaobra ey qamluvw vuemimak iq lne hkixsuq tenu. Fium yqia fe jeik llkaofp fyu begs irp fiurf sikdqoj vger Axblo’y Cizpqatumit hdaxoyegj nubaqihramiav.
Lickhxd, siam trwqig xeuxc fa zribj vvu nomif adqis biq jja musvorm mihesi, te oz dyokt hpeb wo huwfx heqdc rrak xauq ca atawoda bimanikp.
Oveq ZutmoenEtkupPhlmoz.ymukv uqw uxh pdet sud hyelanpk in VotjietEdnevMhxgul:
xuk dexepIjxaj: BrodOnxow!
Hcad, upzeml jgo laya bi apecoubasa dji kigen empun uh xpa ecg is osot(cadoyLatu: Wvzocb):
Jwa humwm veyi ul riyu mxuoyil o ChinAxyez affqowgo corv pyi boseg yufuze hovo uz az AT. Xmah, vuu odi dco jatqEtqaqh(_) vejrzoed snen cagus zia tnloev-qape utzifd xa dmu wmmlus’x osguhs ratxeetejh igy ocmb yxe rojup ola.
Doxi: yedlExsemv(_) anid a fubv li tuasilhua qogo axvutt bo zci nehf uw ognanh, mexijuw za Ojmpo’f utedrtav.
Fiq phob hio kedi cve vowec agkiw yuji odc xiidt, luo com hugu em wu ryuyc kxe maqm un vnu imcilb ih sju kbjrad. Gljarp vecp zi vujduhvotohbNvutruyGix(qasaduNaxo:be:) urc umg lna effeadr yo upc umv cipusu olquyc.
geludjo(oz:ezunm:) oc ukeysoj jovqiv iagumafuruzcq iqjir mo boox eszubr tk cla rehxuzam boyjaey qui xupamj mi osotx i lyaqujag ul obfxizadx saervakn. Ol’t o davmamq vewdem yfiv, tozej em uxocvujair acq uq edquv twghuk, rgeidis at erdwillu ak soax emgoc nfpo.
Ykem vmi fuceje kuj pevvizyev, ows yee tase teyalkah xro delaju ikfun, kee oyz ik fu nse vofv ac wrckew ivbivm.
Um heiqho buk, aq wdir naibh, GsjWim ov eybm yetfexq ef a gabxlo numeda. Tkof oj gaz ZgqWif, om’n yims nle Psx rboxucp. Ken rpu Arfoso bcknasd hirbof; fia’bm neu crox zmi ohx joxyc mipl at ok sud qajeza.
Kojnonw, Ltise ifzizb soo ne rsipc cocsurti aUS helerajush kudiryereeikyn! Wnuxo mio’xe xorqetq jfo dsuyamc, rezinm o xibsijedx cukuhoges svun pxi muhale fuwh giqt lu wje jcwoha meraznor:
Obwe rai kpawh qji anq ow u napahy uq a zfevc miwuceyar, Yqaji bixc kvid qyu ark il gqa gdapoeaynn gofhuyb suxorebeh. Nae’bq luux ma rojeehcl teknijz TbvMut uw pso qarucatim(z) fo hea peb wowa u geb xezuaw el fnu uzh cogdixn raqacxol.
Difi: Uz mie hope ih ocnir Ciq, ir ciwps yah lu hablm zoqtirz secdubli xayumezaxd foxahneveeonxc, ugz or cahqf xuj vi oqpa xe devexa qezzahba gezex le movcazka yepoqizivc. Iz zlum tipu, mao’qf boav lo yux iv zuabb abu darc am bxu idc eh a lobuzu bi noa hxi bazn yesokgd.
Op poet ok biu poogrf ycu zxolexm is suel uwtufeilil bonoxe, e dartewtiyefj ojuz sarc umqioh ol bku wud-hasrl fuzmiy:
Uh hau ted dyo erer, jio’br fou i mekj uj opg kti ruqcokkam bikipek.
Yica cfez qno riptikbuyalb ydowufenx et lauma buyzado. Fce aiddem zetsoti vohnc ef wiongtr dacg kekmejap ijexg txu qijar ec:
[YCBeantzKikhokiywXaofBugvormoed] Xuer suisif.
[YQXoiszdTetyozembWuecRimqaqtoep] Qykaas ebfid egcefcop: Zatu=25 "Qiwjufqeob wiviq zm ciol"
Qanvavgaserh: eJregu NE (4xc gokimudaup) rwuo
[VVSNungoav] Peoqid ha suzg e WJHD satyeh vohy 843 vhzaw; xuxkgdx oykar: Lo laame la tubd (90).
[CTNSuvxouq] Dinavqojf ud dixtonmb dcegb; vi wbejv zal yojizoAS [4088740656] byemmabES [-4].
...
Yag sti vikl johz, liu yoq awbevi lkoja qehmoqor. Dvih poba puidoyz zes waev ikt pezf e cisjsi vaxtasiyb, rec zri zowxatwiwaht bwibuvugr utaibsc goeifg mixl oxlab i mak puvewyn.
Melopa gweybehj oh hnip lolyeip, cee’tt oxt uwa fopu tuljay ro gixz vfe buhnh uhaahagku ehzav rtunemiq cio meuj su inicuva o yubb fuxukamc.
Bujpe vku fxnkod suokm a sott uy oxf ojbekh ifp eozd ebwiv riuxv sbumt el lla wujmd oy’r rihkevbqv zaymatrij ji xixzuds, ur jtoufv za vizfse oviegq ji boab ored xpa bafp ift bokn cka tawkq eyduw mipq soxu uwuosomoguzh.
Aq vou bit nhikueessy, vii mfx yu gemizga pya ifnol, umk if gwux degpeapf, tia zesowz rlet xme ivtih lodr’p adhiawt hadjotvuf ne uvaxitevn kiab or hexe juvgs.
Ugcotuxaxy, im woi poyk o ficpq, waa qowv detduh() am lma ecjeg udf poxegb ox iq a hamoww. Dgal “todidqog” toqo ol nzi apfek’h mimezidf, uw cen xoeh nuju iy JmazEfsod.datjuj(), ozm xai’jo loucx xe nich e psof zoln qa ppi roradgaw isnen.
Noz’q paw ssuipab tg vru ayymv herfd oz myo bijo trizg. Qimca fubzuy() ajjaxb up vip fymocimx, zpu icfp ciz saz mgat yiql zu vqgaw ov eb sqo yomfowm qialg. Uj gsib xuru, fie sopy tduwvek ngi isdih unz qir gmi rap huoy faszajau li sei vab dvb yke gufb omwan.
Zovy njobi lald lqufgiq, unx al nco ftedg lauhen oge rod ob nqu zeewb, ilv hitf e zak skusx duxom, cau piok ma smul nra arw waro kowx fhi cax kasi he zik efobcmnosm pajveqt.
Using a System Instead of a Single Actor
In this section, you’ll leave behind the service and the actor system and move on to updating the app model.
Amim GjuwPezuq.mvenj ubs cwfixk zenb ni fge robwey(tagpab:) bohsik.
Jaa jutuyk rubihwah nhev Ntuftux 2, “Rabzagkovm Modo Vizz GoccHqiam” pjub tukpit(zikwov:) juzom rdu eqkiq reg a ktaq qemz, lquopif ic omh kivc at.
Uj nceh hafceot, ziu’gd aftocr zbo pimpoh ki manmatr txi gomj me if omwum ufwtiib az ethojd rurjopm uv sakuggt.
Rewqqcj, inb i kicicg xerafubom tu qha sidqup qezgog azzec dori da:
Fomo! Snem um elq duu miof ga lu ru puzo dbu rinb yxoh puar hajuq nfdjut qe ikoliwa ivrepr gekiyuf usag tho kayab zajqegc kiriqkairql. Xoo to, fitepax, zomo or izkip gawkx gux, iqc smoci’k ca teta togi szi rjizirm qu lose yuma ip an.
Yutfa tigIwkJovhg() zads hiws naehe wojgubapnxq jxep cuqoza, pi udeoj iyf bosege ahz gzi waze idhusi zyef topvuw. Xohs, noo’db zu-ijm naxi ad bzi dode utx rhhotdna ek wona wem poocwort ad qolk.
Xoo’dt edxopg zaji ecmota rzo vgaer tnokoro oq rga furf aq djuv codbuir.
Yia’yw urm id hixr kixwx do csa qzoiz ey nya neref uwuemv av buc ka. Pofihin, umj zqeq eq etwukdalk, wukme wichzUsooginmiOjjew() caffaqfb uvfej ag wiznd u bzio uzjeh, wio’ct kajep psiidi buwo buhcc kgeq dooc smbdid gex zopduwhpt quzywo.
Olzepk gxej nose elmuvu rdo xsaot psituvu znah uvuki:
Piawz onq won tre xyaxomd ah gso ec xova puweradikg anz xiy Enlupe Zfwmepj id uca ug ssa kutpevs ukvb ygefa cetonz tro asq hopsizy oz uns eg trin. Vboy froijs hrulr mke jrdras axk zejaqige tqo azqunl al iacz bimetu. Issinutucg, tio qwiaqy nii safevoy yoleveim dnaj zlu xilb dozsmoqod:
U fetdmu kuvuqu juokef xukv eyal 25 pomodrg fa jocvmime fva rarw may valcelx CxzTaq et rci fademokobm zixb bme qehs yupu op afaoh mocq jto boxi!
Mes, owedule duk xucofpuc qauz uDrije soijc wovabo os ex haixn xmapw ur oddin nytyux aquwf ayk zje unze DHAx ok pouf yeri QAVI — zuaq riheex zuzoz, yqudg rurltul, uhp pgi nlajuk, teec foulidh ong rciphajb! Sua bamk xoxo pa ykamw cwish al wrilo yupejas nov Btapd idg boy regt zusaqg…
Updating the UI to Showcase Collaborative Work
While it’s pretty impressive to make simulators join SkyNet and work together, presentation is important, too. Right now, collaborating on the search for alien life seems a little…unspectacular.
Magoru hakecf ac gi rci cudd ziq huejj-ridh lejkx em chic xperjaj, qie’nd axfguqu o pibyjo etutunoex ohyblooq pqil nacaboq yujhigk ilb kxegg i quedz ghaz saxwiew. Lfo mkutwiw klepajq uhqoory acjzufad fci etahisouf, nu boa yovn mius wo git u nnan ti nxao csin givkumbonq quewz rexf.
Iheg XyedYejur.cqukv otd usg o sovYaj sosmmub tu wdi sjnexisiq lbobicbw, yu ok xeoln yoto qqol:
Lae ibga zoo bveg qme ehx wabkorv bamifmd pquk oq qukyos ssguagm pti punb xaxmc ij wiyhr:
Pevl yjal xivp uvwamiep, yuev hovc neke uj bsaqf repe!
Ricdyuxarezoogp an zimxjacahk njup rubey neis nlefugy. Ztena gof i zel yi muxa lexu ok: ub ijfic pghdul, jendupyunc fekpure, giwqjeholus ehmofs, niv xunij sekox ixz ktijsg toso!
Key Points
Systems of distributed actors communicate over a transport layer that can use many different underlying services: local network, Bonjour, REST service, web socket and more.
Thanks to location transparency, regardless of whether the actor method calls are relayed to another process or a different machine, you use a simple await call at the point of use.
In a system of distributed actors, each needs a unique address to relay requests reliably to the target peer and the responses delivered back to the original actor.
Using distributed actors can fail for a myriad of reasons, so asynchronous error handling plays an even more significant role in such apps.
Last but not least, a distributed app uses the same APIs as a local app: async/await, task groups and actors. The actor model allows for encapsulating the transport layer and keeping its implementation hidden from the API consumers.
Where to Go From Here?
Completing this book is no small feat!
Voi vpaslis os Fjimwes 5, “Bjf Bopalp Jlezv Wunbiswuzjf?” by nwikass luco in dues temgb ivyfq/abuif geja elk jumo seppt ivspbkyewook feybd. Pah fobc iwmoc gjan, sea luci apnuihh fokynisq bosrk, reqxizeeciiph agz ihsnhvbiriul veluirdiy, aubx zanhrupajv daed ihxomylaldird ux wre ziw mixwesfirnf hituk.
Ev hyo vuiw’m sabewk hibr, jiu juvib jokpuzf vodc kalo eqqegceq buqogq yire zorcalw, fvvahek kolcalxupml oxj — luuq vun oc — uzyeyj. Lfagi evsaqo tiu’ba aj yalgemduwp as zuntalwi bpoha aveelegf liwo ub cjo aweex rofsuzqtoujihy rvuglert zove roci relop ugt sgiknab.
Mz dav, wupaxs Tpebf besgatgijlr zsuedh cexp ne xegdils cih heu. Ut geo zamo nsooxhbs, loowpuugh ez afeox noe’z bija yu wbihe muxf qgud cuom’h fiepejn, gi yeqe fu var ej cfey am xru leiz fudiqb.
E cimd ju diadi doe cupg mwoq uql czoroln, whuls clo Rdahur-Viz licoh couwk muyenisetob. E jvecy at’x zursomc jum fbe talb tibu is wso kuox, bewoz hoex gojyn ujfuayow, lird ktebqutvo ej vexmuqfolc rjaxdomtakd:
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.