Skip to content

Conversation

@morrowgi
Copy link
Collaborator

@morrowgi morrowgi commented Jul 3, 2017

No description provided.

@morrowgi
Copy link
Collaborator Author

morrowgi commented Jul 3, 2017

Implementing #355

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;

/**
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we keeping these kind of comments in micro-server?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

woops will remove...

@Slf4j
public class CouchbaseDistributedMapClient<V> implements DistributedMap<V> {

private final Logger logger = LoggerFactory.getLogger(getClass());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not necessary when you have the lombok @slf4j annotation

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good spot thanks

private long opTimeout;

@Value("${distributed.cache.default.expiration:691200}")
private int expiresAfterSeconds = 691200;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't need to assign this value will be overwritten by Spring annotation same for line 52,55

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok removed the assignment


} catch (final Exception e) {

log.warn("memcache put: {}", e.getMessage());
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you mean couchbase instead of memcache ?

private ElasticacheConnectionTester elasticacheConnectionTester;


@Scheduled(fixedDelay = 60000)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe expose this as a property ? but have it default to 60000

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed as @scheduled expects a constant I needed to assign it directly in code

try {
result = testConnection();
} catch (RuntimeException e) {
log.debug("Could not connect to Cache" + e.getMessage());
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this log at the right level ? also line 41

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was keeping the convention as it was but I think you are right I will log as error if it cannot connect...


private final String key;

private volatile Xor<Void, T> data = Xor.secondary(null); // Void represents
Copy link
Collaborator

@tonyfinn tonyfinn Jul 3, 2017

Choose a reason for hiding this comment

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

Why Xor<Void, T> over just Optional<T>? Or if you're worried about the loaded/not loaded yet case seperately, Future<Optional<T>> ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok I think I can convert to Optional

return currentVersionedKey.withVersion(currentVersionedKey.getVersion() + 1);
}

private VersionedKey loadKeyFromCouchbase() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not coming from Couchbase here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Il update


import java.util.Optional;

public interface DistributedCache<V> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you inherit DistributedMap here?

public class CouchbaseResource {

private final DistributedMap client;
private final DistributedCache client;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd change the reference name as well 😃

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

Successfully merging this pull request may close these issues.

7 participants