Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publishing rest messages - android only #2

Merged
merged 35 commits into from
Apr 28, 2020
Merged

Conversation

tiholic
Copy link
Contributor

@tiholic tiholic commented Apr 16, 2020

Spec creation from reference typescript IDL
Inspiration drawn from existing codebase and ably-java implementation.

Upgrade gradle and Ably java library.

  1. Rest instance creation (partially covered: Auth Spec)
  2. publish messages using rest instance (partially covered: Channels Spec, Channel Object spec)
  3. Error handling on connection failure
    • using AblyException (this will be used wherever appropriate in the library for throwing meaningful exceptions)
  4. test cases for plugin interacting code (rest and publishing rest messages)

This PR focuses only on Android based Rest instance. The file/folder structurization w.r.t RealTime / Push APIs still needs to be evolved.

This is an unstable release supporting android only.

Rohit R. Abbadi added 19 commits April 13, 2020 22:36
- moving few classes from `ably.dart` to `src/spec.dart`
 As we don't need them to be implemented as pure dart methods.
 Must be mixed with platform channel calls using PlatformObject.
- move necessary implementations from `src/ably_implementation.dart` to `src/impl/*.dart`

- use `ably.dart` only to export other files

- move code from `able.dart` to `interface.dart` and `defaults.dart`

- update example code

- update tests
- This will be required by multiple method calls as messages need to be casted for each method call
- spec refactored. classes in spec will be implemented wherever plugin functionality is necessary.

- classes in spec can be implemented in pure dart library (purely based on IDL and some java references)

- lib/src/impl will have all plugin related implementations

- example code updated with ably rest instance creation and publishing messages to a channel
…ler enhancement

- LibraryException renamed to AblyException

- AblyException takes code and message as positional arguments in that order
- codec moved to separate file

- TokenDetails included in codec

- bytecode for AblyMessage is changed to max available i.e, 255 thereby
giving it least preference and accommodate serialization other classes with lower code

- new `createRestWithKey` in Ably, for simpler instance creation

- Added few doc strings
platform messages posted to dart will be decoded by `readValueOfType`
- default log level will be info

- new platform tests for rest implementation (creation of instance)

- remove print statement from PlatformObject.invoke
@tiholic tiholic requested a review from QuintinWillison April 16, 2020 13:32
Copy link
Contributor

@QuintinWillison QuintinWillison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @tiholic!

Thanks - it looks like you've moved this quite a bit forward. 😁

I would certainly still expect, at this early stage, for these functional increments to be unstable and incomplete. So please don't feel you have to excuse yourself, though I would certainly encourage you to do your best to either:

  1. Always submit iOS and Android together as a single atomic increment alongside, obviously, the supporting Dart code.
  2. Make sure you submit iOS soon after Android so as to, apart from anything else, not lose your contextual advantage at that time. And, also, there's a chance that once you get on to iOS that you'll realise you need to refactor all the way up to the Dart again if something doesn't quite work the same way that it does in Android.

Going forward I would appreciate it if you could please try to keep the PRs as small as possible. In light of what I've just written above, this means that I'm asking you to find a comfortable size of functional increment that balances 'complete' (as defined in Agile terms) with simplicity/complexity for those reviewing. I'm happy to have a chat if you need me to expand more on what I mean here.

Thanks again. And please do keep feeding back to @mattheworiordan (and/or me) in respect of how you feel plugin development is going. We are particularly keen to be aware of anything you encounter that might affect the developer experience for Flutter developers encountering our plugin. You are there, at the coalface, so best positioned to detect and communicate issues or concerns - in particular those that might become blockers or usability constraints.

@tiholic
Copy link
Contributor Author

tiholic commented Apr 17, 2020

Thanks @QuintinWillison

Noted! Will try to keep iOS code updated in line with android.
And good point on why this has to be done. That's true in some situations.

And sure, will keep you and Matthew in loop about anything could become a challenge to developers using this plugin.

Copy link
Member

@mattheworiordan mattheworiordan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tiholic.

Great to see you are getting your head around it all and making progress.

I agree with Quintin's comments. One other thing I noticed is divergence from our IDL, which I'd like you to check at https://docs.ably.io/client-lib-development-guide/features/#idl as that is the only source of truth about the spec. I appreciate it's hard as I sent you the TypeScript IDL, which is a slight divergence from the spec as JS is not 100% compatible.

static const _valueAblyMessage = 255;

