FEATURE: Support long type expiration time in v2 APIs#1101
Conversation
속성 타입 구조 정리 (as-is → to-be)
AS-IS (기존)v1은 한 클래스 계열(
TO-BE (변경 후)v1은 그대로 두고, v2는 역할별로 분리 + [v1 — 변경 X]
[v2 — 신규, long]
역할 분리 요약
|
oliviarla
left a comment
There was a problem hiding this comment.
다음은 클래스명 제안인데, @jhpark816 님도 함께 고민해주시면 좋겠습니다.
AttributeClause -> AttributesIF
AttributesCreate -> CreateAttrs
AttributesUpdate -> UpdateAttrs
AttributeResult -> Attrs (v2 인터페이스에서 getAttrs, setAttrs 메서드를 제공하는 가정 하)
지금은 인자명, 변수명이 제각각인데 클래스명이 결정된 후에 변수명을 하나로 통일하면 될 것 같습니다.
질문을 먼저 합니다.
|
966c773 to
df3b226
Compare
인터페이스와 구현 코드 첨부합니다. v2 - setAttributes API AsyncArcusCommandsIF.java /**
* Set the attributes of the item stored at the given key.
*
* @param key the key
* @param attributes the attributes to set
* @return {@code true} if the attributes were set, otherwise {@code false}
*/
ArcusFuture<Boolean> setAttributes(String key, AttributesUpdate attributes);AsyncArcusCommands.java @Override
public ArcusFuture<Boolean> setAttributes(String key, AttributesUpdate attributes) {
AbstractArcusResult<Boolean> result = new AbstractArcusResult<>(new AtomicReference<>());
ArcusFutureImpl<Boolean> future = new ArcusFutureImpl<>(result);
ArcusClient client = arcusClientSupplier.get();
OperationCallback cb = new OperationCallback() {
@Override
public void receivedStatus(OperationStatus status) {
switch (status.getStatusCode()) {
case SUCCESS:
result.set(true);
break;
case ERR_NOT_FOUND:
result.set(false);
break;
case CANCELLED:
future.internalCancel();
break;
default:
/*
* ATTR_ERROR or unknown statement.
*/
result.addError(key, status);
}
}
@Override
public void complete() {
future.complete();
}
};
Operation op = client.getOpFact().setAttr(key, attributes, cb);
future.setOp(op);
client.addOp(key, op);
return future;
}v2 - getAttributes API AsyncArcusCommandsIF.java /**
* Get the attributes of the item stored at the given key.
*
* @param key the key
* @return the {@link AttributesResult} of the item, or {@code null} if not found
*/
ArcusFuture<AttributesResult> getAttributes(String key);AsyncArcusCommands.java @Override
public ArcusFuture<AttributesResult> getAttributes(String key) {
keyValidator.validateKey(key);
AbstractArcusResult<AttributesResult> result =
new AbstractArcusResult<>(new AtomicReference<>());
ArcusFutureImpl<AttributesResult> future = new ArcusFutureImpl<>(result);
ArcusClient client = arcusClientSupplier.get();
AttributesResult attributes = new AttributesResult();
GetAttrOperation.Callback cb = new GetAttrOperation.Callback() {
@Override
public void gotAttribute(String key, String attr) {
attributes.setAttribute(attr);
}
@Override
public void receivedStatus(OperationStatus status) {
switch (status.getStatusCode()) {
case SUCCESS:
result.set(attributes);
break;
case ERR_NOT_FOUND:
result.set(null);
break;
case CANCELLED:
future.internalCancel();
break;
default:
/*
* ATTR_ERROR or unknown statement.
*/
result.addError(key, status);
}
}
@Override
public void complete() {
future.complete();
}
};
GetAttrOperation op = client.getOpFact().getAttr(key, cb);
future.setOp(op);
client.addOp(key, op);
return future;
} |
df3b226 to
dfb9f74
Compare
|
Attr 관련 클래스 분할, 사용 용도는 확인해 보니 OK입니다.
두 사람이 먼저 합의해 볼 수 있나요? |
|
현재 public interface SetAttrClause {
String stringify();
int getLength();
}기존 구조에서는 SetAttrOperationImpl
-> setArguments(..., attrs)
-> String.valueOf(attrs)
-> attrs.toString()즉, setattr 명령 문자열 생성이 다만 따라서 아래처럼 // as-is
setArguments(bb, "setattr", key, attrs);
// to-be
setArguments(bb, "setattr", key, attrs.stringify());정리하면, |
|
@f1v3-dev stringify() 메서드를 추가하는 것은 좋네요. |
AI에게 물어본 결과는 아래와 같고, 아래 용어가 괜찮은 것 같습니다.
앞서 민경 전임의 제안과 유사한데, |
다만 현재 해당 인터페이스의 역할이 관례만 놓고 보면 인터페이스명에는 |
|
CreateAttributes도 implement 해야 하는 interface이죠? |
CreateAttributes는 사용하지 않는 interface입니다.
|
클래스명을 해당 네이밍으로 변경하도록 하겠습니다. |
dfb9f74 to
b7041ab
Compare
|
해당 PR 이후 아래의 작업 이어서 진행하겠습니다.
|
OK. |
네 맞습니다.
다만, 현재 구조에서는 create / insert-with-create의 경우 해당 로직을 문자열(Clause) 생성 위치
|
|
@f1v3-dev |
public interface SetAttrOperation extends KeyedOperation {
SetAttrClause getAttributes();
}이 인터페이스를 보니 어색해 보이기 때문에, 말씀해주신대로 수정하도록 하겠습니다. |
b7041ab to
bda88de
Compare
bda88de to
45290c1
Compare
🔗 Related Issue
⌨️ What I did
v2 API의 만료 시간 (expiration time) 파라미터 타입을
int에서long으로 변경합니다.이를 통해
int범위를 넘는 Unix timestamp 기반 만료 시각(e.g. 2038년 이후 절대 시각)을 사용할 수 있습니다.long exp를 받도록 변경long만료 시간을 담는AttributesCreate도입OperationFactory,ops/*Operation -> getExpiration method, `ASCII / Binary 프로토콜 구현체까지 타입 변경long값을 그대로 사용int범위를 넘는 값은 예외 처리기존 API(
MemcachedClient,ArcusClient)는 변경되지 않으며int만료 파라미터가long으로 자동 형 변환(auto-widening)이 되어 기존 사용자 코드에는 영향이 없습니다.