Library Architecture
In this section, we will briefly explain some basic and generic knowledge about the Smarter AI platform libraries.
Method calling mechanism
Explicit Operation Mechanism
- You register a listener. Then call for an operation explicitly. The library performs the asked operation and sends the result back to you through the listener.
- This kind of operations are asynchronous.
- In this mechanism, the application layer and library layer maintains a Observer pattern.
The explicit method calling mechanism collaboration diagram is given below.
Event Subscription Mechanism
- You subscribe for events. And the platform sends you the events through the platform libraries.
- This is also asynchronous.
The event subscription mechanism collaboration diagram is given below.
Getting Readymade Information
- Library keeps some information ready by itself. You can call library methods and the method returns the result.
- This kind of operations are synchronous.
The event subscription mechanism collaboration diagram is given below.
Method Return Value
Return Value for Explicit Operation Methods
Each explicit operation method of the Smarter AI platform libraries returns a value containing the status of the method call. And the operation results are returned in the callbacks.
Methods of the Access
library returns an enum AccessRet
and the methods of Stream library returns an enum StreamRet
after each invocation.
See below for more details about AccessRet
and StreamRet
.
AccessRet
public enum AccessRet {
OK,
FAIL,
SERVICE_UNAVAILABLE,
NOT_RUNNING,
INVALID_PARAMETERS,
EXCEPTION_ID_INVALID,
EXCEPTION_SECRET_INVALID,
EXCEPTION_SECRET_EXPIRED,
EXCEPTION_CONSTRAINT_VIOLATION,
EXCEPTION_NO_CONNECTIVITY,
EXCEPTION_BAD_CALLBACK,
EXCEPTION_GENERIC
};
enum AccessRet : std::int32_t {
OK = 0,
FAIL = -1,
SERVICE_UNAVAILABLE = -2,
NOT_RUNNING = -3,
EXCEPTION_UNKNOWN_API = -4,
EXCEPTION_INVALID_QUERY = -5,
INVALID_PARAMETERS = -6,
EXCEPTION_ID_INVALID = -7,
EXCEPTION_SECRET_INVALID = -9,
EXCEPTION_SECRET_EXPIRED = -11,
EXCEPTION_CONSTRAINT_VIOLATION = -13,
EXCEPTION_NO_CONNECTIVITY = -15,
EXCEPTION_BAD_CALLBACK = -17,
EXCEPTION_INSUFFICIENT_PRIVILEGES = -18,
EXCEPTION_GENERIC = -21,
EXCEPTION_GENERIC_CLIENT_ERROR = -22,
EXCEPTION_GENERIC_SERVER_ERROR = -23,
EXCEPTION_LOGIN_FAILURE = -24,
EXCEPTION_ONBOARDING_FAILURE = -25,
EXCEPTION_INTERNAL = -26
};
Here is what each of the AccessRet
means
OK(0)
Method call is successful.FAIL(-1)
Method call has failed for passing wrong parameter(s) or the library fault.SERVICE_UNAVAILABLE(-2)
Method call has failed because Smarter AI REST service is temporarily unavailable.NOT_RUNNING(-3)
Access is not yet started. Call start() fromAccess
class before calling this API.EXCEPTION_UNKNOWN_API(-4)
Unknown API is invoked.EXCEPTION_INVALID_QUERY(-5)
Invalid query.INVALID_PARAMETERS(-6)
One or more parameters provided during API invocation are invalid.EXCEPTION_ID_INVALID(-7)
Provided Endpoint Id is invalid. This can happen when the Endpoint has been deleted/banned/removed/reset.EXCEPTION_SECRET_INVALID(-9)
Provided Endpoint secret is invalid. This can happen when the secret is tampered.EXCEPTION_SECRET_EXPIRED(-11)
Provided Endpoint secret is expired. You need to provision again in this case.EXCEPTION_CONSTRAINT_VIOLATION(-13)
Provided data on API invocation violated some constraint.EXCEPTION_NO_CONNECTIVITY(-15)
Access failed to reach Smarter AI REST server. This can happen when there is no Internet issue or service is blocked by your ISP etc.EXCEPTION_BAD_CALLBACK(-17)
Provided asynchronous callback function is badEXCEPTION_INSUFFICIENT_PRIVILEGES(-18)
Insufficient privilegesEXCEPTION_GENERIC(-21)
Method call has failed. Please check if you have done everything as expected before the method call.
Contact Us if you cannot solve it by yourself.EXCEPTION_GENERIC_CLIENT_ERROR(-22)
HTTP 400 series errorsEXCEPTION_GENERIC_SERVER_ERROR(-23)
HTTP 500 series errorsEXCEPTION_LOGIN_FAILURE(-24)
Login failedEXCEPTION_ONBOARDING_FAILURE(-25)
Onboarding failedEXCEPTION_INTERNAL(-26)
Internal error
StreamRet
```java
enum StreamRet {
OK,
NOT_STARTED,
INVALID_PARAMETERS,
FAIL
}
```
Here is what each of the StreamRet
means
OK
Method call is successful.NOT_STARTED
Stream is not started yet. Call start() fromStream
class before calling this API.INVALID_PARAMETERS
One or more parameters provided during API invocation are invalid.FAIL
Method call has failed. Please check if you have done everything as expected before the method call.
Contact Us if you cannot solve it by yourself.
Return Value for Readymade Information Methods
Each readymade information get operation method of Smarter AI platform libraries return the expected value directly. No callback need to be attached.
Status Codes for Access Library
The methods of the Access
library that works with explicit operation mechanism will return its response through the callback with a Status code. These status codes define whether the response is successful or failed due to some error.
The Status code is returned as Integer
indicates status as described in AccessRet.
Updated over 2 years ago