@override
void writeValue (final WriteBuffer buffer, final dynamic value) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't helping this can be DRY'd up somehow. Is this necessary to hard code every attribute like this, when these definitions exist in other places like the type specs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattheworiordan multiple reasons

  1. This part is specific to plugin while spec can be used by pure dart library
  2. Same order will be followed in Android/iOS code, so this will be a one place reference for all transferrable datatypes

@QuintinWillison your comments, please.

return t;
case _valueAblyMessage:
return AblyMessage(
readValue(buffer) as int,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comment in a previous commit about DRY'ing this up, seems even more necessary when I see this duplicated here.

@mattheworiordan
Copy link
Member

P.S. Before this is merged, please ensure [WIP] commits are renamed accordingly.

tiholic added 6 commits April 22, 2020 17:09
@paddybyers
Copy link
Member

@tiholic I've added some comments and responded to some of the questions.

@tiholic tiholic merged commit f96d808 into master Apr 28, 2020
tiholic added a commit that referenced this pull request Apr 28, 2020
Channels class is abstracted by a base channels class which is extended by Rest and Realtime each restricting their own Channel classes

The changes mentioned in below comment are also accommodated
#2 (comment)
tiholic added a commit that referenced this pull request Apr 28, 2020
@QuintinWillison QuintinWillison deleted the integration/plugin branch April 29, 2020 17:21
tiholic pushed a commit that referenced this pull request May 1, 2020
- `.fromKey` and `.fromOptions` are removed from high level interface
#2 (comment)

- Getting rid of XXXBase and XXX as it is only required for ably-java
 since it supports plain java and android
#2 (comment)
tiholic pushed a commit that referenced this pull request May 1, 2020
- Getting rid of XXXBase and XXX as it is only required for ably-java (since it supports plain java and android)
#2 (comment)
tiholic pushed a commit that referenced this pull request May 6, 2020
- `.fromKey` and `.fromOptions` are removed from high level interface
#2 (comment)

- Getting rid of XXXBase and XXX as it is only required for ably-java
 since it supports plain java and android
#2 (comment)
tiholic pushed a commit that referenced this pull request May 6, 2020
- Getting rid of XXXBase and XXX as it is only required for ably-java (since it supports plain java and android)
#2 (comment)
tiholic pushed a commit that referenced this pull request May 6, 2020
- `.fromKey` and `.fromOptions` are removed from high level interface
#2 (comment)

- Getting rid of XXXBase and XXX as it is only required for ably-java
 since it supports plain java and android
#2 (comment)
tiholic pushed a commit that referenced this pull request May 6, 2020
- Getting rid of XXXBase and XXX as it is only required for ably-java (since it supports plain java and android)
#2 (comment)
tiholic pushed a commit that referenced this pull request May 13, 2020
- `.fromKey` and `.fromOptions` are removed from high level interface
#2 (comment)

- Getting rid of XXXBase and XXX as it is only required for ably-java
 since it supports plain java and android
#2 (comment)
tiholic pushed a commit that referenced this pull request May 13, 2020
- Getting rid of XXXBase and XXX as it is only required for ably-java (since it supports plain java and android)
#2 (comment)
tiholic pushed a commit that referenced this pull request Jun 20, 2020
- `.fromKey` and `.fromOptions` are removed from high level interface
#2 (comment)

- Getting rid of XXXBase and XXX as it is only required for ably-java
 since it supports plain java and android
#2 (comment)
tiholic pushed a commit that referenced this pull request Jun 20, 2020
- Getting rid of XXXBase and XXX as it is only required for ably-java (since it supports plain java and android)
#2 (comment)
QuintinWillison added a commit that referenced this pull request Mar 19, 2021
Hoping to solve this error in workflow environment:

Unhandled exception:
Invalid argument (uri): Unknown package: Instance of '_SimpleUri'
#0      _resolveUri.<anonymous closure> (package:dartdoc/src/generator/resource_loader.dart:34:9)
#1      _RootZone.runUnary (dart:async/zone.dart:1612:54)
#2      _FutureListener.handleValue (dart:async/future_impl.dart:152:18)
#3      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:704:45)
#4      Future._propagateToListeners (dart:async/future_impl.dart:733:32)
#5      Future._completeWithValue (dart:async/future_impl.dart:539:5)
#6      Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:577:7)
#7      _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#8      _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#9      _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:120:13)
#10     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)
Error: Process completed with exit code 255.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants