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

UUri without UResource should be supported by all API #81

Open
mishap4 opened this issue Jan 31, 2024 · 4 comments
Open

UUri without UResource should be supported by all API #81

mishap4 opened this issue Jan 31, 2024 · 4 comments

Comments

@mishap4
Copy link

mishap4 commented Jan 31, 2024

Please see the output produced by the code below

void test() {
        UAuthority authority = UAuthority.newBuilder()
                .setName("cloud")
                .setId(ByteString.copyFrom(new byte[] {1 ,2 ,3}))
                .build();
        System.out.println("authority: " + authority);

        UEntity entity = UEntityFactory.fromProto(UTwinProto.getDescriptor().getServices().get(0));
        System.out.println("entity: " + entity);

        Descriptors.MethodDescriptor methodDescriptor = (serviceDescriptor.findMethodByName("GetLastMessages"));
        String methodName = methodDescriptor.getName();
        int methodId = methodDescriptor.getOptions().getExtension(UprotocolOptions.methodId);
        UResource resource = UResourceBuilder.forRpcRequest(methodName, methodId);
        System.out.println("resource: " + resource);

        UUri uri = UUri.newBuilder()
                .setAuthority(authority)
                .setEntity(entity)
                //.setResource(resource)
                .build();

        System.out.println("isLong: " + UriValidator.isLongForm(uri));
        System.out.println("isMicro: " + UriValidator.isMicroForm(uri));
        System.out.println("isResolved: " + UriValidator.isResolved(uri));

        String longUri = LongUriSerializer.instance().serialize(uri);
        byte[] microUri = MicroUriSerializer.instance().serialize(uri);
        System.out.println("long uri: " + longUri);
        System.out.println("micro uri: " + Arrays.toString(microUri));
}
authority: name: "cloud"
id: "\001\002\003"

entity: name: "core.utwin"
id: 26
version_major: 1

resource: name: "rpc"
instance: "GetLastMessages"
id: 1

isLong: false
isMicro: false
isResolved: false
long uri: //cloud/core.utwin/1
micro uri: []
@stevenhartley
Copy link
Contributor

@mishap4 , I thought about this and the code is right, as there is no uResource so we cannot encode it in micro and it is not resolved. isLong() might have to return true but the jury is out on that one...

@mishap4
Copy link
Author

mishap4 commented Jan 31, 2024

I believe it should be considered as some default id for resource and isMicro also should work. There are several places we use URI to point to entity only.

@stevenhartley
Copy link
Contributor

stevenhartley commented Jan 31, 2024 via email

@stevenhartley
Copy link
Contributor

@mishap4 can we close this topic?

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