Add basic Weles structure 69/158869/10
authorAleksander Mistewicz <a.mistewicz@samsung.com>
Thu, 16 Nov 2017 15:49:59 +0000 (16:49 +0100)
committerAleksander Mistewicz <a.mistewicz@samsung.com>
Wed, 22 Nov 2017 10:36:14 +0000 (11:36 +0100)
Each interface, used or implemented by many components, should
be defined in the file with the same name as said interface in
basic, weles, package. Definitions of all non-interface types
related to it should be stored in the same file. The remaining
types, if common to multiple interfaces, should be defined
in main package file: weles.go.

The purpose is to have packages to depend on basic package, but not each
other. Moreover a developer will not need to look into documentation or
search for definition of interface as the location of such definition
will be known by interface's name.

This patch also defines manager's interfaces and structures in described
format.

Change-Id: Ie1bf89c8e7e4af28617cc00f21d6193c4b7517d1
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
dryadjobmanager.go [new file with mode: 0644]
weles.go [new file with mode: 0644]

diff --git a/dryadjobmanager.go b/dryadjobmanager.go
new file mode 100644 (file)
index 0000000..1a1b79a
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ *  Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+
+// File dryadjobmanager.go defines DryadJobManager interface and structures related to it.
+
+package weles
+
+// DryadJobStatus is a representation of current state of DryadJob.
+type DryadJobStatus string
+
+const (
+       // DJ_NEW - initial status of DryadJob after call to Create.
+       DJ_NEW DryadJobStatus = "CREATED"
+       // DJ_DEPLOY - DryadJob is executing deploy section of job definition.
+       DJ_DEPLOY DryadJobStatus = "DEPLOYING"
+       // DJ_BOOT - DryadJob is executing boot section of job definition.
+       DJ_BOOT DryadJobStatus = "BOOTING"
+       // DJ_TEST - DryadJob is executing test section of job definition.
+       DJ_TEST DryadJobStatus = "EXECUTING TESTS"
+       // DJ_FAIL - an irrecoverable error has been encountered
+       // and execution had to be stopped early.
+       DJ_FAIL DryadJobStatus = "ERROR OCCURRED"
+       // DJ_OK - DryadJob has finished execution successfully.
+       DJ_OK DryadJobStatus = "DONE"
+)
+
+// DryadJobInfo contains information about DryadJob.
+type DryadJobInfo struct {
+       Job    JobID
+       Status DryadJobStatus
+}
+
+// DryadJobStatusChange is information passed on the channel to the caller of Create.
+type DryadJobStatusChange DryadJobInfo
+
+// Dryad contains information about device allocated for Job
+// and credentials required to use it.
+type Dryad struct{}
+
+// DryadJobFilter is used by List to access only jobs of interest.
+//
+// Job is matching DryadJobFilter if References contain value of
+// its Job field and Statuses - Status.
+type DryadJobFilter struct {
+       References []JobID
+       Statuses   []DryadJobStatus
+}
+
+// DryadJobManager organizes running Jobs on allocated Dryad.
+type DryadJobManager interface {
+       // Create starts execution of Job definition on allocated Dryad.
+       //
+       // Slow read from a channel may miss some events.
+       Create(JobID, Dryad, chan<- DryadJobStatusChange) error
+
+       // Cancel stops DryadJob associated with Job.
+       //
+       // It has no effect if Cancel has been called before
+       // or job has already terminated.
+       Cancel(JobID) error
+
+       // List returns information about DryadJobs matching DryadJobFilter
+       // or all if it is not specified.
+       List(*DryadJobFilter) ([]DryadJobInfo, error)
+}
diff --git a/weles.go b/weles.go
new file mode 100644 (file)
index 0000000..9244725
--- /dev/null
+++ b/weles.go
@@ -0,0 +1,21 @@
+/*
+ *  Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+
+// Package weles represents the base of the Weles system.
+package weles
+
+// JobID is a reference to Job.
+type JobID uint64