feat(llc): Deprecate location in favor of edge server.
Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
## Upcoming
|
## Upcoming
|
||||||
|
|
||||||
|
🔄 Changed
|
||||||
|
|
||||||
|
- `client.location` is now deprecated in favor of the new [edge server](https://getstream.io/blog/chat-edge-infrastructure) and will be removed in v4.0.0.
|
||||||
|
|
||||||
✅ Added
|
✅ Added
|
||||||
|
|
||||||
- Added `client.enrichUrl` endpoint for enriching URLs with metadata.
|
- Added `client.enrichUrl` endpoint for enriching URLs with metadata.
|
||||||
|
|||||||
@@ -66,8 +66,11 @@ class StreamChatClient {
|
|||||||
this.logLevel = Level.WARNING,
|
this.logLevel = Level.WARNING,
|
||||||
LogHandlerFunction? logHandlerFunction,
|
LogHandlerFunction? logHandlerFunction,
|
||||||
RetryPolicy? retryPolicy,
|
RetryPolicy? retryPolicy,
|
||||||
Location? location,
|
@Deprecated('''
|
||||||
@Deprecated('Use location to change baseUrl instead') String? baseURL,
|
Location is now deprecated in favor of the new edge server. Will be removed in v4.0.0.
|
||||||
|
Read more here: https://getstream.io/blog/chat-edge-infrastructure
|
||||||
|
''') Location? location,
|
||||||
|
String? baseURL,
|
||||||
Duration connectTimeout = const Duration(seconds: 6),
|
Duration connectTimeout = const Duration(seconds: 6),
|
||||||
Duration receiveTimeout = const Duration(seconds: 6),
|
Duration receiveTimeout = const Duration(seconds: 6),
|
||||||
StreamChatApi? chatApi,
|
StreamChatApi? chatApi,
|
||||||
@@ -79,7 +82,6 @@ class StreamChatClient {
|
|||||||
|
|
||||||
final options = StreamHttpClientOptions(
|
final options = StreamHttpClientOptions(
|
||||||
baseUrl: baseURL,
|
baseUrl: baseURL,
|
||||||
location: location,
|
|
||||||
connectTimeout: connectTimeout,
|
connectTimeout: connectTimeout,
|
||||||
receiveTimeout: receiveTimeout,
|
receiveTimeout: receiveTimeout,
|
||||||
headers: {'X-Stream-Client': defaultUserAgent},
|
headers: {'X-Stream-Client': defaultUserAgent},
|
||||||
|
|||||||
@@ -1,32 +1,20 @@
|
|||||||
part of 'stream_http_client.dart';
|
part of 'stream_http_client.dart';
|
||||||
|
|
||||||
const _defaultBaseURL = 'https://chat-us-east-1.stream-io-api.com';
|
const _defaultBaseURL = 'https://chat.stream-io-api.com';
|
||||||
|
|
||||||
/// Client options to modify [StreamHttpClient]
|
/// Client options to modify [StreamHttpClient]
|
||||||
class StreamHttpClientOptions {
|
class StreamHttpClientOptions {
|
||||||
/// Instantiates a new [StreamHttpClientOptions]
|
/// Instantiates a new [StreamHttpClientOptions]
|
||||||
const StreamHttpClientOptions({
|
const StreamHttpClientOptions({
|
||||||
String? baseUrl,
|
String? baseUrl,
|
||||||
this.location,
|
|
||||||
this.connectTimeout = const Duration(seconds: 6),
|
this.connectTimeout = const Duration(seconds: 6),
|
||||||
this.receiveTimeout = const Duration(seconds: 6),
|
this.receiveTimeout = const Duration(seconds: 6),
|
||||||
this.queryParameters = const {},
|
this.queryParameters = const {},
|
||||||
this.headers = const {},
|
this.headers = const {},
|
||||||
}) : _baseUrl = baseUrl ?? _defaultBaseURL;
|
}) : baseUrl = baseUrl ?? _defaultBaseURL;
|
||||||
|
|
||||||
final String _baseUrl;
|
|
||||||
|
|
||||||
/// base url to use with client.
|
/// base url to use with client.
|
||||||
String get baseUrl {
|
final String baseUrl;
|
||||||
if (location == null) return _baseUrl;
|
|
||||||
const serviceName = 'chat';
|
|
||||||
final locationName = location!.name;
|
|
||||||
const baseDomainName = 'stream-io-api.com';
|
|
||||||
return 'https://$serviceName-proxy-$locationName.$baseDomainName';
|
|
||||||
}
|
|
||||||
|
|
||||||
/// data center to use with client
|
|
||||||
final Location? location;
|
|
||||||
|
|
||||||
/// connect timeout, default to 6s
|
/// connect timeout, default to 6s
|
||||||
final Duration connectTimeout;
|
final Duration connectTimeout;
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ import 'package:test/test.dart';
|
|||||||
void main() {
|
void main() {
|
||||||
test('should return the all default set params', () {
|
test('should return the all default set params', () {
|
||||||
const options = StreamHttpClientOptions();
|
const options = StreamHttpClientOptions();
|
||||||
expect(options.location, isNull);
|
expect(options.baseUrl, 'https://chat.stream-io-api.com');
|
||||||
expect(options.baseUrl, 'https://chat-us-east-1.stream-io-api.com');
|
|
||||||
expect(options.connectTimeout, const Duration(seconds: 6));
|
expect(options.connectTimeout, const Duration(seconds: 6));
|
||||||
expect(options.receiveTimeout, const Duration(seconds: 6));
|
expect(options.receiveTimeout, const Duration(seconds: 6));
|
||||||
expect(options.queryParameters, const {});
|
expect(options.queryParameters, const {});
|
||||||
@@ -21,39 +20,10 @@ void main() {
|
|||||||
headers: {'test': 'test'},
|
headers: {'test': 'test'},
|
||||||
queryParameters: {'123': '123'},
|
queryParameters: {'123': '123'},
|
||||||
);
|
);
|
||||||
expect(options.location, isNull);
|
|
||||||
expect(options.baseUrl, 'base-url');
|
expect(options.baseUrl, 'base-url');
|
||||||
expect(options.connectTimeout, const Duration(seconds: 3));
|
expect(options.connectTimeout, const Duration(seconds: 3));
|
||||||
expect(options.receiveTimeout, const Duration(seconds: 3));
|
expect(options.receiveTimeout, const Duration(seconds: 3));
|
||||||
expect(options.headers, {'test': 'test'});
|
expect(options.headers, {'test': 'test'});
|
||||||
expect(options.queryParameters, {'123': '123'});
|
expect(options.queryParameters, {'123': '123'});
|
||||||
});
|
});
|
||||||
|
|
||||||
group('should create baseUrl according to provided location', () {
|
|
||||||
test('us-east', () {
|
|
||||||
const options = StreamHttpClientOptions(location: Location.usEast);
|
|
||||||
expect(options.location, isNotNull);
|
|
||||||
expect(options.baseUrl, 'https://chat-proxy-us-east.stream-io-api.com');
|
|
||||||
});
|
|
||||||
test('eu-west', () {
|
|
||||||
const options = StreamHttpClientOptions(location: Location.euWest);
|
|
||||||
expect(options.location, isNotNull);
|
|
||||||
expect(options.baseUrl, 'https://chat-proxy-dublin.stream-io-api.com');
|
|
||||||
});
|
|
||||||
test('mumbai', () {
|
|
||||||
const options = StreamHttpClientOptions(location: Location.mumbai);
|
|
||||||
expect(options.location, isNotNull);
|
|
||||||
expect(options.baseUrl, 'https://chat-proxy-mumbai.stream-io-api.com');
|
|
||||||
});
|
|
||||||
test('sydney', () {
|
|
||||||
const options = StreamHttpClientOptions(location: Location.sydney);
|
|
||||||
expect(options.location, isNotNull);
|
|
||||||
expect(options.baseUrl, 'https://chat-proxy-sydney.stream-io-api.com');
|
|
||||||
});
|
|
||||||
test('singapore', () {
|
|
||||||
const options = StreamHttpClientOptions(location: Location.singapore);
|
|
||||||
expect(options.location, isNotNull);
|
|
||||||
expect(options.baseUrl, 'https://chat-proxy-singapore.stream-io-api.com');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user