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

A more general purpose API? #97

Open
brodycj opened this issue Jan 25, 2018 · 2 comments
Open

A more general purpose API? #97

brodycj opened this issue Jan 25, 2018 · 2 comments

Comments

@brodycj
Copy link

brodycj commented Jan 25, 2018

Looking through https://github.com/gritzko/swarm/tree/master/packages/client I get an impression that it should be possible to achieve some more flexibility by designing it to work with pluggable storage and backend connection drivers.

If we get it right then it may be possible to use the same module on the server side to coordinate between client connections, local cache or data storage, and lower tiers.

I would be happy to work on this idea if there is sufficient interest.

@olebedev
Copy link
Collaborator

Hi @brodybits,

Contributions are always welcome!
Running the same code at all the tiers is a very interesting option.

Client already has interfaces for storage

export interface Storage {
  set(key: string, value: string): Promise<void>;
  get(key: string): Promise<?string>;
  remove(key: string): Promise<void>;
  keys(): Promise<Array<string>>;
}

and connection

export interface Connection {
  onmessage: (ev: MessageEvent) => any;
  onopen: (ev: Event) => any;
  send(data: string): void;
  readyState: number;
}

Does it fit your needs? If not, please provide more details.

@brodycj
Copy link
Author

brodycj commented Jan 26, 2018

Thanks @olebedev for the response, it seems to make sense. I will probably have to read through the code some more to better understand what is needed to get it to properly support multiple tiers, with flexible pluggable components, with some things such as:

  • client-server connection using pluggable modules to deal with connection and security aspects (auth0 comes to my mind)
  • pluggable database/data storage implementation on server side; I think it would be a major win to interface to proven systems such as Redis, PostgreSQL, etc. etc.
  • bonus: support for additional server-side tiers, geographical distribution, etc.

I would be happy to raise one or more new issues to discuss, if necessary.

I just raised #98 to ask about available documentation. I was also wondering what made you guys decide to merge this as a "monorepo"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants