In this lecture that I presented in the TDC, I will explain a brief experience using the framework CloudKit.
The problems found and the solutions to solve them.
Yet another presentation about Event Sourcing? Yes and no. Event Sourcing is a really great concept. Some could say it’s a Holy Grail of the software architecture. I might agree with that, while remembering that everything comes with a price. This session is a summary of my experience with ES gathered while working on 3 different commercial products. Instead of theoretical aspects, I will focus on possible challenges with ES implementation. What could explode (very often with delayed ignition)? How and where to store events effectively? What are possible schema evolution solutions? How to achieve the highest level of scalability and live with eventual consistency? And many other interesting topics that you might face when experimenting with ES.
Andrzej Ludwikowski - Event Sourcing - what could possibly go wrong? - Codemo...Codemotion
Yet another presentation about Event Sourcing? Yes and no. Event Sourcing is a really great concept. Some could say it’s a Holy Grail of the software architecture. True, but everything comes with a price. This session is a summary of my experience with ES gathered while working on 3 different commercial products. Instead of theoretical aspects, I will focus on possible challenges with ES implementation. What could explode? How and where to store events effectively? What are possible schema evolution solutions? How to achieve the highest level of scalability and live with eventual consistency?
Процесс разработки не начинается и не заканчивается на написании кода программного продукта. Мы пишем документацию, придумываем, как это всё оттестировать, и заботимся о том, чтобы доступность приложения была на высоком уровне.
Мы все делаем привычные вещи привычным для нас способом. Порой выполняя много ручной и неэффективной работы. Но что, если есть другой, радикальный подход. Можно ли формализовать свою деятельность и переложить её в код? Какие практики и инструменты для этого использовать?
В докладе будет представлен личный опыт автора по автоматизации различных элементов разработки ПО.
There is a problem of finding the correct operating services In a distributed systems with dynamic configuration. Currently, there are designed one and more solutions for the ever-changing storage configuration. It should be mentioned at least Netflix Eureka, Consul, etcd or good old Zookeeper. Spring Cloud project allows to integrate some of these solutions to your project and provides powerful solutions for typical problems. However, on the way to unicorns not the most obvious subtleties of implementation and associated problems of use in real projects wait for a developer.
This talk will review the internal structure SpringCloud, implementation of Client-Side Service Discovery pattern, and specific details of concrete implementations on the example of the official libraries and the author's own library.
Yet another presentation about Event Sourcing? Yes and no. Event Sourcing is a really great concept. Some could say it’s a Holy Grail of the software architecture. I might agree with that, while remembering that everything comes with a price. This session is a summary of my experience with ES gathered while working on 3 different commercial products. Instead of theoretical aspects, I will focus on possible challenges with ES implementation. What could explode (very often with delayed ignition)? How and where to store events effectively? What are possible schema evolution solutions? How to achieve the highest level of scalability and live with eventual consistency? And many other interesting topics that you might face when experimenting with ES.
Andrzej Ludwikowski - Event Sourcing - what could possibly go wrong? - Codemo...Codemotion
Yet another presentation about Event Sourcing? Yes and no. Event Sourcing is a really great concept. Some could say it’s a Holy Grail of the software architecture. True, but everything comes with a price. This session is a summary of my experience with ES gathered while working on 3 different commercial products. Instead of theoretical aspects, I will focus on possible challenges with ES implementation. What could explode? How and where to store events effectively? What are possible schema evolution solutions? How to achieve the highest level of scalability and live with eventual consistency?
Процесс разработки не начинается и не заканчивается на написании кода программного продукта. Мы пишем документацию, придумываем, как это всё оттестировать, и заботимся о том, чтобы доступность приложения была на высоком уровне.
Мы все делаем привычные вещи привычным для нас способом. Порой выполняя много ручной и неэффективной работы. Но что, если есть другой, радикальный подход. Можно ли формализовать свою деятельность и переложить её в код? Какие практики и инструменты для этого использовать?
В докладе будет представлен личный опыт автора по автоматизации различных элементов разработки ПО.
There is a problem of finding the correct operating services In a distributed systems with dynamic configuration. Currently, there are designed one and more solutions for the ever-changing storage configuration. It should be mentioned at least Netflix Eureka, Consul, etcd or good old Zookeeper. Spring Cloud project allows to integrate some of these solutions to your project and provides powerful solutions for typical problems. However, on the way to unicorns not the most obvious subtleties of implementation and associated problems of use in real projects wait for a developer.
This talk will review the internal structure SpringCloud, implementation of Client-Side Service Discovery pattern, and specific details of concrete implementations on the example of the official libraries and the author's own library.
Docker on a local machine and Docker in production — are two big differences. It's easy to play with technology but it's hard to do something real for many customers.
Half a year ago inside of Alpha Laboratory (division of Alfa-Bank) we've started building new microservices architecture for one of our pilot projects. We've almost completely changed a stack of the used technologies on a frontend and significantly changed it on a middle layer. For package and distribution we have choosen Docker. Two months ago we've deployed project to production and have opened service for clients.
In the report the following topics will be covered:
- reasons of a choice Docker;
- why Docker without other tools is not enough for a production;
- what stack of technologies we used in our solution;
- what advantages we've got;
- what problems have been faced and how we've solved them.
Distributed Eventing in OSGi - Carsten Ziegelermfrancis
OSGi Community Event 2013 (http://www.osgi.org/CommunityEvent2013/Schedule)
ABSTRACT
One of the major topics the OSGi alliance is working on is a proposal for distributed eventing especially in the cloud. This session starts with an overview of the current state in the alliance and then shows already available solutions from the Apache Sling open source project. This includes distributing events through event admin and controlled processing of events by exactly one processor in distributed installations. The current implementations will be set in context to the ongoing activations in the alliance.
SPEAKER BIO
Carsten Ziegeler is senior developer at Adobe Research Switzerland and spends most of his time on architectural and infrastructure topics. Working for over 25 years in open source projects, Carsten is a member of the Apache Software Foundation and heavily participates in several Apache communities including Sling, Felix and ACE. He is a frequent speaker on technology and open source conferences and participates in the OSGi Core Platform and Enterprise expert groups.
Test Driven Documentation with Spring Rest Docs JEEConf2017Roman Tsypuk
My talk on JEEConf about Spring Rest Docs, Swagger and Test Driven Documentation.
Material covers:
1. Swagger. SpringFox
2. Swagger approaches and trade-offs
3. Test Driven Development → Test Driven Documentation
4. Live Coding session - how to connect and start using SpringRestDocs
5. Spring Rest Docs features
6. AsciiDoc is awesome (syntax, examples, extensions).
7. Migration of your project from Swagger to SpringRestDocs
Simon Stratton from Safebear hosted a workshop on building a blockchain using hyper ledger. If you are interested in programming or building a simple block chain this presentation is for you.
These are the slides of my talk at iOSCon 2017: https://skillsmatter.com/skillscasts/9549-architecting-alive-apps
Our apps are ever more alive. They interact with the rest of the world talking to backends and receiving notifications from them. They get their input from us and from other sensors. They are even aware of the location of the device they run in, or its position. But, in our IoT world, they may also detect presence in a room, get the temperature of it, or change the color of its lights.
Sadly enough, many of the apps available today with those capabilities have some architectural limitations:
Many of them are written in a way that is really dependent on a specific hardware.
Some restrict their use cases to whatever is provided by the hardware devices.
And almost all of them expect having a connection with the real device as the only way to test if they work properly.
However, we can also use an advanced architecture, like the Clean Architecture, to create a beautiful, scalable, testable, and robust application. Join Jorge and he will share with you how you can do it!
This is a "Code or it didn't happen" (TM) talk.
Docker on a local machine and Docker in production — are two big differences. It's easy to play with technology but it's hard to do something real for many customers.
Half a year ago inside of AlfaLab (division of Alfa-Bank) we've started building architecture with microservices approach for few our pilot projects. We've almost completely changed a stack of the used technologies on a frontend and significantly changed it on a middle layer. For package and distribution we have choosen Docker. Two months ago we've deployed project to production and have opened service for clients.
In the report the following topics will be covered:
- reasons of a choice Docker;
- why Docker without other tools is not enough for a production;
- what stack of technologies we used in our solution;
- what advantages we've got;
- what problems have been faced and how we've solved them.
Custom deployments with sbt-native-packagerGaryCoady
sbt-native-packager offers a comprehensive approach to packaging artifacts with SBT. The user describes a generic layout, which can then be extended for different types of software and deployments. For example, it is flexible enough to describe both a Zip-based archive format, and an RPM package with appropriate Systemd configuration for a service.
This talk will cover the essentials needed to understand the design of sbt-native-packager, and how to extend its structure to create custom layouts and deployments.
Docker on a local machine and Docker in production — are two big differences. It's easy to play with technology but it's hard to do something real for many customers.
Half a year ago inside of Alpha Laboratory (division of Alfa-Bank) we've started building new microservices architecture for one of our pilot projects. We've almost completely changed a stack of the used technologies on a frontend and significantly changed it on a middle layer. For package and distribution we have choosen Docker. Two months ago we've deployed project to production and have opened service for clients.
In the report the following topics will be covered:
- reasons of a choice Docker;
- why Docker without other tools is not enough for a production;
- what stack of technologies we used in our solution;
- what advantages we've got;
- what problems have been faced and how we've solved them.
Distributed Eventing in OSGi - Carsten Ziegelermfrancis
OSGi Community Event 2013 (http://www.osgi.org/CommunityEvent2013/Schedule)
ABSTRACT
One of the major topics the OSGi alliance is working on is a proposal for distributed eventing especially in the cloud. This session starts with an overview of the current state in the alliance and then shows already available solutions from the Apache Sling open source project. This includes distributing events through event admin and controlled processing of events by exactly one processor in distributed installations. The current implementations will be set in context to the ongoing activations in the alliance.
SPEAKER BIO
Carsten Ziegeler is senior developer at Adobe Research Switzerland and spends most of his time on architectural and infrastructure topics. Working for over 25 years in open source projects, Carsten is a member of the Apache Software Foundation and heavily participates in several Apache communities including Sling, Felix and ACE. He is a frequent speaker on technology and open source conferences and participates in the OSGi Core Platform and Enterprise expert groups.
Test Driven Documentation with Spring Rest Docs JEEConf2017Roman Tsypuk
My talk on JEEConf about Spring Rest Docs, Swagger and Test Driven Documentation.
Material covers:
1. Swagger. SpringFox
2. Swagger approaches and trade-offs
3. Test Driven Development → Test Driven Documentation
4. Live Coding session - how to connect and start using SpringRestDocs
5. Spring Rest Docs features
6. AsciiDoc is awesome (syntax, examples, extensions).
7. Migration of your project from Swagger to SpringRestDocs
Simon Stratton from Safebear hosted a workshop on building a blockchain using hyper ledger. If you are interested in programming or building a simple block chain this presentation is for you.
These are the slides of my talk at iOSCon 2017: https://skillsmatter.com/skillscasts/9549-architecting-alive-apps
Our apps are ever more alive. They interact with the rest of the world talking to backends and receiving notifications from them. They get their input from us and from other sensors. They are even aware of the location of the device they run in, or its position. But, in our IoT world, they may also detect presence in a room, get the temperature of it, or change the color of its lights.
Sadly enough, many of the apps available today with those capabilities have some architectural limitations:
Many of them are written in a way that is really dependent on a specific hardware.
Some restrict their use cases to whatever is provided by the hardware devices.
And almost all of them expect having a connection with the real device as the only way to test if they work properly.
However, we can also use an advanced architecture, like the Clean Architecture, to create a beautiful, scalable, testable, and robust application. Join Jorge and he will share with you how you can do it!
This is a "Code or it didn't happen" (TM) talk.
Docker on a local machine and Docker in production — are two big differences. It's easy to play with technology but it's hard to do something real for many customers.
Half a year ago inside of AlfaLab (division of Alfa-Bank) we've started building architecture with microservices approach for few our pilot projects. We've almost completely changed a stack of the used technologies on a frontend and significantly changed it on a middle layer. For package and distribution we have choosen Docker. Two months ago we've deployed project to production and have opened service for clients.
In the report the following topics will be covered:
- reasons of a choice Docker;
- why Docker without other tools is not enough for a production;
- what stack of technologies we used in our solution;
- what advantages we've got;
- what problems have been faced and how we've solved them.
Custom deployments with sbt-native-packagerGaryCoady
sbt-native-packager offers a comprehensive approach to packaging artifacts with SBT. The user describes a generic layout, which can then be extended for different types of software and deployments. For example, it is flexible enough to describe both a Zip-based archive format, and an RPM package with appropriate Systemd configuration for a service.
This talk will cover the essentials needed to understand the design of sbt-native-packager, and how to extend its structure to create custom layouts and deployments.
In this session, we will discuss the top 10 mobile apps architectures and how you can leverage the new cross-platform AWS Mobile Services to build a highly scalable and reliable mobile app, powered by the AWS Cloud. We will explore core functionality like authentication and authorization of users, data synchronization, backend infrastructure without the need to manage servers, understanding your user behavior, engaging your users and bringing your users back to your app. No matter if you are building the next great social app, or a front-office enterprise mobile app, this session will discuss best practices and reference architectures for building reliable and scalable mobile apps.
This talk represents the combined experience from several web development teams who have been using Symfony2 since months already to create high profile production applications. The aim is to give the audience real world advice on how to best leverage Symfony2, the current rough spots and how to work around them. Aside from covering how to implement functionality in Symfony2, this talk will also cover topics such as how to best integrate 3rd party bundles and where to find them as well as how to deploy the code and integrate into the entire server setup.
Talk about add proxy user in Spark Task execution time given in Spark Summit East 2017 by Jorge López-Malla and Abel Ricon
full video:
https://www.youtube.com/watch?v=VaU1xC0Rixo&feature=youtu.be
Cassandra Summit 2014: Highly Scalable Web Application in the Cloud with Cass...DataStax Academy
Presenters, L
Putting together a cloud based web application that allows end users to upload, encode, manage and distribute video media files is not a difficult task these days. Especially with the number of related frameworks and services available, ready to be used or consumed. The situation gets more complex when the expected traffic is in the millions-of-users range, globally distributed, and requiring detailed monitoring for usage. Using this scenario, in this session you will learn how to use the recently updated Datastax C# Cassandra driver, how to deploy a multi-datacenter Cassandra cluster using the Microsoft Azure platform that can be accessed from different programming languages, and how to leverage existing cloud services to perform some of the tasks associated with this use case.
Tackle Containerization Advisor (TCA) for Legacy ApplicationsKonveyor Community
Recording of presentation: https://youtu.be/VapEooROERw
With the adoption of cloud services and the reliability and resiliency it offers, enterprises are eager to understand how many of their legacy applications can be containerized.
We propose Tackle Containerization Advisor (TCA), a framework that provides a containerization advisory for legacy applications.
Given an application description in terms of its technical components, TCA proposes a multi-step process that standardizes the raw inputs and curates technology stack into various components, detects missing components and finally recommends the best possible containerization approach.
Presenter: Anup Kalia, Research Staff Member @ IBM Research
GitHub: https://github.com/konveyor/tackle-container-advisor
In this talk, a closer look into the lifecycle of operators will be presented. With an understanding of how operators evolve, it becomes clear what
challenges during operator upgrades. A brief overview of lifecycle management tools such as Helm, OLM, and Carvel is presented in this context. In particular, it will be discussed whether these tools can help, which restrictions apply and where further development would be desirable.
At the end of this talk, you will know what operator lifecycle management is about, what its challenges are, and which tools may be used to reduce operational friction.
This talk was given by Julian Fischer for DoK Day Europe @ KubeCon 2022.
Link: https://youtu.be/_lQhoCUQReU
https://go.dok.community/slack
https://dok.community/
From the DoK Day EU 2022 (https://youtu.be/Xi-h4XNd5tE)
The ability to extend Kubernetes with Custom Resource Definitions and respective controllers has led to the OperatorSDK, which became
the de facto standard for data service automation on Kubernetes. There are countless operator implementations available, and new operators are
being released on a daily basis. Organizations managing hundreds of Kubernetes clusters for dozens of developer teams are also challenged to
manage the lifecycle of hundreds of Kubernetes operators. The goal is to keep the operational overhead to a minimum.
In this talk, a closer look into the lifecycle of operators will be presented. With an understanding of how operators evolve, it becomes clear what
challenges during operator upgrades. A brief overview of lifecycle management tools such as Helm, OLM, and Carvel is presented in this context. In particular, it will be discussed whether these tools can help, which restrictions apply and where further development would be desirable.
At the end of this talk, you will know what operator lifecycle management is about, what its challenges are, and which tools may be used to reduce operational friction.
-----
Julian Fischer, CEO of anynines, has dedicated his career to the automation of software operations. In more than fifteen years, he has built several application platforms. He has been using Kubernetes, Cloud Foundry, and BOSH in recent years. Within platform automation, Julian has a strong focus on data service automation at scale.
ITT 2014 - Peter Steinberger - Architecting Modular CodebasesIstanbul Tech Talks
Everyone knows the pain of convoluted code as an application grows and feature after feature is being added. In this talk Peter lets you explore ideas how to grow your project in a healthy, maintainable way, how to manage dependencies, how to design code around testability, how to write plugins and even some practical solutions around the idea of aspect oriented programming. This is all based on a large-scale 150k lines project and Peter shows some production code as well.
FLOW3 is a web application platform which uses Domain-Driven Design as its major underlying concept. This approach makes FLOW3 easy to learn and at the same time clean and flexible for complex projects. It features namespaces, has an emphasis on clean, object-oriented code and provides a seemless Doctrine 2 integration.
FLOW3 incorporates Dependency Injection in a way which lets you truly enjoy creating a stable and easy-to-test application architecture (no configuration necessary). Being the only Aspect-Oriented Programming capable PHP framework, FLOW3 allows you to cleanly separate cross-cutting concerns like security from your main application logic.
This tutorial takes you through an imaginary project from scratch. During the journey we’ll visit all important areas of the framework.
Docker Kubernetes Istio
Understanding Docker and creating containers.
Container Orchestration based on Kubernetes
Blue Green Deployment, AB Testing, Canary Deployment, Traffic Rules based on Istio
In this meetup, Liran Cohen, Cloud platform & DevOps Team Leader, will talk about some of Kubernetes key concepts. We will learn about the architecture of the system; the different resources available in the system; the problems it’s trying to solve, and the model that it uses to manage containerized application deployments.
Unleashing Docker with Pipelines in Bitbucket CloudAtlassian
For those using Bitbucket Cloud, Bitbucket Pipelines makes Docker a first class citizen in your CI/CD cycle. Join Bitbucket Pipelines developer Philip Hodder to learn how containers are changing the way developers build software for the cloud, enabling faster development and safer deployments in a microservices world. He'll use practical, real-world examples to show best practices for testing, building, and pushing your Docker containers in the cloud when using Bitbucket Pipelines.
Philip Hodder, Developer, Atlassian
Similar to The Developer Conference - CloudKit, entendendo a Cloud da Apple (20)
28. Database
CKDatabase
Public PrivatePrivate
Public Private
let publicDatabase = CKContainer.defaultContainer().publicCloudDatabase
let privateDatabase = CKContainer.defaultContainer().privateCloudDatabase
• Every app access to at least one container.
• Every container has two databases
29. Database
Public Private
Data Type Shared Data User’s Data
Account Required for writing Required
Quota Developer User
Default Permissions World Redable User readable
Editing Permissions Dashboard Rules N/A
31. CKRecord class
Record
Structured data
Wraps key/values pairs
Metadata
Record Values
• String
• NSNumber
• NSDate
• NSData
• CLLocation
• CKAsset
• CKReference
Array of these types
32. let session = CKRecord(recordType: "Session")
session["name"] = "Endentendo a Cloudkit da Apple"
session["author"] = "Rodrigo Leite"
session["start_date"] = NSDate()
Record
33. Record
class session: CKRecord{
func name() -> String?{
return self["name"] as? String
}
func author() -> String?{
return self["author"] as? String
}
....
}
• Subclassing
Apple Docs
34. Record
class Session: NSObject{
let record: CKRecord?
var name: String?{
didSet{
record!["name"] = name
}
}
var author: String?{
didSet{
record!["author"] = name
}
}
init(record: CKRecord){
self.record = record
self.name = self.record!["name"] as? String
self.author = self.record!["author"] as? String
}
}
Apple Docs
36. Record Identifier
public class CKRecord : NSObject, NSSecureCoding, NSCopying {
/* These create the record in the default zone. */
public init(recordType: String)
public init(recordType: String, recordID: CKRecordID)
public init(recordType: String, zoneID: CKRecordZoneID)
public var recordType: String { get }
@NSCopying public var recordID: CKRecordID { get }
/* Change tags are updated by the server to a unique value every time a record is modified.
A different change tag necessarily means that the contents of the record are different. */
public var recordChangeTag: String? { get }
/* This is a User Record recordID, identifying the user that created this record. */
@NSCopying public var creatorUserRecordID: CKRecordID? { get }
@NSCopying public var creationDate: NSDate? { get }
/* This is a User Record recordID, identifying the user that last modified this record. */
@NSCopying public var lastModifiedUserRecordID: CKRecordID? { get }
@NSCopying public var modificationDate: NSDate? { get }
..
}
• The identifier of the record in the cloud kit
41. Assets
• CKAsset class
• Large, unstructured data
•Files on disk
•Owned by records
•Removed when owner is deleted
let attendee = CKRecord(recordType: "Attendee")
let image = UIImage(named: "")!
let documentDirectory = NSSearchPathForDirectoriesInDomains(.DocumentDirectory,
.UserDomainMask,
true).first! as String
let localPath = documentDirectory + "/profilePicture"
let data = UIImageJPEGRepresentation(image, 0.85)
data!.writeToFile(localPath, atomically: true)
let photoURL = NSURL(fileURLWithPath: localPath)
let asset = CKAsset(fileURL: photoURL)
attendee["profileImage"] = asset
45. extension CKDatabase {
/* Convenience APIs
These calls operate on a single item in the default zone and allow for simple operations.
If you'd like to batch your requests, add dependencies between requests, set priorities,
or schedule operations on your own queue, take a look at the corresponding CKOperation.
This work is treated as having NSQualityOfServiceUserInitiated quality of service.
*/
/* CKFetchRecordsOperation and CKModifyRecordsOperation are the more configurable,
CKOperation-based alternatives to these methods */
public func fetchRecordWithID(recordID: CKRecordID, completionHandler: (CKRecord?, NSError?) -> Void)
public func saveRecord(record: CKRecord, completionHandler: (CKRecord?, NSError?) -> Void)
public func deleteRecordWithID(recordID: CKRecordID, completionHandler: (CKRecordID?, NSError?) -> Void)
/* CKQueryOperation is the more configurable, CKOperation-based
alternative to this method */
public func performQuery(query: CKQuery, inZoneWithID zoneID: CKRecordZoneID?, completionHandler: ([CKRecord]?,
NSError?) -> Void)
/* CKFetchRecordZonesOperation and CKModifyRecordZonesOperation are the more configurable,
CKOperation-based alternatives to these methods */
public func fetchAllRecordZonesWithCompletionHandler(completionHandler: ([CKRecordZone]?, NSError?) -> Void)
public func fetchRecordZoneWithID(zoneID: CKRecordZoneID, completionHandler: (CKRecordZone?, NSError?) -> Void)
public func saveRecordZone(zone: CKRecordZone, completionHandler: (CKRecordZone?, NSError?) -> Void)
public func deleteRecordZoneWithID(zoneID: CKRecordZoneID, completionHandler: (CKRecordZoneID?, NSError?) -> Void)
/* CKFetchSubscriptionsOperation and CKModifySubscriptionsOperation are the more configurable,
CKOperation-based alternative to these methods */
public func fetchSubscriptionWithID(subscriptionID: String, completionHandler: (CKSubscription?, NSError?) -> Void)
public func fetchAllSubscriptionsWithCompletionHandler(completionHandler: ([CKSubscription]?, NSError?) -> Void)
public func saveSubscription(subscription: CKSubscription, completionHandler: (CKSubscription?, NSError?) -> Void)
public func deleteSubscriptionWithID(subscriptionID: String, completionHandler: (String?, NSError?) -> Void)
}
Convenience API
46. let session = CKRecord(recordType: "Session")
session["name"] = "Endentendo a Cloudkit da Apple"
session["author"] = "Rodrigo Leite"
session["start_date"] = NSDate()
let publicDatabase = CKContainer.defaultContainer().publicCloudDatabase
publicDatabase.saveRecord(session) { (record: CKRecord?, error: NSError?) in
if (error != nil){
/* Error handling */
}else{
}
}
Save Object
Convenience API
47. Fetch Object
Convenience API
let database = CKContainer.defaultContainer().publicCloudDatabase
database.fetchRecordWithID(recordID) { (record, error) in
if error != nil {
/* *** ERROR HANDLING **** */
}else{
}
}
49. Basic NSOperation
public class NSOperation : NSObject {
/* **** LIFE CYCLE **** */
public var completionBlock: (() -> Void)?
public func cancel()
/* ***** STATE ***** */
public var executing: Bool { get }
public var finished: Bool { get }
/* ***** DEPENDENCIES **** */
public func addDependency(op: NSOperation)
public func removeDependency(op: NSOperation)
}
50. Basic NSOperationQueue
public class NSOperationQueue : NSObject {
/* ******* START OPERATION **** */
public func addOperations(ops: [NSOperation], waitUntilFinished wait: Bool)
public var operations: [NSOperation] { get }
/* ****** CANCEL OPERATION **** */
public var suspended: Bool
public func cancelAllOperations()
}
51. CKOperation
public class CKFetchRecordsOperation : CKDatabaseOperation {
public init()
public convenience init(recordIDs: [CKRecordID])
public class func fetchCurrentUserRecordOperation() -> Self
public var recordIDs: [CKRecordID]?
/* Declares which user-defined keys should be fetched and added to the resulting CKRecords. If nil,
declares the entire record should be downloaded. If set to an empty array, declares that no user fields should
be downloaded. Defaults to nil. */
public var desiredKeys: [String]?
/* Called repeatedly during transfer. */
public var perRecordProgressBlock: ((CKRecordID, Double) -> Void)?
/* Called on success or failure for each record. */
public var perRecordCompletionBlock: ((CKRecord?, CKRecordID?, NSError?) -> Void)?
/* This block is called when the operation completes.
The [NSOperation completionBlock] will also be called if both are set.
If the error is CKErrorPartialFailure, the error's userInfo dictionary contains
a dictionary of recordIDs to errors keyed off of CKPartialErrorsByItemIDKey.
*/
public var fetchRecordsCompletionBlock: (([CKRecordID : CKRecord]?, NSError?) -> Void)?
}
52. let database = CKContainer.defaultContainer().publicCloudDatabase
database.fetchRecordWithID(recordID) { (record, error) in
...
database.fetchRecordWithID(otherRecordID, completionHandler: { (record, error) in
...
database.saveRecord(otherRecord, completionHandler: { (record, error) in
....
})
})
}
Convenience API
53. var session : CKRecord?
var attendees = [CKRecord]()
let firstQuery = CKQuery(recordType: "Session", predicate: NSPredicate(format: "name == %@", "Cloudkit"))
let firstFetch = CKQueryOperation(query: firstQuery)
firstFetch.recordFetchedBlock = { record in
session = record
}
let reference = CKReference(record: session!, action: .None )
let secondQuery = CKQuery(recordType: "Atendee", predicate: NSPredicate(format: "reference == %@",
reference))
let secondFetch = CKQueryOperation(query: secondQuery)
secondFetch.recordFetchedBlock = { record in
attendees.append(record)
}
secondFetch.addDependency(firstFetch)
let queue = NSOperationQueue()
queue.addOperations([firstFetch, secondFetch], waitUntilFinished: false)
Dependent Task
• Fetch all attendee in a session
55. NSPredicate
CKQuery
CKQuery only accepts a subset of predicate behaviors
Rules
• Predicates are based on a format string
• Predicates operate only on fields containing primitive data forms